Exemplo n.º 1
0
 public GResourceItem(string gName, string gValue, GComment <TValue>?gComment = default)
 {
     GName    = gName ?? throw new ArgumentNullException(nameof(gName));
     GValue   = gValue ?? throw new ArgumentNullException(nameof(gValue));
     GComment = gComment;
     Id       = new GResourceItemId <TValue>();
 }
Exemplo n.º 2
0
        //public GClass(string gName, string? gVisibility, string? gInheritance, string[]? gImplements, GPropertyGroup[]? gPropertyGroups, GConstructor[]? gConstructors, GMethod[]? gMethods) {
        public GClass(string gName = default, string gVisibility = default, string gAccessModifier = default, string gInheritance = default,
                      IList <string> gImplements = default,
                      IList <string> gDisposesOf = default,
                      IDictionary <IGPropertyId <TValue>, IGProperty <TValue> > gPropertys = default,
                      IDictionary <IGPropertyGroupId <TValue>, IGPropertyGroup <TValue> > gPropertyGroups = default,
                      IDictionary <IGMethodId <TValue>, IGMethod <TValue> > gMethods = default,
                      IDictionary <IGMethodGroupId <TValue>, IGMethodGroup <TValue> > gMethodGroups          = default,
                      IDictionary <IGStaticVariableId <TValue>, IGStaticVariable <TValue> > gStaticVariables = default,
                      IDictionary <IGStaticVariableGroupId <TValue>, IGStaticVariableGroup <TValue> > gStaticVariableGroups = default,
                      IDictionary <IGConstStringId <TValue>, IGConstString <TValue> > gConstStrings = default,
                      IDictionary <IGConstStringGroupId <TValue>, IGConstStringGroup <TValue> > gConstStringGroups = default,
                      IDictionary <IGDelegateId <TValue>, IGDelegate <TValue> > gDelegates = default,
                      IDictionary <IGDelegateGroupId <TValue>, IGDelegateGroup <TValue> > gDelegateGroups          = default,
                      IDictionary <IGEnumerationId <TValue>, IGEnumeration <TValue> > gEnumerations                = default,
                      IDictionary <IGEnumerationGroupId <TValue>, IGEnumerationGroup <TValue> > gEnumerationGroups = default,
                      //IDictionary<IGExceptionId<TValue>, IGException<TValue>> gExceptions = default,
                      //IDictionary<IGExceptionGroupId<TValue>, IGExceptionGroup<TValue>> gExceptionGroups = default,
                      //IDictionary<IGEventId<TValue>, IGEvent<TValue>> gEvents = default,
                      //IDictionary<IGEventGroupId<TValue>, IGEventGroup<TValue>> gEventGroups = default,
                      GComment gComment = default,
                      IEnumerable <GStateConfiguration> gStateConfigurations = default
                      )
        {
            GName                 = gName == default ? "" : gName;
            GVisibility           = gVisibility == default ? "" : gVisibility;;
            GAccessModifier       = gAccessModifier == default ? "" : gAccessModifier;
            GInheritance          = gInheritance == default ? "" : gInheritance;;
            GImplements           = gImplements == default ? new List <string>() : gImplements;
            GDisposesOf           = gDisposesOf == default ? new List <string>() : gDisposesOf;
            GPropertyGroups       = gPropertyGroups == default ? new Dictionary <IGPropertyGroupId <TValue>, IGPropertyGroup <TValue> >() : gPropertyGroups;
            GPropertys            = gPropertys == default ? new Dictionary <IGPropertyId <TValue>, IGProperty <TValue> >() : gPropertys;
            GMethods              = gMethods == default ? new Dictionary <IGMethodId <TValue>, IGMethod <TValue> >() : gMethods;
            GMethodGroups         = gMethodGroups == default ? new Dictionary <IGMethodGroupId <TValue>, IGMethodGroup <TValue> >() : gMethodGroups;
            GStaticVariables      = gStaticVariables == default ? new Dictionary <IGStaticVariableId <TValue>, IGStaticVariable <TValue> >() : gMethodGroups;
            GStaticVariableGroups = gStaticVariableGroups == default ? new Dictionary <IGStaticVariableGroupId <TValue>, IGStaticVariableGroup <TValue> >() : gStaticVariableGroups;
            GConstStrings         = gConstStrings == default ? new Dictionary <IGConstStringId <TValue>, IGConstString <TValue> >() : gConstStrings;
            GConstStringGroups    = gConstStringGroups == default ? new Dictionary <IGConstStringGroupId <TValue>, IGConstStringGroup <TValue> >() : gConstStringGroups;
            GDelegates            = gDelegates == default ? new Dictionary <IGDelegateId <TValue>, IGDelegate <TValue> >() : gDelegates;
            GDelegateGroups       = gDelegateGroups == default ? new Dictionary <IGDelegateGroupId <TValue>, IGDelegateGroup <TValue> >() : gDelegateGroups;
            GEnumerations         = gEnumerations == default ? new Dictionary <IGEnumerationId <TValue>, IGEnumeration <TValue> >() : gEnumerations;
            GEnumerationGroups    = gEnumerationGroups == default ? new Dictionary <IGEnumerationGroupId <TValue>, IGEnumerationGroup <TValue> >() : gEnumerationGroups;
            //GExceptions = gExceptions  == default? new Dictionary<IGExceptionId<TValue>, IGException<TValue>>() : gExceptions;
            //GExceptionGroups = gExceptionGroups  == default? new Dictionary<IGExceptionGroupId<TValue>, IGExceptionGroup<TValue>>() : gExceptionGroups;
            //GEvents = gEvents  == default? new Dictionary<IGEventId<TValue>, IGEvent<TValue>>() : gEvents;
            //GEventGroups = gEventGroups  == default? new Dictionary<IGEventGroupId<TValue>, IGEventGroup<TValue>>() : gEventGroups;
            GComment             = gComment == default ? new GComment() : gComment;
            GStateConfigurations = new List <IGStateConfiguration>();
            if (gStateConfigurations != default)
            {
                foreach (var sc in gStateConfigurations)
                {
                    GStateConfigurations.Add(sc);
                }
            }

            Id = new GClassId <TValue>();
        }
        public GAttributeGroup(string gName      = "", Dictionary <IGAttributeId <TValue>, IGAttribute <TValue> > gAttributes = default,
                               GComment gComment = default
                               )
        {
            GName       = gName;
            GAttributes = gAttributes == default ? new Dictionary <IGAttributeId <TValue>, IGAttribute <TValue> >() : gAttributes;
            GComment    = gComment == default ? new GComment() : gComment;

            Id = new GAttributeGroupId <TValue>();
        }
Exemplo n.º 4
0
        /*******************************************************************************/
        /*******************************************************************************/

        public static (GBody, GComment) MCreateProcessInputMethodForTopLevelBackgroundGHS()
        {
            GBody gBody = new GBody(gStatements: new List <string>()
            {
                "#region TBD", " #endregion",
            });
            GComment gComment = new GComment(new List <string>()
            {
                "///  Used to process inputStrings from the ConsoleMonitorPattern"
            });

            return(gBody, gComment);
        }
        public static (IGBody, IGComment) MCreateProcessInputMethodForFileSystemToObjectGraphGHS()
        {
            GBody gBody = new GBody(gStatements: new List <string>()
            {
                "#region TBD", " #endregion",
            });
            GComment gComment = new GComment(new List <string>()
            {
                "///  Used to process inputStrings from the ConsoleMonitorPattern"
            });

            return(gBody, gComment);
        }
 public GEnumerationMember(string gName = "", int?gValue = default,
                           IDictionary <IGAttributeId <TValue>, IGAttribute <TValue> > gAttributes = default,
                           IDictionary <IGAttributeGroupId <TValue>, IGAttributeGroup <TValue> > gAttributeGroups = default,
                           GComment gComment = default
                           )
 {
     GName            = gName;
     GValue           = gValue;
     GAttributes      = gAttributes == default ? new Dictionary <IGAttributeId <TValue>, IGAttribute <TValue> >() : gAttributes;
     GAttributeGroups = gAttributeGroups == default ? new Dictionary <IGAttributeGroupId <TValue>, IGAttributeGroup <TValue> >() : gAttributeGroups;
     GComment         = gComment == default ? new GComment() : gComment;
     Id = new GEnumerationMemberId <TValue>();
 }
        public static IGMethod MCreateExecuteAsyncMethod(string gAccessModifier = "")
        {
            var gMethodDeclaration = new GMethodDeclaration(gName: "ExecuteAsync", gType: "Task",
                                                            gVisibility: "protected", gAccessModifier: gAccessModifier, isConstructor: false,
                                                            gArguments: new Dictionary <IPhilote <IGArgument>, IGArgument>());

            foreach (var kvp in new Dictionary <string, string>()
            {
                { "genericHostsCancellationToken", "CancellationTokenFromCaller " }
            })
            {
                var gMethodArgument = new GArgument(kvp.Key, kvp.Value);
                gMethodDeclaration.GArguments[gMethodArgument.Philote] = gMethodArgument;
            }

            var gBody = new GBody(gStatements: new List <string>()
            {
                "#region Create linkedCancellationSource and linkedCancellationToken",
                "  //// Combine the cancellation tokens,so that either can stop this HostedService",
                "  //linkedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(internalCancellationToken, externalCancellationToken);",
                "  //var linkedCancellationToken = linkedCancellationTokenSource.Token;",
                "#endregion",
                "#region Register actions with the CancellationTokenFromCaller (s)",
                "  //externalCancellationToken.Register(() => Logger.LogDebug(DebugLocalizer[\"{0} {1} externalCancellationToken has signalled stopping.\"], \"ConsoleMonitorBackgroundService\", \"externalCancellationToken\"));",
                "  //internalCancellationToken.Register(() => Logger.LogDebug(DebugLocalizer[\"{0} {1} internalCancellationToken has signalled stopping.\"], \"ConsoleMonitorBackgroundService\", \"internalCancellationToken\"));",
                "  //linkedCancellationToken.Register(() => Logger.LogDebug(DebugLocalizer[\"{0} {1} linkedCancellationToken has signalled stopping.\"], \"ConsoleMonitorBackgroundService\", \"linkedCancellationToken\"));",
                "#endregion",
                "#region Instantiate this service's Data structure",
                "  //DataInitializationInStartAsyncReplacementPattern",
                "#endregion",
                "// Wait for the conjoined cancellation token (or individually if the hosted service does not define its own internal cts)",
                "// WaitHandle.WaitAny(new[] { linkedCancellationToken.WaitHandle });",
                "Logger.LogDebug(DebugLocalizer[\"{0} {1} ConsoleMonitorBackgroundService is stopping due to \"], \"ConsoleMonitorBackgroundService\", \"ExecuteAsync\"); // add third parameter for internal or external",
                "AssemblyUnitNameReplacementPatternBaseData.Dispose();",
            });
            GComment gComment = new GComment(new List <string>()
            {
                "/// <summary>",
                "/// Called by the genericHost to start the Backgroundservice.",
                "/// Sets up data structures",
                "/// </summary>",
                "/// <param name=\"externalCancellationToken\"></param>",
                "/// <returns></returns>",
            });

            return(new GMethod(gMethodDeclaration, gBody, gComment));
        }
        public static IGMethod MCreateStartAsyncMethod(string gAccessModifier = "")
        {
            var gMethodArguments = new Dictionary <IPhilote <IGArgument>, IGArgument>();

            foreach (var o in new List <IGArgument>()
            {
                new GArgument("genericHostsCancellationToken", "CancellationTokenFromCaller"),
            })
            {
                gMethodArguments.Add(o.Philote, o);
            }
            var gMethodDeclaration = new GMethodDeclaration(gName: "StartAsync", gType: "Task",
                                                            gVisibility: "public", gAccessModifier: gAccessModifier, isConstructor: false,
                                                            gArguments: gMethodArguments);

            var gBody = new GBody(gStatements: new List <string>()
            {
                "#region Create linkedCancellationSource and linkedCancellationToken",
                "  //// Combine the cancellation tokens,so that either can stop this HostedService",
                "  //linkedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(internalCancellationToken, externalCancellationToken);",
                "  //GenericHostsCancellationToken = genericHostsCancellationToken;",
                "#endregion",
                "#region Register actions with the CancellationTokenFromCaller (s)",
                "  //GenericHostsCancellationToken.Register(() => Logger.LogDebug(DebugLocalizer[\"{0} {1} GenericHostsCancellationToken has signalled stopping.\"], \"FileSystemToObjectGraphService\", \"StartAsync\"));",
                "  //internalCancellationToken.Register(() => Logger.LogDebug(DebugLocalizer[\"{0} {1} internalCancellationToken has signalled stopping.\"], \"FileSystemToObjectGraphService\", \"internalCancellationToken\"));",
                "  //linkedCancellationToken.Register(() => Logger.LogDebug(DebugLocalizer[\"{0} {1} GenericHostsCancellationToken has signalled stopping.\"], \"FileSystemToObjectGraphService\",\"GenericHostsCancellationToken\"));",
                "#endregion",
                "#region Register local event handlers with the IHostApplicationLifetime's events",
                "  // Register the methods defined in this class with the three CancellationTokenFromCaller properties found on the IHostApplicationLifetime instance passed to this class in it's .ctor",
                "  HostApplicationLifetime.ApplicationStarted.Register(OnStarted);",
                "  HostApplicationLifetime.ApplicationStopping.Register(OnStopping);",
                "  HostApplicationLifetime.ApplicationStopped.Register(OnStopped);",
                "#endregion",
                // "DataInitializationInStartAsyncReplacementPattern",
                "//return Task.CompletedTask;"
            });

            GComment gComment = new GComment(new List <string>()
            {
            });
            GMethod newgMethod = new GMethod(gMethodDeclaration, gBody, gComment);

            return(newgMethod);
        }
Exemplo n.º 9
0
 public GEnumeration(string gName    = default, string gUnderlyingBaseType = default, string gVisibility = default, string gInheritance = default,
                     bool isBitFlags = default,
                     Dictionary <IGEnumerationMemberId <TValue>, IGEnumerationMember <TValue> > gEnumerationMembers = default,
                     Dictionary <IGAttributeId <TValue>, IGAttribute <TValue> > gAttributes = default,
                     Dictionary <IGAttributeGroupId <TValue>, IGAttributeGroup <TValue> > gAttributeGroups = default,
                     GComment gComment = default
                     )
 {
     GName = gName == default ? "" : gName;
     GUnderlyingBaseType = gUnderlyingBaseType == default ? "" : gUnderlyingBaseType;
     GVisibility         = gVisibility == default ? "" : gVisibility;
     GInheritance        = gInheritance == default ? "" : gInheritance;;
     IsBitFlags          = isBitFlags == default ? false : (bool)isBitFlags;
     GEnumerationMembers = gEnumerationMembers == default ? new Dictionary <IGEnumerationMemberId <TValue>, IGEnumerationMember <TValue> >() : gEnumerationMembers;
     GAttributes         = gAttributes == default ? new Dictionary <IGAttributeId <TValue>, IGAttribute <TValue> >() : gAttributes;
     GAttributeGroups    = gAttributeGroups == default ? new Dictionary <IGAttributeGroupId <TValue>, IGAttributeGroup <TValue> >() : gAttributeGroups;
     GComment            = gComment == default ? new GComment() : gComment;
     Id = new GEnumerationId <TValue>();
 }
        public static IGMethod MCreateConvertFileSystemToObjectGraphAsync(IGClass gClass)
        {
            var gMethodArguments = new Dictionary <IPhilote <IGArgument>, IGArgument>();

            foreach (var o in new List <IGArgument>()
            {
                new GArgument("rootString", "string"),
                new GArgument("asyncFileReadBlockSize", "int"),
                new GArgument("enableHash", "bool"),
                new GArgument("convertFileSystemToGraphProgress", "ConvertFileSystemToGraphProgress"),
                new GArgument("Persistence", "Persistence<IInsertResultsAbstract>"),
                new GArgument("PickAndSave", "PickAndSave<IInsertResultsAbstract>"),
                new GArgument("cancellationToken", "CancellationTokenFromCaller?"),
            })
            {
                gMethodArguments.Add(o.Philote, o);
            }
            var gMethodDeclaration = new GMethodDeclaration(gName: "ConvertFileSystemToObjectGraphAsync",
                                                            gType: "Task<ConvertFileSystemToGraphResult>",
                                                            gVisibility: "public", gAccessModifier: "async", isConstructor: false,
                                                            gArguments: gMethodArguments);
            var gBody = new GBody(new List <string>()
            {
                "cancellationToken?.ThrowIfCancellationRequested();",
                "await Task.Delay(10000);",
                "return new ConvertFileSystemToGraphResult();",
            });
            var gComment = new GComment(new List <string>()
            {
                "/// <summary>",
                "/// Convert the contents of a complete FileSystem (or portion thereof) to an Graph representation",
                "/// </summary>",
                "/// <param name=\"\"></param>",
                "/// <param name=\"\"></param>",
                "/// <param name=\"cancellationToken\"></param>",
                "/// <returns>Task<ConvertFileSystemToGraphResult></returns>",
            });

            return(new GMethod(gMethodDeclaration, gBody, gComment));
        }
        public static IGMethod MCreateStopAsyncMethod(string gAccessModifier = "")
        {
            var gMethodDeclaration = new GMethodDeclaration(gName: "StopAsync", gType: "Task",
                                                            gVisibility: "public", gAccessModifier: gAccessModifier, isConstructor: false,
                                                            gArguments: new Dictionary <IPhilote <IGArgument>, IGArgument>());

            foreach (var kvp in new Dictionary <string, string>()
            {
                { "genericHostsCancellationToken", "CancellationTokenFromCaller " }
            })
            {
                var gMethodArgument = new GArgument(kvp.Key, kvp.Value);
                gMethodDeclaration.GArguments[gMethodArgument.Philote] = gMethodArgument;
            }

            var gBody = new GBody(gStatements: new List <string>()
            {
                "// StopAsync issued in both IHostedService and IHostLifetime interfaces",
                "// This IS called when the user closes the ConsoleWindow with the windows top right pane \"x (close)\" icon",
                "// This IS called when the user hits ctrl-C in the console window",
                "//  After Ctrl-C and after this method exits, the Debugger",
                "//   shows an unhandled Exception: System.OperationCanceledException: 'The operation was canceled.'",
                "// See also discussion of Stop async in the following attributions.",
                "// Attribution to  https://stackoverflow.com/questions/51044781/graceful-shutdown-with-generic-host-in-net-core-2-1",
                "// Attribution to https://stackoverflow.com/questions/52915015/how-to-apply-hostoptions-shutdowntimeout-when-configuring-net-core-generic-host for OperationCanceledException notes",
                //Not sure if this is the right place for the dispose
                "// DataDisposalInStopAsyncReplacementPattern",
                "//InternalCancellationTokenSource.Cancel();",
                "// Defer completion promise, until our application has reported it is done.",
                "// return TaskCompletionSource.Task;",
                "//Stop(); // would call the servicebase stop if this was a generic hosted service ??",
                "//return Task.CompletedTask;"
            });
            GComment gComment = new GComment(new List <string>()
            {
            });

            return(new GMethod(gMethodDeclaration, gBody, gComment));
        }
 public GCommentWithIntTestData(GComment <int> instanceTestData, string serializedTestData)
 {
     InstanceTestData   = instanceTestData;
     SerializedTestData = serializedTestData ?? throw new ArgumentNullException(nameof(serializedTestData));
 }