🔥 Object Factory Demo -> Using a function as an object factory to reduce boilerplate

TL;DR for @josecgomez (Don’t peek guys)

This works.

:rofl:
Function A → ObjectFactorySimpleExample

output = new DataSet();
var tbl = output.Tables.Add("Objects");
tbl.Columns.Add("Object", typeof(object));

tbl.Rows.Add(new RestClient());

Function B → ObjectConsumerSimpleExample

var ds = ThisLib.ObjectFactorySimpleExample();

var client = ds.Tables[0].Rows[0]["Object"] as RestClient;

var request = new RestRequest("https://google.com/robots.txt", Method.GET);

var response = client.Execute(request);

output = response.Content; 

Output

User-agent: *
User-agent: Yandex
Disallow: /search
Allow: /search/about
Allow: /search/howsearchworks
Disallow: /sdch
Disallow: /groups
Disallow: /index.html?
Disallow: /?
Allow: /?hl=
Disallow: /?hl=*&
Allow: /?hl=*&gws_rd=ssl$
Disallow: /?hl=*&*&gws_rd=ssl
Allow: /?gws_rd=ssl$
Allow: /?pt1=true$
Disallow: /imgres
Disallow: /u/
Disallow: /setprefs
Disallow: /m?
Disallow: /m/
Allow:    /m/finance
Disallow: /wml?
Disallow: /wml/?
Disallow: /wml/search?
Disallow: /xhtml?
Disallow: /xhtml/?
Disallow: /xhtml/search?
Disallow: /xml?
Disallow: /imode?
Disallow: /imode/?
Disallow: /imode/search?
Disallow: /jsky?
Disallow: /jsky/?
Disallow: /jsky/search?
Disallow: /pda?
Disallow: /pda/?
Disallow: /pda/search?
Disallow: /sprint_xhtml
Disallow: /sprint_wml
Disallow: /pqa
Disallow: /gwt/
Disallow: /purchases
Disallow: /local?
Disallow: /local_url
Disallow: /shihui?
Disallow: /shihui/
Disallow: /products?
Disallow: /product_
Disallow: /products_
Disallow: /products;
Disallow: /print
Disallow: /books/
Disallow: /bkshp?*q=
Disallow: /books?*q=
Disallow: /books?*output=
Disallow: /books?*pg=
Disallow: /books?*jtp=
Disallow: /books?*jscmd=
Disallow: /books?*buy=
Disallow: /books?*zoom=
Allow: /books?*q=related:
Allow: /books?*q=editions:
Allow: /books?*q=subject:
Allow: /books/about
Allow: /books?*zoom=1
Allow: /books?*zoom=5
Allow: /books/content?*zoom=1
Allow: /books/content?*zoom=5
Disallow: /patents?
Disallow: /patents/download/
Disallow: /patents/pdf/
Disallow: /patents/related/
Disallow: /scholar
Disallow: /citations?
Allow: /citations?user=
Disallow: /citations?*cstart=
Allow: /citations?view_op=new_profile
Allow: /citations?view_op=top_venues
Allow: /scholar_share
Disallow: /s?
Disallow: /maps?
Allow: /maps?*output=classic
Allow: /maps?*file=
Disallow: /mapstt?
Disallow: /mapslt?
Disallow: /mapabcpoi?
Disallow: /maphp?
Disallow: /mapprint?
Disallow: /maps/
Allow: /maps/$
Allow: /maps/@
Allow: /maps/?q=
Allow: /maps/?hl=
Allow: /maps/?f=
Allow: /maps/?daddr=
Allow: /maps/?entry=wc
Allow: /maps/search/
Allow: /maps/sitemap.xml
Allow: /maps/sitemaps/
Allow: /maps/dir/
Allow: /maps/d/
Allow: /maps/reserve
Allow: /maps/about
Allow: /maps/contrib/
Allow: /maps/match
Allow: /maps/place/
Allow: /maps/_/
Allow: /search?*tbm=map
Allow: /maps/vt?
Allow: /maps/preview
Disallow: /maps/api/js/
Allow: /maps/api/js
Disallow: /mld?
Disallow: /staticmap?
Disallow: /help/maps/streetview/partners/welcome/
Disallow: /help/maps/indoormaps/partners/
Disallow: /lochp?
Disallow: /ie?
Disallow: /uds/
Disallow: /transit?
Disallow: /trends?
Disallow: /trends/music?
Disallow: /trends/hottrends?
Disallow: /trends/viz?
Disallow: /trends/embed.js?
Disallow: /trends/fetchComponent?
Disallow: /trends/beta
Disallow: /trends/topics
Disallow: /trends/explore?
Disallow: /trends/embed
Disallow: /trends/api
Disallow: /musica
Disallow: /musicad
Disallow: /musicas
Disallow: /musicl
Disallow: /musics
Disallow: /musicsearch
Disallow: /musicsp
Disallow: /musiclp
Disallow: /urchin_test/
Disallow: /movies?
Disallow: /wapsearch?
Disallow: /reviews/search?
Disallow: /orkut/albums
Disallow: /cbk
Disallow: /recharge/dashboard/car
Disallow: /recharge/dashboard/static/
Disallow: /profiles/me
Disallow: /s2/profiles/me
Allow: /s2/profiles
Allow: /s2/oz
Allow: /s2/photos
Allow: /s2/search/social
Allow: /s2/static
Disallow: /s2
Disallow: /transconsole/portal/
Disallow: /gcc/
Disallow: /aclk
Disallow: /tbproxy/
Disallow: /imesync/
Disallow: /shenghuo/search?
Disallow: /support/forum/search?
Disallow: /reviews/polls/
Disallow: /hosted/images/
Disallow: /ppob/?
Disallow: /ppob?
Disallow: /accounts/ClientLogin
Disallow: /accounts/ClientAuth
Disallow: /accounts/o8
Allow: /accounts/o8/id
Disallow: /topicsearch?q=
Disallow: /xfx7/
Disallow: /squared/api
Disallow: /squared/search
Disallow: /squared/table
Disallow: /qnasearch?
Disallow: /sidewiki/entry/
Disallow: /quality_form?
Disallow: /labs/popgadget/search
Disallow: /compressiontest/
Disallow: /analytics/feeds/
Disallow: /analytics/partners/comments/
Disallow: /analytics/portal/
Disallow: /analytics/uploads/
Allow: /alerts/manage
Allow: /alerts/remove
Disallow: /alerts/
Allow: /alerts/$
Disallow: /phone/compare/?
Disallow: /travel/clk
Disallow: /travel/entity
Disallow: /travel/search
Disallow: /travel/flights/s/
Disallow: /travel/hotels/entity
Disallow: /travel/hotels/*/entity
Disallow: /travel/hotels/stories
Disallow: /travel/hotels/*/stories
Disallow: /travel/story
Disallow: /hotelfinder/rpc
Disallow: /hotels/rpc
Disallow: /evaluation/
Disallow: /forms/perks/
Disallow: /shopping/suppliers/search
Disallow: /edu/cs4hs/
Disallow: /trustedstores/s/
Disallow: /trustedstores/tm2
Disallow: /trustedstores/verify
Disallow: /shopping?
Disallow: /shopping/product/
Disallow: /shopping/seller
Disallow: /shopping/ratings/account/metrics
Disallow: /shopping/ratings/merchant/immersivedetails
Disallow: /shopping/reviewer
Disallow: /shopping/search
Disallow: /shopping/deals
Disallow: /storefront
Disallow: /storepicker
Disallow: /about/careers/applications/candidate-prep
Disallow: /about/careers/applications/connect-with-a-googler
Disallow: /about/careers/applications/jobs/results?page=
Disallow: /about/careers/applications/jobs/results/?page=
Disallow: /about/careers/applications/jobs/results?*&page=
Disallow: /about/careers/applications/jobs/results/?*&page=
Disallow: /landing/signout.html
Disallow: /gallery/
Disallow: /landing/now/ontap/
Allow: /maps/reserve
Allow: /maps/reserve/partners
Disallow: /maps/reserve/api/
Disallow: /maps/reserve/search
Disallow: /maps/reserve/bookings
Disallow: /maps/reserve/settings
Disallow: /maps/reserve/manage
Disallow: /maps/reserve/payment
Disallow: /maps/reserve/receipt
Disallow: /maps/reserve/sellersignup
Disallow: /maps/reserve/payments
Disallow: /maps/reserve/feedback
Disallow: /maps/reserve/terms
Disallow: /maps/reserve/m/
Disallow: /maps/reserve/b/
Disallow: /maps/reserve/partner-dashboard
Disallow: /local/cars
Disallow: /local/cars/
Disallow: /local/dealership/
Disallow: /local/dining/
Disallow: /local/place/products/
Disallow: /local/place/reviews/
Disallow: /local/place/rap/
Disallow: /local/tab/
Disallow: /localservices/
Disallow: /nonprofits/account/
Disallow: /uviewer
Disallow: /landing/cmsnext-root/

# AdsBot
User-agent: AdsBot-Google
Disallow: /maps/api/js/
Allow: /maps/api/js
Disallow: /maps/api/place/js/
Disallow: /maps/api/staticmap
Disallow: /maps/api/streetview

# New user agent groups must also have a user agent reference in the global (*)
# group. See "Order of precedence" section in
# https://goo.gle/rep#order-of-precedence-for-user-agents
User-agent: Yandex
Disallow: /about/careers/applications/jobs/results
Disallow: /about/careers/applications-a/jobs/results

# Crawlers of certain social media sites are allowed to access page markup when
# google.com/imgres* links are shared. To learn more, please contact
# images-robots-allowlist@google.com.
User-agent: facebookexternalhit
User-agent: Twitterbot
Allow: /imgres
Allow: /search
Disallow: /groups
Disallow: /hosted/images/
Disallow: /m/

Sitemap: https://www.google.com/sitemap.xml

This is something I’m using in an upcoming “Skunk Works” project, and I thought I would share it by itself. Feel free to use it as is, but I’m not necessarily sharing this as a completed or recommended product. Showing some advanced techniques to get by some constraints, as well as just reduce some boilerplate in the future.

Advanced features you may see here:

  • Faking an Enum
  • Retrieving complex non serialized objects from other functions.
  • Sending complex non serialized objects to other functions.
  • Complete and total DataSet abuse.
  • Abuse of delegates and anonymous objects.
  • Dictionaries as switch / case replacement.
  • Dictionary Abuse with those poor delegates.
  • Feature creep
  • Success/Errors/Exceptions/Debug output
  • Exceptions, Errors, and Console output are in a DataSet, which means you can chain them with merge.
  • Use/Abuse of the goto keyword to move some initialization to the bottom of a function for readability.
    • Some of you will hate it, some will love it lol. :rofl:

I still haven’t added any logging features, but it’s on the todo list.

Library → ObjectFactoryDemo ObjectFactoryDemo.efxj (54.1 KB)

This is both a demo of both using a function as an object factory using DataSets, as well as a Function Return/ Debug Template using it.

References →
Newtonsoft.Json.dll

Function → ObjectFactory

This is an object factory for common objects to reduce boilerplate. Note, this is using DataSets to pass raw objects, so this is for internal use. You can call it from other functions that are visible however.

Ok, so what is this one? This function has some helper methods in it that I use often, and are part of my standard template for coding. Well I got tired of all that and wanted to see if I could pull these objects from somewhere else. I wanted to go DRY. (Don’t Repeat Yourself)

Well how do I do that? I mean the objects I use are complex, most are not serializable, etc.
Well, for internal server side code, we have two things going for us →

  • Server side calls do not use REST, they are direct.
  • DataSets can have a column type of object.

Bam, that was it, I was sure of it. So I coded up a simple example, and I’ll be damn, it worked perfectly.
What I did was in one function, call another that returned a dataset with a RestClient fully configured inside the first row of a DataSet. I then just pulled it out, and ran a request through it.
Worked fine :tada:

So anyway, I let the feature creep set in a little bit, so I ended up with this feature list lol →

  • Request an object, or a delegate to a function / action.
  • Run a method on a delegate in the other function.
  • Get a description of an object or delegate.
  • Built in help, if you forget, just call the help object.
  • Self documenting if you follow the pattern.
  • All objects are in a dictionary, with special properties.

Is it overkill, you betcha. I was playing with techniques. Learn / Discard what you will.
Usings →
using Newtonsoft.Json;

Signature →

Direction Name Type
In GetObjectsDS System.Data.DataSet
Out ReturnedObjectsDS System.Data.DataSet
// Define newline for multi-line formatting
string nl = Environment.NewLine;
string methodHelpDescriptionStub = String.Join(nl, new List<string>
{
    "This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.",
    "CallingType.GetDescription returns a description of this method.",
    "Request this method like:"
});
string objectHelpDescriptionStub = String.Join(nl, new List<string>
{
    "This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.",
    "CallingType.GetDescription returns a description of this method.",
    "Request this object like:"
});

//Fake Enum
var CallingType = new
{
    RunMethod      = (bool?)null,
    ReturnDelegate = (bool?)false,
    GetDescription = (bool?)true,
};

Func<DataSet, DataSet> InitReturnDS = (inDS) =>
{
    using(var dsTemp = inDS != null ? inDS : new DataSet())
    {
        var tbl = new DataTable("Helpers") { Columns = { {"Helper", typeof(string)}, {"Object", typeof(object)} } };
        dsTemp.Tables.Add(tbl);
        return dsTemp;
    }
};


Func<(bool? CallingType, string Request, List<object> RequestParameters), object> WrapFunctionID = (req) =>
{
    try
    {
        Func<object, string> FunctionID = (f) =>
        {
            string rawID = f.ToString().Split('.').Last();
            return rawID.EndsWith("Impl") ? rawID.Substring(0, rawID.Length - 4) : rawID;
        };
        var innerFunc = FunctionID;
    
    
        string description = String.Join(nl, new List<string>
        {
            $"METHOD: {req.Request}",
            "This helper returns the function id of your function.",
            methodHelpDescriptionStub,
            $"\tvar {req.Request}            = Helper.Run(\"{req.Request}\", this) as string;",
            $"\tvar Get{req.Request}Object   = Helper.ReturnDelegate(\"{req.Request}\", null) as Func<object, string>;",
            $"\tvar {req.Request}Description = Helper.GetDescription(\"{req.Request}\", null) as string;",
            $"{nl}Signature:{nl}\t {innerFunc.ToString()}{nl}{nl}"
        });
    
        
        if     (req.CallingType == CallingType.RunMethod)      return innerFunc(req.RequestParameters[0]); //Run
        else if(req.CallingType == CallingType.GetDescription) return description;                         //Description
        else                                                   return (object)innerFunc;                   //Delegate
    }
    catch (Exception ex) { return ex; }
};

Func<(bool? CallingType, string Request, List<object> RequestParameters), object> WrapSerialize = (req) =>
{
    try
    {
        Func<object, bool, string> Serialize = (o, f) => JsonConvert.SerializeObject(o, f ? Formatting.Indented : Formatting.None);
        var innerFunc = Serialize;

        string description = String.Join(nl, new List<string>
        {
            $"METHOD: {req.Request}",
            "This helper returns a Newtonsoft Json Serializer helper.",
            methodHelpDescriptionStub,
            $"\tvar result = Helper.Run(\"{req.Request}\", new object[] {{ (object)aSerializableObject, (bool)indented }}) as string;",
            $"\tvar Get{req.Request}Object   = Helper.ReturnDelegate(\"{req.Request}\", null) as Func<object, bool, string>;",
            $"\tvar {req.Request}Description = Helper.GetDescription(\"{req.Request}\", null) as string;",
            $"{nl}Signature:{nl}\t {innerFunc.ToString()}{nl}{nl}"            
        });
    
        if     (req.CallingType == CallingType.RunMethod)      return innerFunc(req.RequestParameters[0], (bool)req.RequestParameters[1]); //Run
        else if(req.CallingType == CallingType.GetDescription) return description;                                                         //Description
        else                                                   return (object)innerFunc;                                                   //Delegate
    }
    catch (Exception ex) { return ex; }

};


//Init "ListErrors" DebugDataSet --------------------------------------------------------------------------------------------------------------------------------------------------------->
var tblExceptions = new { tblName = "Exceptions", dicColumns = new Dictionary<string, Type>() { {"Source", typeof(string)}, {"Exception", typeof(Exception)}, {"Meta", typeof(object)} } };
var tblErrors     = new { tblName = "Errors",     dicColumns = new Dictionary<string, Type>() { {"Source", typeof(string)}, {"Errors",    typeof(string)},    {"Meta", typeof(object)} } };
var tblConsole    = new { tblName = "Console",    dicColumns = new Dictionary<string, Type>() { {"Source", typeof(string)}, {"Messages",  typeof(string)},    {"Meta", typeof(object)} } };

Func<DataSet, string, Dictionary<string, Type>, DataSet> DictionaryToDataSet = (inDS, tblName, dic) =>
{
    inDS = inDS != null ? inDS : new DataSet(); //If you make new, it's no longer mutable, must use return/
    var tblTemp = inDS.Tables.Add(tblName);
    dic.Keys.ToList().ForEach(key =>
    {
        tblTemp.Columns.Add(key, dic[key]);
    });
    return inDS;
};

Func<(bool? CallingType, string Request, List<object> RequestParameters), object> WrapInitExceptionsDS = (req) =>
{
    try
    {
        Func<DataSet, DataSet> InitExceptionsDS = (inDS) =>
        {
            inDS = inDS != null ? inDS : new DataSet(); //If you make new, it's no longer mutable, must use return/
            inDS = DictionaryToDataSet(inDS,  tblExceptions.tblName, tblExceptions.dicColumns);
            inDS = DictionaryToDataSet(inDS,  tblErrors.tblName,     tblErrors.dicColumns);
            inDS = DictionaryToDataSet(inDS,  tblConsole.tblName,    tblConsole.dicColumns);
            return inDS;
        };  
        var innerFunc = InitExceptionsDS;
    
        string description = String.Join(nl, new List<string>
        {
            $"METHOD: {req.Request}",
            "This helper initializes a DebugDataSet",
            methodHelpDescriptionStub,
            $"\tListErrors = Helper.Run(\"{req.Request}\", (DataSet)inDS) as DataSet;",
            $"\tvar Get{req.Request}Object   = Helper.ReturnDelegate(\"{req.Request}\", null) as Func<DataSet, DataSet>;",
            $"\tvar {req.Request}Description = Helper.GetDescription(\"{req.Request}\", null) as string;",
            $"{nl}Signature:{nl}\t {innerFunc.ToString()}{nl}{nl}"            
        });
    
        if     (req.CallingType == CallingType.RunMethod)      return innerFunc((DataSet)req.RequestParameters[0]); //Run
        else if(req.CallingType == CallingType.GetDescription) return description;                                  //Description
        else                                                   return (object)innerFunc;                            //Delegate   
    }
    catch (Exception ex) { return ex; }
};
//<------------------------------------------------------------------------------------------------------------------------------------------------------End Init "ListErrors" DebugDataSet


//Base Methods to add things to the "ListErrors" (Debug) DataSet
Action<DataSet, string, Exception, object>      AddExceptionToDataSetBase = (exDS, id, exception, meta)        => exDS.Tables["Exceptions"].Rows.Add(id, exception, meta);
Action<DataSet, string, string, string, object> AddMessageToDataSetBase   = (exDS, id, tblName, message, meta) => exDS.Tables[tblName].Rows.Add(id, message, meta);

//Just a Dumper for neat Console output if you want it
Func<DataSet, string, string, string, string, bool, bool, string> DumpMessagesToString = (exDS, tblName, fldSourceName, fldName, fldMetaName, dumpMeta, writeLineNumbers) =>
{
    string messageReturn = "";
    
    var srcList = exDS.Tables[tblName].AsEnumerable().Select(fld => fld.Field<string>(fldSourceName)).Distinct().ToList();
    
    srcList.ForEach(msgSrc =>
    {
        var lines = String.Join(String.Empty, exDS.Tables[tblName]
            .AsEnumerable()
            .Where(fld => fld.Field<string>(fldSourceName) == msgSrc)
            .Select(fld => fld.Field<string>(fldName)))
            .ReplaceLineEndings(Environment.NewLine)
            .Split(new[] { Environment.NewLine }, StringSplitOptions.None)
            .ToList();
    
        var formatted = lines
            .Select((line, index) => (writeLineNumbers ? $"({(index + 1).ToString("D4")}) " : "") + $"{line}{Environment.NewLine}" )
            .Take(Math.Max(0, lines.Count - 1));
    
        messageReturn += $"Source: {msgSrc} -> {Environment.NewLine}{String.Concat(formatted)}--------------------------------------------{Environment.NewLine}";
    
        if (dumpMeta)
        {
            var messagesWithMeta = exDS.Tables[tblName]
                .AsEnumerable()
                .Select(fld => new
                {
                    msg = fld.Field<string>(fldName),
                    meta = fld.Field<object>(fldMetaName)
                })
                .Select(mwm =>
                    "MSG + META------------------------------" + Environment.NewLine +
                    mwm.msg +
                    (mwm.meta != null ? Environment.NewLine + JsonConvert.SerializeObject(mwm.meta, Formatting.Indented) : String.Empty) + Environment.NewLine +
                    "------------------------------MSG + META"  + Environment.NewLine)
                .ToList();
                
                messageReturn += Environment.NewLine + string.Join(Environment.NewLine, messagesWithMeta);
          }
    });

     return messageReturn;
};

Func<DataSet, string, string, string, string, bool, string> DumpExceptionsToString = (exDS, tblName, fldSourceName, fldExceptionName, fldMetaName, dumpMeta) =>
{
    var exList = exDS.Tables[tblName].AsEnumerable().Select(fld => new
    {
        Source    = fld.Field<string>(fldSourceName),
        Exception = fld.Field<Exception>(fldExceptionName),
        Meta      = (object)(dumpMeta ? fld.Field<object>(fldMetaName) : null), 
        
    }).ToList();
    
    return JsonConvert.SerializeObject(exList, Formatting.Indented) + nl;
 };

//Returning a Complex Object
Func<(bool? CallingType, string Request, List<object> RequestParameters), object> WrapConsole = (req) =>
{
    try
    {
        object innerObject = null;
    
        //Don't create object unless requested    
        if(req.CallingType != CallingType.GetDescription && req.RequestParameters != null)
        {
            var Console = new
            {
                Write = new Action<string>((message) =>
                    AddMessageToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], "Console", message, null)),
        
                WriteWithMeta = new Action<string, object>((message, meta) =>
                    AddMessageToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], "Console", message, meta)),
            
                WriteLine = new Action<string>((message) =>
                    AddMessageToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], "Console", message + Environment.NewLine, null)),
            
                WriteLineWithMeta = new Action<string, object>((message, meta) =>
                    AddMessageToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], "Console", message + Environment.NewLine, meta)),
                
                DumpConsole = new Func<bool, string>((writeLineNumbers) =>
                    DumpMessagesToString((DataSet)req.RequestParameters[0], "Console", "Source", "Messages", "Meta", false, writeLineNumbers)),
                
                DumpConsoleWithMeta = new Func<bool, string>((writeLineNumbers) =>
                    DumpMessagesToString((DataSet)req.RequestParameters[0], "Console", "Source", "Messages", "Meta", true, writeLineNumbers))
            };
            
            innerObject = Console;
        }
    
        string description = String.Join(nl, new List<string>
        {
            $"OBJECT: {req.Request}",
            $"This helper returns the \"{req.Request}\" Object.",
            objectHelpDescriptionStub,
            "This object needs parameters to construct correctly.",
            $"\tvar {req.Request}A = Helper.Run(\"{req.Request}\", new object[] {{ (DataSet)DebugDataSet, (string)Source }}) as dynamic;",
            $"\tvar {req.Request}B = Helper.ReturnDelegate(\"{req.Request}\", new object[] {{ (DataSet)DebugDataSet, (string)Source }}) as dynamic;",
            $"\tvar {req.Request}Description = Helper.GetDescription(\"{req.Request}\", null) as string;",
            $"{nl}{nl}"
        }); 

        
        //RunMethod & ReturnDelegate return the same here. (The object) 
        return req.CallingType == CallingType.GetDescription ? description : (object)innerObject;  
    }
    catch (Exception ex) { return ex; }
};


Func<(bool? CallingType, string Request, List<object> RequestParameters), object> WrapErrorHelper = (req) =>
{
    try
    {
        object innerObject = null;
        
        //Don't create object unless requested
        if(req.CallingType != CallingType.GetDescription && req.RequestParameters != null)
        {    
            var ErrorHelper = new
            {
                AddExceptionToDataSet = new Action<Exception>((exception) =>
                    AddExceptionToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], exception, null)),
                
                AddExceptionToDataSetWithMeta = new Action<Exception, object>((exception, meta) =>
                    AddExceptionToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], exception, meta)),
                    
                AddErrorToDataSet = new Action<string>((message) =>
                    AddMessageToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], "Errors", message + Environment.NewLine, null)),
        
                AddErrorToDataSetWithMeta = new Action<string, object>((message, meta) =>
                    AddMessageToDataSetBase((DataSet)req.RequestParameters[0], (string)req.RequestParameters[1], "Errors", message + Environment.NewLine, meta)),
        
                DumpExceptions = new Func<string>(() =>
                    DumpExceptionsToString((DataSet)req.RequestParameters[0], "Exceptions", "Source", "Exception", "Meta", false)),
        
                DumpExceptionsWithMeta = new Func<string>(() =>
                    DumpExceptionsToString((DataSet)req.RequestParameters[0], "Exceptions", "Source", "Exception", "Meta", true)),

                DumpErrors = new Func<string>(() =>
                    DumpMessagesToString((DataSet)req.RequestParameters[0], "Errors", "Source", "Errors", "Meta", false, false)),
                
                DumpErrorsWithMeta = new Func<string>(() =>
                    DumpMessagesToString((DataSet)req.RequestParameters[0], "Errors", "Source", "Errors", "Meta", true, false))
                    
            };
            
            innerObject = ErrorHelper;
        }

        string description = String.Join(nl, new List<string>
        {
            $"OBJECT: {req.Request}",
            $"This helper returns the \"{req.Request}\" Object.",
            objectHelpDescriptionStub,
            "This object needs parameters to construct correctly.",
            $"\tvar {req.Request}A = Helper.Run(\"{req.Request}\", new object[] {{ (DataSet)DebugDataSet, (string)Source }}) as dynamic;",
            $"\tvar {req.Request}B = Helper.ReturnDelegate(\"{req.Request}\", new object[] {{ (DataSet)DebugDataSet, (string)Source }}) as dynamic;",
            $"\tvar {req.Request}Description = Helper.GetDescription(\"{req.Request}\", null) as string;",
            $"{nl}{nl}"            
        }); 

        //RunMethod & ReturnDelegate return the same here. (The object) 
        return req.CallingType == CallingType.GetDescription ? description : (object)innerObject;  
    }
    catch (Exception ex) { return ex; }
};

//This one is special, lol
Func<(bool? CallingType, string Request, List<object> RequestParameters), object> WrapHelp = (req) =>
{
    try
    {
        Func<Dictionary<string, Func<(bool? CallingType, string Request, List<object> RequestParameters), object>>, string> Help = (fd) =>
        {
            var sb = new System.Text.StringBuilder();
        
            fd.Keys.ToList().ForEach(fn =>
            {
                var func = fd[fn];
            
                sb.AppendLine(func((CallingType.GetDescription, fn, null)) as string );  
            });
        
            return sb.ToString();
        };
        var innerFunc = Help;

        string description = String.Join(nl, new List<string>
        {
            $"HELP: {req.Request}",
            "This returns help for all the objects in this Helper Dictionary",
            objectHelpDescriptionStub,
            $"\tvar {req.Request}A = Helper.Run(\"{req.Request}\", null) as string;",
            $"\tvar {req.Request}B = Helper.ReturnDelegate(\"{req.Request}\", null) as string;",
            $"\tvar {req.Request}Description = Helper.GetDescription(\"{req.Request}\", null) as string;",            
            $"{nl}Signature:{nl}\t {innerFunc.ToString()}{nl}{nl}"
        });
       
        //RunMethod & ReturnDelegate return the same here. (The Help!)
        if (req.CallingType != CallingType.GetDescription)
            return innerFunc((Dictionary<string, Func<(bool? CallingType, string Request, List<object> RequestParameters), object>>)req.RequestParameters[0]); //Run
        else return description;                                                                                                                               //Description 
    }
    catch (Exception ex) { return ex; }
};

//Context Factory
Func<(bool? CallingType, string Request, List<object> RequestParameters), object> WrapContext = (req) =>
{
    try
    {
        object innerObject = null;
        
        //Don't create object unless requested
        if(req.CallingType != CallingType.GetDescription && req.RequestParameters != null)
        {
            if(req.RequestParameters[0] == "ErpContext") innerObject = Ice.Services.ContextFactory.CreateContext<ErpContext>();
            if(req.RequestParameters[0] == "IceContext") innerObject = Ice.Services.ContextFactory.CreateContext<Ice.IceContext>();
        }
    
        string description = String.Join(nl, new List<string>
        {
            $"OBJECT: {req.Request}",
            $"This helper returns the \"{req.Request}\" Object.",
            objectHelpDescriptionStub,
            "THIS OBJECT MUST BE DISPOSED!!!",
            $"\tvar {req.Request}A = Helper.Run(\"{req.Request}\", \"ErpContext\") as ErpContext;",
            $"\tvar {req.Request}A = Helper.Run(\"{req.Request}\", \"IceContext\") as Ice.IceContext;",
            $"\tvar {req.Request}B = Helper.ReturnDelegate(\"{req.Request}\", \"ErpContext\") as ErpContext;",
            $"\tvar {req.Request}B = Helper.ReturnDelegate(\"{req.Request}\", \"IceContext\") as Ice.IceContext;",
            $"\tvar {req.Request}Description = Helper.GetDescription(\"{req.Request}\", null) as string;",
            $"{nl}{nl}"            
        }); 
    
        //RunMethod & ReturnDelegate return the same here. (The object) 
        return req.CallingType == CallingType.GetDescription ? description : (object)innerObject;  
    }
    catch (Exception ex) { return ex; }
};



//Function Registry
var functionRegistry = new Dictionary<string, Func<(bool? CallingType, string Request, List<object> RequestParameters), object>>()
{
    ["Help"]             = WrapHelp,
    ["FunctionID"]       = WrapFunctionID,
    ["Serialize"]        = WrapSerialize,
    ["InitExceptionsDS"] = WrapInitExceptionsDS,
    ["Console"]          = WrapConsole,
    ["ErrorHelper"]      = WrapErrorHelper,
    ["Context"]          = WrapContext
};


ReturnedObjectsDS = InitReturnDS(ReturnedObjectsDS);

var ObjectsToReturn = new Dictionary<string, object>();

var requestTbl = GetObjectsDS.Tables["Requests"];

var reqList = requestTbl.AsEnumerable().Select(req => new
{
    CallingType       = req.Field<object>("CallingType"), //req.Field<bool>("CallingType"),
    Request           = req.Field<string>("Request"),
    RequestParameters = req.Field<List<object>>("RequestParams")
}).ToList();

    


//Can be called for multiple objects, of course some depend on each other, so use your noggin
foreach(var req in reqList)
{
    if(functionRegistry.ContainsKey(req.Request))
    {
        object returnObject = functionRegistry[req.Request](((bool?)req.CallingType, req.Request, req.Request != "Help" ? req.RequestParameters : new List<object>(){ functionRegistry }));
        ObjectsToReturn.Add(req.Request, returnObject);
    }

};

ObjectsToReturn.Keys.ToList().ForEach(key => ReturnedObjectsDS.Tables["Helpers"].Rows.Add(key, ObjectsToReturn[key]));

Function → TestObjectFactoryFullTemplate

This is the Full Fat Template Demo for the Object Factory.

This one is fully broke out and commented. It has extras. It’s wordy.
Still WAY less wordy than the template I used to use.
Usings → none

Signature →

Direction Name Type
Out Success System.Boolean
Out ListErrors System.Data.DataSet
Out DebugOut System.String
/*FULL FAT TEMPLATE DEMO##############################################################################
  
  Project: Epicor Object Factory Function Demo / Function Debug Harness
  Author: Kevin Lincecum
  License: MIT

  This is the large version of the template I use. It has extra stuff in it.

##############################################################################FULL FAT TEMPLATE DEMO*/

//Fake Enum (RunMethod not supported for objects.)
var CallingType = new { RunMethod = (bool?)null, ReturnDelegate = (bool?)false, GetDescription = (bool?)true };

//ObjectFactory
Func<bool?, string, object, object> GetObject = null;

//Go To bottom and Initialize (Not much down there anymore lol)
goto Initialize;
//Return from bottom after Initialize
ReturnFromInit:

//Mostly redundant, but helpful?
var Helper = new {
    Run            = new Func<string, object, object>((request, requestParams) => GetObject(CallingType.RunMethod,              request, requestParams)),
    GetDescription = new Func<string, object, string>((request, requestParams) => (string)GetObject(CallingType.GetDescription, request, requestParams)),
    ReturnDelegate = new Func<string, object, object>((request, requestParams) => GetObject(CallingType.ReturnDelegate,         request, requestParams)) };

//Initialize DebugDataSet
ListErrors = Helper.Run("InitExceptionsDS", null) as DataSet;

//Grab FunctionID
string FunctionID = Helper.Run("FunctionID", this) as string;
string FunctionIDExtended = $"Efx.{LibraryID}.{FunctionID}";

//Get Newtonsoft Json Serializer
var Serialize = Helper.ReturnDelegate("Serialize", null) as Func<object, bool, string>;

//Get Console
var ConsoleDynamic = Helper.ReturnDelegate("Console", new List<object>() { ListErrors, FunctionIDExtended }) as dynamic;
var Console = new { //This is not needed, but I wanted Intellisense (Code Completion)
    Write               = (Action<string>)ConsoleDynamic.Write,
    WriteLine           = (Action<string>)ConsoleDynamic.WriteLine,
    WriteWithMeta       = (Action<string, object>)ConsoleDynamic.WriteWithMeta,
    WriteLineWithMeta   = (Action<string, object>)ConsoleDynamic.WriteLineWithMeta,
    DumpConsole         = (Func<bool, string>)ConsoleDynamic.DumpConsole,
    DumpConsoleWithMeta = (Func<bool, string>)ConsoleDynamic.DumpConsoleWithMeta };

//Get ErrorHelper
var ErrorHelperDynamic = Helper.ReturnDelegate("ErrorHelper", new List<object>() { ListErrors, FunctionIDExtended }) as dynamic;
var ErrorHelper = new { //This is not needed, but I wanted Intellisense (Code Completion)
    AddExceptionToDataSet         = (Action<Exception>)ErrorHelperDynamic.AddExceptionToDataSet,
    AddExceptionToDataSetWithMeta = (Action<Exception, object>) ErrorHelperDynamic.AddExceptionToDataSetWithMeta,
    AddErrorToDataSet             = (Action<string>)ErrorHelperDynamic.AddErrorToDataSet,
    AddErrorToDataSetWithMeta     = (Action<string, object>)ErrorHelperDynamic.AddErrorToDataSetWithMeta,
    DumpExceptions                = (Func<string>)ErrorHelperDynamic.DumpExceptions,
    DumpExceptionsWithMeta        = (Func<string>)ErrorHelperDynamic.DumpExceptionsWithMeta,
    DumpErrors                    = (Func<string>)ErrorHelperDynamic.DumpErrors,
    DumpErrorsWithMeta            = (Func<string>)ErrorHelperDynamic.DumpErrorsWithMeta };
    

try
{//BEGIN CODE#############################################################################################################################


    //This will retrieve the "Help" from the factory, when you forget...
    var help = Helper.Run("Help", null) as string;
    

    //This is not the system "Console". This is local. This puts it in the ListErrors Debug DataSet.
    //We will dump it to the console in the 'finally'
    Console.WriteLine(help); //Prints the help.

    
    //Prints the description for an object.
    Console.WriteLine(Helper.GetDescription("Console", null));

    
    //Get a delegate from the Factory.
    var GetFunctionID = Helper.ReturnDelegate("FunctionID", null) as Func<object, string>;
    Console.WriteLine("Ran from delegate [FunctionID]: " + GetFunctionID(this));    


    //Run a function from the Factory.
    var FunctionIDForDemo = Helper.Run("FunctionID", this) as string;
    Console.WriteLine("Ran from the Factory [FunctionID]: " + FunctionIDForDemo);    


    //The [Console] object -> (Look in 'finally' section for dumpers)
    Console.Write("Hello ");     //No new line
    Console.WriteLine("World!"); //On same line

    Console.WriteWithMeta("Hello ", "ABC");     //No new line, has extra "Meta" data attached
    Console.WriteLineWithMeta("World!", "DEF"); //On same line, has extra "Meta" data attached


    //The [ErrorHelper] Object -> (Look in 'finally' section for dumpers)
    ErrorHelper.AddExceptionToDataSet(new BLException("Dang!"));
    ErrorHelper.AddExceptionToDataSetWithMeta(new BLException("Ooops!"), "Oh no!");
    
    ErrorHelper.AddErrorToDataSet("Woot!");
    ErrorHelper.AddErrorToDataSetWithMeta("Yo Dawg!", "Yumm");


    //Simple Serializer
    var anObject = new { Example = "Yep", AnotherField = 7 }; 
    var someJson = Serialize(anObject, true);
    Console.WriteLine(someJson);


    //Grab a Context for Convenience (ErpContext or IceContext)
    //using(var Db2 = Helper.ReturnDelegate("Context", "ErpContext") as IceContext)
    using(var Db2 = Helper.ReturnDelegate("Context", "ErpContext") as ErpContext)
    {
        Console.WriteLine(Serialize(Db2.ABCCode.FirstOrDefault(), true));
    }


    Console.WriteLine("Thus endeth the demo. ;)");


    Success = true;

    
//###############################################################################################################################END CODE
}
catch (Exception mainEx)
{
    Success = false;
    ErrorHelper.AddExceptionToDataSet(mainEx);
}
finally
{//Turned on when debugging (Turn on or off what you don't want) All on for demo. đź’© Takes a big dump. đź’©
    bool lineNumbers = false;
      DebugOut += $"CONSOLE######################################################CONSOLE{Environment.NewLine}";
    try { DebugOut += Console.DumpConsole(lineNumbers); } catch {}
      DebugOut += $"ERRORHELPEREXCEPTIONS##########################ERRORHELPEREXCEPTIONS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpExceptions(); } catch {}
      DebugOut += $"ERRORHELPERERRORS##################################ERRORHELPERERRORS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpErrors(); } catch {}

      DebugOut += $"{Environment.NewLine}WITHMETA####################################################WITHMETA{Environment.NewLine}";
      DebugOut += $"WITHMETA####################################################WITHMETA{Environment.NewLine}{Environment.NewLine}";

    lineNumbers = true;
      DebugOut += $"CONSOLE######################################################CONSOLE{Environment.NewLine}";
    try { DebugOut += Console.DumpConsoleWithMeta(lineNumbers); } catch {}
      DebugOut += $"ERRORHELPER##############################################ERRORHELPER{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpExceptionsWithMeta(); } catch {}
      DebugOut += $"ERRORHELPERERRORS##################################ERRORHELPERERRORS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpErrorsWithMeta(); } catch {}

}
return; //Safety Stop DO NOT REMOVE (Infinite Loop)

//From Top
Initialize:

GetObject = (callingType, request, requestParams) =>
{//This will return an object from the factory.
    using (var dsTemp = new DataSet())
    {
        var tblTemp = new DataTable("Requests") { Columns = { {"CallingType", typeof(object)}, { "Request", typeof(string) }, { "RequestParams", typeof(List<object>) } } };
        dsTemp.Tables.Add(tblTemp);
        object cType = (callingType.HasValue ? (object)callingType : (object)DBNull.Value);
        object rParams = requestParams is object[] ? ((object[])requestParams).ToList() : (requestParams is List<object> ? requestParams : new List<object>(){requestParams});
        tblTemp.Rows.Add(cType, request, rParams);
        var returnObject = ThisLib.ObjectFactory(dsTemp).Tables["Helpers"].Rows[0]["Object"]; return returnObject is Exception ? throw (Exception)returnObject : returnObject;
    }
};

//Return to Top
goto ReturnFromInit;

Function → TestObjectFactoryMedium

This is the Medium Fat Template Demo for the Object Factory.
Usings → none

This one is condensed. Some of the Init is still at the bottom. The extras are gone.
Signature →

Direction Name Type
Out Success System.Boolean
Out ListErrors System.Data.DataSet
Out DebugOut System.String
/*MEDIUM FAT TEMPLATE DEMO##############################################################################
  
  Project: Epicor Object Factory Function Demo / Function Debug Harness
  Author: Kevin Lincecum
  License: MIT

  This is the medium version of the template I use. Extras stripped out.
  This is slightly less wordy, especially if you pull out the comments.
  I prefer the full fat, with or without comments.
  Looking at it again though, this is growing on me.

##############################################################################MEDIUM FAT TEMPLATE DEMO*/


var CallingType = new { RunMethod = (bool?)null, ReturnDelegate = (bool?)false, GetDescription = (bool?)true };
Func<bool?, string, object, object> GetObject = null;
goto Initialize; //Go To bottom and Initialize (Not much down there anymore lol)
ReturnFromInit: //Return from bottom after Initialize
ListErrors = GetObject(CallingType.RunMethod, "InitExceptionsDS", null) as DataSet;
string FunctionID = GetObject(CallingType.RunMethod, "FunctionID", this) as string;
string FunctionIDExtended = $"Efx.{LibraryID}.{FunctionID}";
var Serialize = GetObject(CallingType.ReturnDelegate, "Serialize", null) as Func<object, bool, string>;
var Console = GetObject(CallingType.ReturnDelegate, "Console", new List<object>() { ListErrors, FunctionIDExtended }) as dynamic;
var ErrorHelper = GetObject(CallingType.ReturnDelegate, "ErrorHelper", new List<object>() { ListErrors, FunctionIDExtended }) as dynamic;
    

try
{//BEGIN CODE#############################################################################################################################


    //This will retrieve the "Help" from the factory, when you forget...
    var help = GetObject(CallingType.RunMethod, "Help", null) as string;
    

    //This is not the system "Console". This is local. This puts it in the ListErrors Debug DataSet.
    //We will dump it to the console in the 'finally'
    Console.WriteLine(help); //Prints the help.

    
    //Prints the description for an object.
    Console.WriteLine(GetObject(CallingType.GetDescription, "Console", null) as string);

    
    //Get a delegate from the Factory.
    var GetFunctionID = GetObject(CallingType.ReturnDelegate, "FunctionID", null) as Func<object, string>;
    Console.WriteLine("Ran from delegate [FunctionID]: " + GetFunctionID(this));    


    //Run a function from the Factory.
    var FunctionIDForDemo = GetObject(CallingType.RunMethod, "FunctionID", this) as string;
    Console.WriteLine("Ran from the Factory [FunctionID]: " + FunctionIDForDemo);    


    //The [Console] object -> (Look in 'finally' section for dumpers)
    Console.Write("Hello ");     //No new line
    Console.WriteLine("World!"); //On same line

    Console.WriteWithMeta("Hello ", "ABC");     //No new line, has extra "Meta" data attached
    Console.WriteLineWithMeta("World!", "DEF"); //On same line, has extra "Meta" data attached


    //The [ErrorHelper] Object -> (Look in 'finally' section for dumpers)
    ErrorHelper.AddExceptionToDataSet(new BLException("Dang!"));
    ErrorHelper.AddExceptionToDataSetWithMeta(new BLException("Ooops!"), "Oh no!");
    
    ErrorHelper.AddErrorToDataSet("Woot!");
    ErrorHelper.AddErrorToDataSetWithMeta("Yo Dawg!", "Yumm");


    //Simple Serializer
    var anObject = new { Example = "Yep", AnotherField = 7 }; 
    var someJson = Serialize(anObject, true);
    Console.WriteLine(someJson);


    //Grab a Context for Convenience (ErpContext or IceContext)
    //using(var Db2 = GetObject(CallingType.ReturnDelegate, "Context", "ErpContext") as IceContext)
    using(var Db2 = GetObject(CallingType.ReturnDelegate, "Context", "ErpContext") as ErpContext)
    {
        Console.WriteLine(Serialize(Db2.ABCCode.FirstOrDefault(), true));
    }
    

    Console.WriteLine("Thus endeth the demo. ;)");


    Success = true;

    
//###############################################################################################################################END CODE
}
catch (Exception mainEx)
{
    Success = false;
    ErrorHelper.AddExceptionToDataSet(mainEx);
}
finally
{//Turned on when debugging (Turn on or off what you don't want) All on for demo. đź’© Takes a big dump. đź’©
    bool lineNumbers = false;
      DebugOut += $"CONSOLE######################################################CONSOLE{Environment.NewLine}";
    try { DebugOut += Console.DumpConsole(lineNumbers); } catch {}
      DebugOut += $"ERRORHELPEREXCEPTIONS##########################ERRORHELPEREXCEPTIONS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpExceptions(); } catch {}
      DebugOut += $"ERRORHELPERERRORS##################################ERRORHELPERERRORS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpErrors(); } catch {}

      DebugOut += $"{Environment.NewLine}WITHMETA####################################################WITHMETA{Environment.NewLine}";
      DebugOut += $"WITHMETA####################################################WITHMETA{Environment.NewLine}{Environment.NewLine}";

    lineNumbers = true;
      DebugOut += $"CONSOLE######################################################CONSOLE{Environment.NewLine}";
    try { DebugOut += Console.DumpConsoleWithMeta(lineNumbers); } catch {}
      DebugOut += $"ERRORHELPER##############################################ERRORHELPER{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpExceptionsWithMeta(); } catch {}
      DebugOut += $"ERRORHELPERERRORS##################################ERRORHELPERERRORS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpErrorsWithMeta(); } catch {}

}
return; //Safety Stop DO NOT REMOVE (Infinite Loop)

//From Top
Initialize:

GetObject = (callingType, request, requestParams) =>
{//This will return an object from the factory.
    using (var dsTemp = new DataSet())
    {
        var tblTemp = new DataTable("Requests") { Columns = { {"CallingType", typeof(object)}, { "Request", typeof(string) }, { "RequestParams", typeof(List<object>) } } };
        dsTemp.Tables.Add(tblTemp);
        object cType = (callingType.HasValue ? (object)callingType : (object)DBNull.Value);
        object rParams = requestParams is object[] ? ((object[])requestParams).ToList() : (requestParams is List<object> ? requestParams : new List<object>(){requestParams});
        tblTemp.Rows.Add(cType, request, rParams);
        var returnObject = ThisLib.ObjectFactory(dsTemp).Tables["Helpers"].Rows[0]["Object"]; return returnObject is Exception ? throw (Exception)returnObject : returnObject;
    }
};

//Return to Top
goto ReturnFromInit;

Function → TestObjectFactoryMinimum

This is the Low Fat Template Demo for the Object Factory.

This one is pretty minified. Everything is at the top and condensed. I hate it.
Usings → none

Signature →

Direction Name Type
Out Success System.Boolean
Out ListErrors System.Data.DataSet
Out DebugOut System.String
/*LOW FAT TEMPLATE DEMO##############################################################################
  
  Project: Epicor Object Factory Function Demo / Function Debug Harness
  Author: Kevin Lincecum
  License: MIT

  This is the minimum version of the template I use. Extras stripped out.
  The init for everything is now at the top. Everything is stripped and minimized.
  I don't like it, but here it is anyway.

##############################################################################LOW FAT TEMPLATE DEMO*/

var CallingType = new { RunMethod = (bool?)null, ReturnDelegate = (bool?)false, GetDescription = (bool?)true };
Func<bool?, string, object, object> GetObject = (callingType, request, requestParams) => {
 using (var dsTemp = new DataSet()) { var tblTemp = new DataTable("Requests") { Columns = { {"CallingType", typeof(object)}, { "Request", typeof(string) }, { "RequestParams", typeof(List<object>) } } };
dsTemp.Tables.Add(tblTemp); object cType = (callingType.HasValue ? (object)callingType : (object)DBNull.Value); object rParams = requestParams is object[] ? ((object[])requestParams).ToList() : (requestParams is List<object> ? requestParams : new List<object>(){requestParams}); tblTemp.Rows.Add(cType, request, rParams); var returnObject = ThisLib.ObjectFactory(dsTemp).Tables["Helpers"].Rows[0]["Object"]; return returnObject is Exception ? throw (Exception)returnObject : returnObject; } };
ListErrors = GetObject(CallingType.RunMethod, "InitExceptionsDS", null) as DataSet;
string FunctionID = GetObject(CallingType.RunMethod, "FunctionID", this) as string; string FunctionIDExtended = $"Efx.{LibraryID}.{FunctionID}";
var Serialize = GetObject(CallingType.ReturnDelegate, "Serialize", null) as Func<object, bool, string>;
var Console = GetObject(CallingType.ReturnDelegate, "Console", new List<object>() { ListErrors, FunctionIDExtended }) as dynamic;
var ErrorHelper = GetObject(CallingType.ReturnDelegate, "ErrorHelper", new List<object>() { ListErrors, FunctionIDExtended }) as dynamic;
    

try
{//BEGIN CODE#############################################################################################################################


    //This will retrieve the "Help" from the factory, when you forget...
    var help = GetObject(CallingType.RunMethod, "Help", null) as string;
    

    //This is not the system "Console". This is local. This puts it in the ListErrors Debug DataSet.
    //We will dump it to the console in the 'finally'
    Console.WriteLine(help); //Prints the help.

    
    //Prints the description for an object.
    Console.WriteLine(GetObject(CallingType.GetDescription, "Console", null) as string);

    
    //Get a delegate from the Factory.
    var GetFunctionID = GetObject(CallingType.ReturnDelegate, "FunctionID", null) as Func<object, string>;
    Console.WriteLine("Ran from delegate [FunctionID]: " + GetFunctionID(this));    


    //Run a function from the Factory.
    var FunctionIDForDemo = GetObject(CallingType.RunMethod, "FunctionID", this) as string;
    Console.WriteLine("Ran from the Factory [FunctionID]: " + FunctionIDForDemo);    


    //The [Console] object -> (Look in 'finally' section for dumpers)
    Console.Write("Hello ");     //No new line
    Console.WriteLine("World!"); //On same line

    Console.WriteWithMeta("Hello ", "ABC");     //No new line, has extra "Meta" data attached
    Console.WriteLineWithMeta("World!", "DEF"); //On same line, has extra "Meta" data attached


    //The [ErrorHelper] Object -> (Look in 'finally' section for dumpers)
    ErrorHelper.AddExceptionToDataSet(new BLException("Dang!"));
    ErrorHelper.AddExceptionToDataSetWithMeta(new BLException("Ooops!"), "Oh no!");
    
    ErrorHelper.AddErrorToDataSet("Woot!");
    ErrorHelper.AddErrorToDataSetWithMeta("Yo Dawg!", "Yumm");


    //Simple Serializer
    var anObject = new { Example = "Yep", AnotherField = 7 }; 
    var someJson = Serialize(anObject, true);
    Console.WriteLine(someJson);


    //Grab a Context for Convenience (ErpContext or IceContext)
    //using(var Db2 = GetObject(CallingType.ReturnDelegate, "Context", "ErpContext") as IceContext)
    using(var Db2 = GetObject(CallingType.ReturnDelegate, "Context", "ErpContext") as ErpContext)
    {
        Console.WriteLine(Serialize(Db2.ABCCode.FirstOrDefault(), true));
    }
    

    Console.WriteLine("Thus endeth the demo. ;)");


    Success = true;

    
//###############################################################################################################################END CODE
}
catch (Exception mainEx)
{
    Success = false;
    ErrorHelper.AddExceptionToDataSet(mainEx);
}
finally
{//Turned on when debugging (Turn on or off what you don't want) All on for demo. đź’© Takes a big dump. đź’©
    bool lineNumbers = false;
      DebugOut += $"CONSOLE######################################################CONSOLE{Environment.NewLine}";
    try { DebugOut += Console.DumpConsole(lineNumbers); } catch {}
      DebugOut += $"ERRORHELPEREXCEPTIONS##########################ERRORHELPEREXCEPTIONS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpExceptions(); } catch {}
      DebugOut += $"ERRORHELPERERRORS##################################ERRORHELPERERRORS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpErrors(); } catch {}

      DebugOut += $"{Environment.NewLine}WITHMETA####################################################WITHMETA{Environment.NewLine}";
      DebugOut += $"WITHMETA####################################################WITHMETA{Environment.NewLine}{Environment.NewLine}";

    lineNumbers = true;
      DebugOut += $"CONSOLE######################################################CONSOLE{Environment.NewLine}";
    try { DebugOut += Console.DumpConsoleWithMeta(lineNumbers); } catch {}
      DebugOut += $"ERRORHELPER##############################################ERRORHELPER{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpExceptionsWithMeta(); } catch {}
      DebugOut += $"ERRORHELPERERRORS##################################ERRORHELPERERRORS{Environment.NewLine}";
    try { DebugOut += ErrorHelper.DumpErrorsWithMeta(); } catch {}
}

Output of one of the Test Functions, with EVERYTHING turned on.

ListErrors (DataSet)

{
  "Exceptions": [
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Exception": {
        "ClassName": "Ice.BLException",
        "Message": "Dang!",
        "Data": null,
        "InnerException": null,
        "HelpURL": null,
        "StackTraceString": null,
        "RemoteStackTraceString": null,
        "RemoteStackIndex": 0,
        "ExceptionMethod": null,
        "HResult": -2146232832,
        "Source": null,
        "WatsonBuckets": null
      },
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Exception": {
        "ClassName": "Ice.BLException",
        "Message": "Ooops!",
        "Data": null,
        "InnerException": null,
        "HelpURL": null,
        "StackTraceString": null,
        "RemoteStackTraceString": null,
        "RemoteStackIndex": 0,
        "ExceptionMethod": null,
        "HResult": -2146232832,
        "Source": null,
        "WatsonBuckets": null
      },
      "Meta": "Oh no!"
    }
  ],
  "Errors": [
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Errors": "Woot!\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Errors": "Yo Dawg!\r\n",
      "Meta": "Yumm"
    }
  ],
  "Console": [
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "HELP: Help\r\nThis returns help for all the objects in this Helper Dictionary\r\nThis is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this object like:\r\n\tvar HelpA = Helper.Run(\"Help\", null) as string;\r\n\tvar HelpB = Helper.ReturnDelegate(\"Help\", null) as string;\r\n\tvar HelpDescription = Helper.GetDescription(\"Help\", null) as string;\r\n\r\nSignature:\r\n\t System.Func`2[System.Collections.Generic.Dictionary`2[System.String,System.Func`2[System.ValueTuple`3[System.Nullable`1[System.Boolean],System.String,System.Collections.Generic.List`1[System.Object]],System.Object]],System.String]\r\n\r\n\r\nMETHOD: FunctionID\r\nThis helper returns the function id of your function.\r\nThis is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this method like:\r\n\tvar FunctionID            = Helper.Run(\"FunctionID\", this) as string;\r\n\tvar GetFunctionIDObject   = Helper.ReturnDelegate(\"FunctionID\", null) as Func<object, string>;\r\n\tvar FunctionIDDescription = Helper.GetDescription(\"FunctionID\", null) as string;\r\n\r\nSignature:\r\n\t System.Func`2[System.Object,System.String]\r\n\r\n\r\nMETHOD: Serialize\r\nThis helper returns a Newtonsoft Json Serializer helper.\r\nThis is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this method like:\r\n\tvar result = Helper.Run(\"Serialize\", new object[] { (object)aSerializableObject, (bool)indented }) as string;\r\n\tvar GetSerializeObject   = Helper.ReturnDelegate(\"Serialize\", null) as Func<object, bool, string>;\r\n\tvar SerializeDescription = Helper.GetDescription(\"Serialize\", null) as string;\r\n\r\nSignature:\r\n\t System.Func`3[System.Object,System.Boolean,System.String]\r\n\r\n\r\nMETHOD: InitExceptionsDS\r\nThis helper initializes a DebugDataSet\r\nThis is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this method like:\r\n\tListErrors = Helper.Run(\"InitExceptionsDS\", (DataSet)inDS) as DataSet;\r\n\tvar GetInitExceptionsDSObject   = Helper.ReturnDelegate(\"InitExceptionsDS\", null) as Func<DataSet, DataSet>;\r\n\tvar InitExceptionsDSDescription = Helper.GetDescription(\"InitExceptionsDS\", null) as string;\r\n\r\nSignature:\r\n\t System.Func`2[System.Data.DataSet,System.Data.DataSet]\r\n\r\n\r\nOBJECT: Console\r\nThis helper returns the \"Console\" Object.\r\nThis is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this object like:\r\nThis object needs parameters to construct correctly.\r\n\tvar ConsoleA = Helper.Run(\"Console\", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;\r\n\tvar ConsoleB = Helper.ReturnDelegate(\"Console\", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;\r\n\tvar ConsoleDescription = Helper.GetDescription(\"Console\", null) as string;\r\n\r\n\r\n\r\nOBJECT: ErrorHelper\r\nThis helper returns the \"ErrorHelper\" Object.\r\nThis is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this object like:\r\nThis object needs parameters to construct correctly.\r\n\tvar ErrorHelperA = Helper.Run(\"ErrorHelper\", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;\r\n\tvar ErrorHelperB = Helper.ReturnDelegate(\"ErrorHelper\", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;\r\n\tvar ErrorHelperDescription = Helper.GetDescription(\"ErrorHelper\", null) as string;\r\n\r\n\r\n\r\nOBJECT: Context\r\nThis helper returns the \"Context\" Object.\r\nThis is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this object like:\r\nTHIS OBJECT MUST BE DISPOSED!!!\r\n\tvar ContextA = Helper.Run(\"Context\", \"ErpContext\") as ErpContext;\r\n\tvar ContextA = Helper.Run(\"Context\", \"IceContext\") as Ice.IceContext;\r\n\tvar ContextB = Helper.ReturnDelegate(\"Context\", \"ErpContext\") as ErpContext;\r\n\tvar ContextB = Helper.ReturnDelegate(\"Context\", \"IceContext\") as Ice.IceContext;\r\n\tvar ContextDescription = Helper.GetDescription(\"Context\", null) as string;\r\n\r\n\r\n\r\n\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "OBJECT: Console\r\nThis helper returns the \"Console\" Object.\r\nThis is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.\r\nCallingType.GetDescription returns a description of this method.\r\nRequest this object like:\r\nThis object needs parameters to construct correctly.\r\n\tvar ConsoleA = Helper.Run(\"Console\", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;\r\n\tvar ConsoleB = Helper.ReturnDelegate(\"Console\", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;\r\n\tvar ConsoleDescription = Helper.GetDescription(\"Console\", null) as string;\r\n\r\n\r\n\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "Ran from delegate [FunctionID]: TestObjectFactoryFullTemplate\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "Ran from the Factory [FunctionID]: TestObjectFactoryFullTemplate\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "Hello ",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "World!\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "Hello ",
      "Meta": "ABC"
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "World!\r\n",
      "Meta": "DEF"
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "{\r\n  \"Example\": \"Yep\",\r\n  \"AnotherField\": 7\r\n}\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "{\r\n  \"$id\": \"1\",\r\n  \"Company\": \"000000\",\r\n  \"ABCCode1\": \"A\",\r\n  \"CountFreq\": 30,\r\n  \"ExcludeFromCC\": false,\r\n  \"StockValPcnt\": 0.0,\r\n  \"PcntTolerance\": 0.0,\r\n  \"CalcPcnt\": false,\r\n  \"CalcQty\": false,\r\n  \"CalcValue\": false,\r\n  \"QtyTolerance\": 0.0,\r\n  \"ValueTolerance\": 0.0,\r\n  \"ShipToCustNum\": 0,\r\n  \"SysRevID\": \"AAAAAAi6GeQ=\",\r\n  \"SysRowID\": \"acbcb805-9d15-fca7-e311-33e0dbc8c227\",\r\n  \"EntityKey\": {\r\n    \"$id\": \"2\",\r\n    \"EntitySetName\": \"ABCCode\",\r\n    \"EntityContainerName\": \"ErpContext\",\r\n    \"EntityKeyValues\": [\r\n      {\r\n        \"Key\": \"SysRowID\",\r\n        \"Value\": \"acbcb805-9d15-fca7-e311-33e0dbc8c227\"\r\n      }\r\n    ]\r\n  }\r\n}\r\n",
      "Meta": null
    },
    {
      "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
      "Messages": "Thus endeth the demo. ;)\r\n",
      "Meta": null
    }
  ]
}

DebugOut (Dumps from Console, Exceptions, Errors) Lot’s of :poop:

CONSOLE######################################################CONSOLE
Source: Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate -> 
HELP: Help
This returns help for all the objects in this Helper Dictionary
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
	var HelpA = Helper.Run("Help", null) as string;
	var HelpB = Helper.ReturnDelegate("Help", null) as string;
	var HelpDescription = Helper.GetDescription("Help", null) as string;

Signature:
	 System.Func`2[System.Collections.Generic.Dictionary`2[System.String,System.Func`2[System.ValueTuple`3[System.Nullable`1[System.Boolean],System.String,System.Collections.Generic.List`1[System.Object]],System.Object]],System.String]


METHOD: FunctionID
This helper returns the function id of your function.
This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
CallingType.GetDescription returns a description of this method.
Request this method like:
	var FunctionID            = Helper.Run("FunctionID", this) as string;
	var GetFunctionIDObject   = Helper.ReturnDelegate("FunctionID", null) as Func<object, string>;
	var FunctionIDDescription = Helper.GetDescription("FunctionID", null) as string;

Signature:
	 System.Func`2[System.Object,System.String]


METHOD: Serialize
This helper returns a Newtonsoft Json Serializer helper.
This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
CallingType.GetDescription returns a description of this method.
Request this method like:
	var result = Helper.Run("Serialize", new object[] { (object)aSerializableObject, (bool)indented }) as string;
	var GetSerializeObject   = Helper.ReturnDelegate("Serialize", null) as Func<object, bool, string>;
	var SerializeDescription = Helper.GetDescription("Serialize", null) as string;

Signature:
	 System.Func`3[System.Object,System.Boolean,System.String]


METHOD: InitExceptionsDS
This helper initializes a DebugDataSet
This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
CallingType.GetDescription returns a description of this method.
Request this method like:
	ListErrors = Helper.Run("InitExceptionsDS", (DataSet)inDS) as DataSet;
	var GetInitExceptionsDSObject   = Helper.ReturnDelegate("InitExceptionsDS", null) as Func<DataSet, DataSet>;
	var InitExceptionsDSDescription = Helper.GetDescription("InitExceptionsDS", null) as string;

Signature:
	 System.Func`2[System.Data.DataSet,System.Data.DataSet]


OBJECT: Console
This helper returns the "Console" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
This object needs parameters to construct correctly.
	var ConsoleA = Helper.Run("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleB = Helper.ReturnDelegate("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleDescription = Helper.GetDescription("Console", null) as string;



OBJECT: ErrorHelper
This helper returns the "ErrorHelper" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
This object needs parameters to construct correctly.
	var ErrorHelperA = Helper.Run("ErrorHelper", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ErrorHelperB = Helper.ReturnDelegate("ErrorHelper", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ErrorHelperDescription = Helper.GetDescription("ErrorHelper", null) as string;



OBJECT: Context
This helper returns the "Context" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
THIS OBJECT MUST BE DISPOSED!!!
	var ContextA = Helper.Run("Context", "ErpContext") as ErpContext;
	var ContextA = Helper.Run("Context", "IceContext") as Ice.IceContext;
	var ContextB = Helper.ReturnDelegate("Context", "ErpContext") as ErpContext;
	var ContextB = Helper.ReturnDelegate("Context", "IceContext") as Ice.IceContext;
	var ContextDescription = Helper.GetDescription("Context", null) as string;




OBJECT: Console
This helper returns the "Console" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
This object needs parameters to construct correctly.
	var ConsoleA = Helper.Run("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleB = Helper.ReturnDelegate("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleDescription = Helper.GetDescription("Console", null) as string;



Ran from delegate [FunctionID]: TestObjectFactoryFullTemplate
Ran from the Factory [FunctionID]: TestObjectFactoryFullTemplate
Hello World!
Hello World!
{
  "Example": "Yep",
  "AnotherField": 7
}
{
  "$id": "1",
  "Company": "000000",
  "ABCCode1": "A",
  "CountFreq": 30,
  "ExcludeFromCC": false,
  "StockValPcnt": 0.0,
  "PcntTolerance": 0.0,
  "CalcPcnt": false,
  "CalcQty": false,
  "CalcValue": false,
  "QtyTolerance": 0.0,
  "ValueTolerance": 0.0,
  "ShipToCustNum": 0,
  "SysRevID": "AAAAAAi6GeQ=",
  "SysRowID": "acbcb805-9d15-fca7-e311-33e0dbc8c227",
  "EntityKey": {
    "$id": "2",
    "EntitySetName": "ABCCode",
    "EntityContainerName": "ErpContext",
    "EntityKeyValues": [
      {
        "Key": "SysRowID",
        "Value": "acbcb805-9d15-fca7-e311-33e0dbc8c227"
      }
    ]
  }
}
Thus endeth the demo. ;)
--------------------------------------------
ERRORHELPEREXCEPTIONS##########################ERRORHELPEREXCEPTIONS
[
  {
    "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
    "Exception": {
      "ClassName": "Ice.BLException",
      "Message": "Dang!",
      "Data": null,
      "InnerException": null,
      "HelpURL": null,
      "StackTraceString": null,
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "ExceptionMethod": null,
      "HResult": -2146232832,
      "Source": null,
      "WatsonBuckets": null
    },
    "Meta": null
  },
  {
    "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
    "Exception": {
      "ClassName": "Ice.BLException",
      "Message": "Ooops!",
      "Data": null,
      "InnerException": null,
      "HelpURL": null,
      "StackTraceString": null,
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "ExceptionMethod": null,
      "HResult": -2146232832,
      "Source": null,
      "WatsonBuckets": null
    },
    "Meta": null
  }
]
ERRORHELPERERRORS##################################ERRORHELPERERRORS
Source: Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate -> 
Woot!
Yo Dawg!
--------------------------------------------

WITHMETA####################################################WITHMETA
WITHMETA####################################################WITHMETA

CONSOLE######################################################CONSOLE
Source: Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate -> 
(0001) HELP: Help
(0002) This returns help for all the objects in this Helper Dictionary
(0003) This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
(0004) CallingType.GetDescription returns a description of this method.
(0005) Request this object like:
(0006) 	var HelpA = Helper.Run("Help", null) as string;
(0007) 	var HelpB = Helper.ReturnDelegate("Help", null) as string;
(0008) 	var HelpDescription = Helper.GetDescription("Help", null) as string;
(0009) 
(0010) Signature:
(0011) 	 System.Func`2[System.Collections.Generic.Dictionary`2[System.String,System.Func`2[System.ValueTuple`3[System.Nullable`1[System.Boolean],System.String,System.Collections.Generic.List`1[System.Object]],System.Object]],System.String]
(0012) 
(0013) 
(0014) METHOD: FunctionID
(0015) This helper returns the function id of your function.
(0016) This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
(0017) CallingType.GetDescription returns a description of this method.
(0018) Request this method like:
(0019) 	var FunctionID            = Helper.Run("FunctionID", this) as string;
(0020) 	var GetFunctionIDObject   = Helper.ReturnDelegate("FunctionID", null) as Func<object, string>;
(0021) 	var FunctionIDDescription = Helper.GetDescription("FunctionID", null) as string;
(0022) 
(0023) Signature:
(0024) 	 System.Func`2[System.Object,System.String]
(0025) 
(0026) 
(0027) METHOD: Serialize
(0028) This helper returns a Newtonsoft Json Serializer helper.
(0029) This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
(0030) CallingType.GetDescription returns a description of this method.
(0031) Request this method like:
(0032) 	var result = Helper.Run("Serialize", new object[] { (object)aSerializableObject, (bool)indented }) as string;
(0033) 	var GetSerializeObject   = Helper.ReturnDelegate("Serialize", null) as Func<object, bool, string>;
(0034) 	var SerializeDescription = Helper.GetDescription("Serialize", null) as string;
(0035) 
(0036) Signature:
(0037) 	 System.Func`3[System.Object,System.Boolean,System.String]
(0038) 
(0039) 
(0040) METHOD: InitExceptionsDS
(0041) This helper initializes a DebugDataSet
(0042) This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
(0043) CallingType.GetDescription returns a description of this method.
(0044) Request this method like:
(0045) 	ListErrors = Helper.Run("InitExceptionsDS", (DataSet)inDS) as DataSet;
(0046) 	var GetInitExceptionsDSObject   = Helper.ReturnDelegate("InitExceptionsDS", null) as Func<DataSet, DataSet>;
(0047) 	var InitExceptionsDSDescription = Helper.GetDescription("InitExceptionsDS", null) as string;
(0048) 
(0049) Signature:
(0050) 	 System.Func`2[System.Data.DataSet,System.Data.DataSet]
(0051) 
(0052) 
(0053) OBJECT: Console
(0054) This helper returns the "Console" Object.
(0055) This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
(0056) CallingType.GetDescription returns a description of this method.
(0057) Request this object like:
(0058) This object needs parameters to construct correctly.
(0059) 	var ConsoleA = Helper.Run("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
(0060) 	var ConsoleB = Helper.ReturnDelegate("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
(0061) 	var ConsoleDescription = Helper.GetDescription("Console", null) as string;
(0062) 
(0063) 
(0064) 
(0065) OBJECT: ErrorHelper
(0066) This helper returns the "ErrorHelper" Object.
(0067) This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
(0068) CallingType.GetDescription returns a description of this method.
(0069) Request this object like:
(0070) This object needs parameters to construct correctly.
(0071) 	var ErrorHelperA = Helper.Run("ErrorHelper", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
(0072) 	var ErrorHelperB = Helper.ReturnDelegate("ErrorHelper", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
(0073) 	var ErrorHelperDescription = Helper.GetDescription("ErrorHelper", null) as string;
(0074) 
(0075) 
(0076) 
(0077) OBJECT: Context
(0078) This helper returns the "Context" Object.
(0079) This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
(0080) CallingType.GetDescription returns a description of this method.
(0081) Request this object like:
(0082) THIS OBJECT MUST BE DISPOSED!!!
(0083) 	var ContextA = Helper.Run("Context", "ErpContext") as ErpContext;
(0084) 	var ContextA = Helper.Run("Context", "IceContext") as Ice.IceContext;
(0085) 	var ContextB = Helper.ReturnDelegate("Context", "ErpContext") as ErpContext;
(0086) 	var ContextB = Helper.ReturnDelegate("Context", "IceContext") as Ice.IceContext;
(0087) 	var ContextDescription = Helper.GetDescription("Context", null) as string;
(0088) 
(0089) 
(0090) 
(0091) 
(0092) OBJECT: Console
(0093) This helper returns the "Console" Object.
(0094) This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
(0095) CallingType.GetDescription returns a description of this method.
(0096) Request this object like:
(0097) This object needs parameters to construct correctly.
(0098) 	var ConsoleA = Helper.Run("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
(0099) 	var ConsoleB = Helper.ReturnDelegate("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
(0100) 	var ConsoleDescription = Helper.GetDescription("Console", null) as string;
(0101) 
(0102) 
(0103) 
(0104) Ran from delegate [FunctionID]: TestObjectFactoryFullTemplate
(0105) Ran from the Factory [FunctionID]: TestObjectFactoryFullTemplate
(0106) Hello World!
(0107) Hello World!
(0108) {
(0109)   "Example": "Yep",
(0110)   "AnotherField": 7
(0111) }
(0112) {
(0113)   "$id": "1",
(0114)   "Company": "000000",
(0115)   "ABCCode1": "A",
(0116)   "CountFreq": 30,
(0117)   "ExcludeFromCC": false,
(0118)   "StockValPcnt": 0.0,
(0119)   "PcntTolerance": 0.0,
(0120)   "CalcPcnt": false,
(0121)   "CalcQty": false,
(0122)   "CalcValue": false,
(0123)   "QtyTolerance": 0.0,
(0124)   "ValueTolerance": 0.0,
(0125)   "ShipToCustNum": 0,
(0126)   "SysRevID": "AAAAAAi6GeQ=",
(0127)   "SysRowID": "acbcb805-9d15-fca7-e311-33e0dbc8c227",
(0128)   "EntityKey": {
(0129)     "$id": "2",
(0130)     "EntitySetName": "ABCCode",
(0131)     "EntityContainerName": "ErpContext",
(0132)     "EntityKeyValues": [
(0133)       {
(0134)         "Key": "SysRowID",
(0135)         "Value": "acbcb805-9d15-fca7-e311-33e0dbc8c227"
(0136)       }
(0137)     ]
(0138)   }
(0139) }
(0140) Thus endeth the demo. ;)
--------------------------------------------

MSG + META------------------------------
HELP: Help
This returns help for all the objects in this Helper Dictionary
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
	var HelpA = Helper.Run("Help", null) as string;
	var HelpB = Helper.ReturnDelegate("Help", null) as string;
	var HelpDescription = Helper.GetDescription("Help", null) as string;

Signature:
	 System.Func`2[System.Collections.Generic.Dictionary`2[System.String,System.Func`2[System.ValueTuple`3[System.Nullable`1[System.Boolean],System.String,System.Collections.Generic.List`1[System.Object]],System.Object]],System.String]


METHOD: FunctionID
This helper returns the function id of your function.
This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
CallingType.GetDescription returns a description of this method.
Request this method like:
	var FunctionID            = Helper.Run("FunctionID", this) as string;
	var GetFunctionIDObject   = Helper.ReturnDelegate("FunctionID", null) as Func<object, string>;
	var FunctionIDDescription = Helper.GetDescription("FunctionID", null) as string;

Signature:
	 System.Func`2[System.Object,System.String]


METHOD: Serialize
This helper returns a Newtonsoft Json Serializer helper.
This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
CallingType.GetDescription returns a description of this method.
Request this method like:
	var result = Helper.Run("Serialize", new object[] { (object)aSerializableObject, (bool)indented }) as string;
	var GetSerializeObject   = Helper.ReturnDelegate("Serialize", null) as Func<object, bool, string>;
	var SerializeDescription = Helper.GetDescription("Serialize", null) as string;

Signature:
	 System.Func`3[System.Object,System.Boolean,System.String]


METHOD: InitExceptionsDS
This helper initializes a DebugDataSet
This is a method, CallingType.RunMethod runs the method, CallingType.ReturnDelegate return the delegate.
CallingType.GetDescription returns a description of this method.
Request this method like:
	ListErrors = Helper.Run("InitExceptionsDS", (DataSet)inDS) as DataSet;
	var GetInitExceptionsDSObject   = Helper.ReturnDelegate("InitExceptionsDS", null) as Func<DataSet, DataSet>;
	var InitExceptionsDSDescription = Helper.GetDescription("InitExceptionsDS", null) as string;

Signature:
	 System.Func`2[System.Data.DataSet,System.Data.DataSet]


OBJECT: Console
This helper returns the "Console" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
This object needs parameters to construct correctly.
	var ConsoleA = Helper.Run("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleB = Helper.ReturnDelegate("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleDescription = Helper.GetDescription("Console", null) as string;



OBJECT: ErrorHelper
This helper returns the "ErrorHelper" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
This object needs parameters to construct correctly.
	var ErrorHelperA = Helper.Run("ErrorHelper", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ErrorHelperB = Helper.ReturnDelegate("ErrorHelper", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ErrorHelperDescription = Helper.GetDescription("ErrorHelper", null) as string;



OBJECT: Context
This helper returns the "Context" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
THIS OBJECT MUST BE DISPOSED!!!
	var ContextA = Helper.Run("Context", "ErpContext") as ErpContext;
	var ContextA = Helper.Run("Context", "IceContext") as Ice.IceContext;
	var ContextB = Helper.ReturnDelegate("Context", "ErpContext") as ErpContext;
	var ContextB = Helper.ReturnDelegate("Context", "IceContext") as Ice.IceContext;
	var ContextDescription = Helper.GetDescription("Context", null) as string;





------------------------------MSG + META

MSG + META------------------------------
OBJECT: Console
This helper returns the "Console" Object.
This is an object, CallingType.RunMethod & CallingType.ReturnDelegate return the object.
CallingType.GetDescription returns a description of this method.
Request this object like:
This object needs parameters to construct correctly.
	var ConsoleA = Helper.Run("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleB = Helper.ReturnDelegate("Console", new object[] { (DataSet)DebugDataSet, (string)Source }) as dynamic;
	var ConsoleDescription = Helper.GetDescription("Console", null) as string;




------------------------------MSG + META

MSG + META------------------------------
Ran from delegate [FunctionID]: TestObjectFactoryFullTemplate

------------------------------MSG + META

MSG + META------------------------------
Ran from the Factory [FunctionID]: TestObjectFactoryFullTemplate

------------------------------MSG + META

MSG + META------------------------------
Hello 
------------------------------MSG + META

MSG + META------------------------------
World!

------------------------------MSG + META

MSG + META------------------------------
Hello 
"ABC"
------------------------------MSG + META

MSG + META------------------------------
World!

"DEF"
------------------------------MSG + META

MSG + META------------------------------
{
  "Example": "Yep",
  "AnotherField": 7
}

------------------------------MSG + META

MSG + META------------------------------
{
  "$id": "1",
  "Company": "000000",
  "ABCCode1": "A",
  "CountFreq": 30,
  "ExcludeFromCC": false,
  "StockValPcnt": 0.0,
  "PcntTolerance": 0.0,
  "CalcPcnt": false,
  "CalcQty": false,
  "CalcValue": false,
  "QtyTolerance": 0.0,
  "ValueTolerance": 0.0,
  "ShipToCustNum": 0,
  "SysRevID": "AAAAAAi6GeQ=",
  "SysRowID": "acbcb805-9d15-fca7-e311-33e0dbc8c227",
  "EntityKey": {
    "$id": "2",
    "EntitySetName": "ABCCode",
    "EntityContainerName": "ErpContext",
    "EntityKeyValues": [
      {
        "Key": "SysRowID",
        "Value": "acbcb805-9d15-fca7-e311-33e0dbc8c227"
      }
    ]
  }
}

------------------------------MSG + META

MSG + META------------------------------
Thus endeth the demo. ;)

------------------------------MSG + META
ERRORHELPER##############################################ERRORHELPER
[
  {
    "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
    "Exception": {
      "ClassName": "Ice.BLException",
      "Message": "Dang!",
      "Data": null,
      "InnerException": null,
      "HelpURL": null,
      "StackTraceString": null,
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "ExceptionMethod": null,
      "HResult": -2146232832,
      "Source": null,
      "WatsonBuckets": null
    },
    "Meta": null
  },
  {
    "Source": "Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate",
    "Exception": {
      "ClassName": "Ice.BLException",
      "Message": "Ooops!",
      "Data": null,
      "InnerException": null,
      "HelpURL": null,
      "StackTraceString": null,
      "RemoteStackTraceString": null,
      "RemoteStackIndex": 0,
      "ExceptionMethod": null,
      "HResult": -2146232832,
      "Source": null,
      "WatsonBuckets": null
    },
    "Meta": "Oh no!"
  }
]
ERRORHELPERERRORS##################################ERRORHELPERERRORS
Source: Efx.ObjectFactoryDemo.TestObjectFactoryFullTemplate -> 
Woot!
Yo Dawg!
--------------------------------------------

MSG + META------------------------------
Woot!

------------------------------MSG + META

MSG + META------------------------------
Yo Dawg!

"Yumm"
------------------------------MSG + META
7 Likes

Cookie really wanted some conversation lol.

1 Like

The Office Television GIF by hero0fwar

1 Like