MPropertyGroupAndConstructorDeclarationAndInitializationForInjectedPropertyInFileSystemToObjectGraphBaseAssembly(
            IGClass gClass,
            IGMethod gConstructor)
        {
            var gPropertyGroup = new GPropertyGroup("Injected Propertys specific to the FileSystemToObjectGraph");

            gClass.AddPropertyGroups(gPropertyGroup);
            // foreach (var o in new List<string>() { "ConsoleMonitor" }) {
            // gClass.AddTConstructorAutoPropertyGroup(gConstructor.Philote, o, gPropertyGroupId: gPropertyGroup.Philote);
            // }
        }
        /*******************************************************************************/
        /*******************************************************************************/

        public static void MPropertyGroupForFileSystemToObjectGraphBaseAssembly(IGClass gClass)
        {
            var gPropertyGroup = new GPropertyGroup("Propertys specific to the FileSystemToObjectGraph");

            foreach (var o in new List <IGProperty>()
            {
                // new GProperty("?", gType: "IDisposable",gAccessors: "{ get; set; }", gVisibility: "protected internal"),
                // new GProperty("Choices", gType: "Dictionary<String,IEnumerable<string>>", gAccessors: "{ get; }", gVisibility: "protected internal"),
            })
            {
                gPropertyGroup.GPropertys.Add(o.Philote, o);
            }
            gClass.AddPropertyGroups(gPropertyGroup);
        }
        public static void MStateMachineConstructor(
            IGCompilationUnit gCompilationUnit = default, IGNamespace gNamespace = default, IGClass gClass = default,
            IGMethod gConstructor = default, IList <string> initialDiGraphList   = default)
        {
            #region UsingGroup
            var gUsingGroup = MUsingGroupForStatelessStateMachine();
            gCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote, gUsingGroup);
            #endregion
            #region Delegates
            var gDelegates = new Dictionary <IPhilote <IGDelegate>, IGDelegate>();
            var UnhandledTriggerDelegateArguments = new Dictionary <IPhilote <IGArgument>, IGArgument>();
            foreach (var o in new List <IGArgument>()
            {
                new GArgument("state", "State"), new GArgument("trigger", "Trigger"),
            })
            {
                UnhandledTriggerDelegateArguments.Add(o.Philote, o);
            }
            foreach (var o in new List <IGDelegate>()
            {
                new GDelegate(new GDelegateDeclaration("UnHandledTriggerDelegate", gType: "void", gVisibility: "public",
                                                       gArguments: UnhandledTriggerDelegateArguments)),
                new GDelegate(new GDelegateDeclaration(gName: "EntryExitDelegate", gType: "void", gVisibility: "public")),
                new GDelegate(new GDelegateDeclaration(gName: "GuardClauseDelegate", gType: "void", gVisibility: "public")),
            })
            {
                gDelegates.Add(o.Philote, o);
            }
            gNamespace.AddDelegate(gDelegates);
            #endregion

            #region StateMachine GPropertyGroup and its properties
            var gPropertyGroup = new GPropertyGroup(gName: "StateMachine Properties");
            // StateMachine Property
            var gProperty = new GProperty(gName: "StateMachine", gType: "StateMachine<State,Trigger>", gAccessors: "{get;}");
            gPropertyGroup.GPropertys.Add(gProperty.Philote, gProperty);
            // StateConfigurations property
            //gProperty = new GProperty(gName: "StateConfigurations", gType: "List<StateConfiguration>", gAccessors: "{get;}");
            //gPropertyGroup.GPropertys.Add(gProperty.Philote, gProperty);
            // Add the PropertyGroup to the gClass
            gClass.GPropertyGroups.Add(gPropertyGroup.Philote, gPropertyGroup);
            #endregion

            // Add initialization statements for the properties in the the StateMachine Properties Property Group to the constructor body
            gConstructor.GBody.GStatements.AddRange(new List <string>()
            {
                "StateMachine = new StateMachine<State, Trigger>(State.WaitingForInitialization);",
                "//StateConfigurations = stateConfigurations;",
                "ConfigureStateMachine();",
            });

            //// StateConfiguration Class for the provided namespace
            //// Define the properties for the StateConfiguration class
            //// ToDo: Move this type into ATAP.Utilities.StateMachine
            //var gPropertys = new Dictionary<IPhilote<IGProperty>, GIProperty>();
            //gProperty = new GProperty("State", "State", gAccessors: "{get;}", gVisibility: "public");
            //gPropertys.Add(gProperty.Philote, gProperty);
            //gProperty = new GProperty("Trigger", "Trigger", gAccessors: "{get;}", gVisibility: "public");
            //gPropertys.Add(gProperty.Philote, gProperty);
            //gProperty = new GProperty("NextState", "State", gAccessors: "{get;}", gVisibility: "public");
            //gPropertys.Add(gProperty.Philote, gProperty);
            //var stateConfigurationClass = new GClass(gName: "StateConfiguration", gPropertys: gPropertys);

            //var gMethodArguments = new Dictionary<IPhilote<IGArgument>, IGArgument>();
            //foreach (var o in new List<IGArgument>() {
            //  new GArgument("state", "State"), new GArgument("trigger", "Trigger"), new GArgument("nextState", "State"),
            //}) {
            //  gMethodArguments.Add(o.Philote, o);
            //}

            //gConstructor = new GMethod(
            //  new GMethodDeclaration(gName: "StateConfiguration", isConstructor: true, gType: "IDisposable",
            //    gVisibility: "public", gAccessModifier: "",
            //    gArguments: gMethodArguments),
            //  gBody:
            //  new GBody(new List<string>() {"State=state;", "Trigger=trigger;", "NextState=nextState;",}),
            //  new GComment(new List<string>() {
            //    "/// <summary>", "/// builds one state instance", "/// </summary>", "/// <returns></returns>",
            //  }));
            //stateConfigurationClass.GMethods.Add(gConstructor.Philote, gConstructor);
            //gNamespace.GClasss.Add(stateConfigurationClass.Philote, stateConfigurationClass);
        }
        public static IGAssemblyGroup MConsoleSinkGHS(string gAssemblyGroupName,
                                                      string subDirectoryForGeneratedFiles    = default, string baseNamespaceName = default, bool hasInterfaces = true,
                                                      GPatternReplacement gPatternReplacement = default)
        {
            GPatternReplacement _gPatternReplacement =
                gPatternReplacement == default ? new GPatternReplacement() : gPatternReplacement;
            var mCreateAssemblyGroupResult = MAssemblyGroupGHHSConstructor(gAssemblyGroupName, subDirectoryForGeneratedFiles,
                                                                           baseNamespaceName, hasInterfaces, _gPatternReplacement);

            #region Initial StateMachine Configuration
            mCreateAssemblyGroupResult.GPrimaryConstructorBase.GStateConfiguration.GDOTGraphStatements.Add(
                @"
          WaitingForInitialization -> WaitingForRequestToWriteSomething [label = ""InitializationCompleteReceived""]
          WaitingForRequestToWriteSomething -> WaitingForWriteToComplete [label = ""WriteStarted""]
          WaitingForWriteToComplete -> WaitingForRequestToWriteSomething [label = ""WriteFinished""]
          WaitingForWriteToComplete -> WaitingForRequestToWriteSomething [label = ""CancellationTokenActivated""]
          WaitingForRequestToWriteSomething -> ServiceFaulted [label = ""ExceptionCaught""]
          WaitingForWriteToComplete ->ServiceFaulted [label = ""ExceptionCaught""]
          WaitingForRequestToWriteSomething ->ShutdownStarted [label = ""CancellationTokenActivated""]
          WaitingForRequestToWriteSomething ->ShutdownStarted [label = ""StopAsyncActivated""]
          WaitingForWriteToComplete ->ShutdownStarted [label = ""StopAsyncActivated""]
          ShutdownStarted ->ShutdownComplete [label = ""ShutdownCompleted""]
        "
                );
            #endregion

            var s1 = new List <string>()
            {
                @"StateMachine.Configure(State.WaitingForInitialization)",
                //$"  .OnEntry(() => {{ if (OnWaitingForInitializationEntry!= null) OnWaitingForInitializationEntry(); }})",
                //$"  .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})",
                $"  .Permit(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething)",
                $";",

                @"StateMachine.Configure(State.WaitingForRequestToWriteSomething)",
                //$"  .OnEntry(() => {{ if (OnWaitingForInitializationEntry!= null) OnWaitingForInitializationEntry(); }})",
                // $"  .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})",
                $"  .Permit(Trigger.WriteStarted, State.WaitingForWriteToComplete)",
                $"  .Permit(Trigger.StopAsyncActivated, State.ShutdownStarted)",
                // $"  .PermitReentryIf(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething, () => {{ if (GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived!= null) return GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived(); return true; }})",
                $";",

                @"StateMachine.Configure(State.WaitingForWriteToComplete)",
                $"  .OnEntry((string mesg) => {{Console.Write(mesg);}})",
                // $"  .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})",
                $"  .Permit(Trigger.WriteFinished, State.WaitingForRequestToWriteSomething)",
                $"  .Permit(Trigger.StopAsyncActivated, State.ShutdownStarted)",
                // $"  .PermitReentryIf(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething, () => {{ if (GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived!= null) return GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived(); return true; }})",
                $";",

                @"StateMachine.Configure(State.ShutdownStarted)",
                //$"  .OnEntry(() => {{ if (OnWaitingForInitializationEntry!= null) OnWaitingForInitializationEntry(); }})",
                // $"  .OnExit(() => {{ if (OnWaitingForInitializationExit!= null) OnWaitingForInitializationExit(); }})",
                $"  .Permit(Trigger.ShutdownCompleted, State.ShutdownComplete)",
                // $"  .PermitReentryIf(Trigger.InitializationCompleteReceived, State.WaitingForRequestToWriteSomething, () => {{ if (GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived!= null) return GuardClauseFroWaitingForInitializationToWaitingForRequestToWriteSomethingUsingTriggerInitializationCompleteReceived(); return true; }})",
                $";",
                @"StateMachine.Configure(State.ShutdownComplete);",
            };
            #region Add UsingGroups to the Titular Derived and Titular Base CompilationUnits
            #region Add UsingGroups common to both the Titular Derived and Titular Base CompilationUnits
            #endregion
            #region Add UsingGroups specific to the Titular Base CompilationUnit
            #endregion
            #endregion
            #region Injected PropertyGroup For ConsoleSinkAndConsoleSource
            #endregion
            #region Additional Properties needed by the Base  class
            var lclPropertyGroup = new GPropertyGroup($"Private Properties part of {mCreateAssemblyGroupResult.GClassBase.GName}");
            var mesgProperty     = new GProperty(gName: "Mesg", gType: "string", gVisibility: "private");
            lclPropertyGroup.GPropertys.Add(mesgProperty.Philote, mesgProperty);
            mCreateAssemblyGroupResult.GClassBase.GPropertyGroups.Add(lclPropertyGroup.Philote, lclPropertyGroup);
            #endregion
            #region Add the MethodGroup containing new methods provided by this library to the Titular Base CompilationUnit
            var gMethodGroup =
                new GMethodGroup(
                    gName:
                    $"MethodGroup specific to {mCreateAssemblyGroupResult.GClassBase.GName}");
            foreach (var gMethod in MCreateWriteMethodInConsoleSink())
            {
                gMethodGroup.GMethods.Add(gMethod.Philote, gMethod);
            }
            mCreateAssemblyGroupResult.GClassBase.AddMethodGroup(gMethodGroup);
            #endregion
            #region Add additional classes provided by this library to the Titular Base CompilationUnit
            #endregion
            #region Add References used by the Titular Derived and Titular Base CompilationUnits to the ProjectUnit
            #region Add References used by both the Titular Derived and Titular Base CompilationUnits
            #endregion
            #region Add References unique to the Titular Base CompilationUnit
            #endregion
            #endregion
            /*******************************************************************************/
            #region Update the Interface Assembly for this service
            #region Add UsingGroups for the Titular Derived Interface and Titular Base Interface
            #region Add UsingGroups common to both the Titular Derived Interface and the Titular Base Interface
            #endregion
            #region Add UsingGroups specific to the Titular Base Interface
            #endregion
            #endregion
            #region Add References for the Titular Interface ProjectUnit
            #region Add References common to both the Titular Derived Interface and Titular Base Interface
            #endregion
            #region Add References unique to the Titular Base Interface CompilationUnit
            #endregion
            #endregion
            #endregion
            #region Finalize the GHHS
            GAssemblyGroupGHHSFinalizer(mCreateAssemblyGroupResult);
            #endregion
            #region Populate the ConfigureStateMachine method
            mCreateAssemblyGroupResult.GClassBase.CombinedMethods()
            .Where(x => x.GDeclaration.GName == "ConfigureStateMachine").First().GBody.GStatements.AddRange(s1);
            // mCreateAssemblyGroupResult.GPrimaryConstructorBase.GBody.GStatements.AddRange(s1);
            #endregion
            return(mCreateAssemblyGroupResult.GAssemblyGroup);
        }
        public static IGAssemblyGroupBasicConstructorResult MAssemblyGroupCommonConstructorForGHHSAndGHBS(string gAssemblyGroupName                = default,
                                                                                                          string subDirectoryForGeneratedFiles     = default, string baseNamespaceName = default, bool hasInterfaces = true,
                                                                                                          IGPatternReplacement gPatternReplacement = default)
        {
            var gAssemblyGroupBasicConstructorResult = MAssemblyGroupBasicConstructor(gAssemblyGroupName,
                                                                                      subDirectoryForGeneratedFiles, baseNamespaceName, hasInterfaces, gPatternReplacement);

            //var GTitularAssemblyUnitName = GAssemblyGroupName;
            //GPatternReplacement _gPatternReplacement =
            //  gPatternReplacement == default ? new GPatternReplacement() : gPatternReplacement;

            //GAssemblyGroup GAssemblyGroup;
            //GAssemblyUnit gAssemblyUnit;
            //GCompilationUnit gCompilationUnit;
            //GUsingGroup gUsingGroup;
            //GNamespace gNamespace;
            //GPatternReplacement gAssemblyGroupPatternReplacement;
            //GPatternReplacement gAssemblyUnitPatternReplacement;

            //#region GReplacementPatternDictionary for AssemblyGroup
            //gAssemblyGroupPatternReplacement = new GPatternReplacement(
            //  gDictionary: new Dictionary<Regex, string>() {
            //    {new Regex("AssemblyGroupNameReplacementPattern"), GAssemblyGroupName}, {
            //      new Regex("SolutionReferencedProjectsBasePathReplacementPattern"),
            //      @"C:/Dropbox/whertzing/GitHub/ATAP.Utilities/"
            //    }, {
            //      new Regex("SolutionReferencedProjectsLocalBasePathReplacementPattern"), @"D:/Temp/GenerateProgramArtifacts/"
            //    },
            //  });
            //// add the argument transform
            //foreach (var kvp in gPatternReplacement.GDictionary) {
            //  gAssemblyGroupPatternReplacement.GDictionary.Add(kvp.Key, kvp.Value);
            //}
            //#endregion
            //GAssemblyGroup = new GAssemblyGroup(GAssemblyGroupName, gPatternReplacement: gAssemblyGroupPatternReplacement);

            //#region Titular AssemblyUnit
            //var gAssemblyUnitName = $"{GAssemblyGroupName}";
            //#region GReplacementPatternDictionary for AssemblyUnit
            //gAssemblyUnitPatternReplacement = new GPatternReplacement(
            //  gDictionary: new Dictionary<Regex, string>() {
            //    {new Regex("AssemblyUnitNameReplacementPattern"), gAssemblyUnitName}
            //  });
            //foreach (var kvp in gAssemblyGroupPatternReplacement.GDictionary) {
            //  gAssemblyUnitPatternReplacement.GDictionary.Add(kvp.Key, kvp.Value);
            //}
            //#endregion
            //gAssemblyUnit = new GAssemblyUnit(gAssemblyUnitName, gRelativePath: gAssemblyUnitName,
            //  gProjectUnit: new GProjectUnit(gAssemblyUnitName, gPatternReplacement: gAssemblyUnitPatternReplacement),
            //  gPatternReplacement: gAssemblyUnitPatternReplacement);
            //#endregion
            //#region Titular Base CompilationUnit
            //var gCompilationUnitName = $"{gAssemblyUnitName}Base";
            //#region GReplacementPatternDictionary for CompilationUnit Base CompilationUnit
            //// ToDo: encapsulate and refactor
            //string tempdatainitialization = @"
            //  /*
            //  #region configurationRoot for this HostedService
            //  // Create the configurationBuilder for this HostedService. This creates an ordered chain of configuration providers. The first providers in the chain have the lowest priority, the last providers in the chain have a higher priority.
            //  // The Environment has been configured by the GenericHost before this point is reached
            //  // InitialStartupDirectory has been set by the GenericHost before this point is reached, and is where the GenericHost program or service was started
            //  // LoadedFromDirectory has been configured by the GenericHost before this point is reached. It is the location where this assembly resides
            //  // ToDo: Implement these two values into the GenericHost configurationRoot somehow, then remove from the constructor signature
            //  // var loadedFromDirectory = hostConfiguration.GetValue<string>(\SomeStringConstantConfigrootKey\ \./\); //ToDo suport dynamic assembly loading form other Startup directories -  Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            //  // var initialStartupDirectory = hostConfiguration.GetValue<string>(\SomeStringConstantConfigrootKey\ \./\);
            //  // Build the configurationRoot for this service
            //  // var configurationBuilder = ConfigurationExtensions.StandardConfigurationBuilder(loadedFromDirectory, initialStartupDirectory, ConsoleMonitorDefaultConfiguration.Production, ConsoleMonitorStringConstants.SettingsFileName, ConsoleMonitorStringConstants.SettingsFileNameSuffix, StringConstants.CustomEnvironmentVariablePrefix, LoggerFactory, stringLocalizerFactory, hostEnvironment, hostConfiguration, linkedCancellationToken);
            //  // ConfigurationRoot = configurationBuilder.Build();
            //  #endregion
            //  // Embedded object as Data
            //  //AssemblyUnitNameReplacementPatternBaseData = new AssemblyUnitNameReplacementPatternBaseData();
            //  */";
            //var gCompilationUnitPatternReplacement = new GPatternReplacement(gDictionary: new Dictionary<Regex, string>() {
            //  {new Regex("CompilationUnitNameReplacementPattern"), "AssemblyUnitNameReplacementPattern"},
            //  {new Regex("DataInitializationInStartAsyncReplacementPattern"), tempdatainitialization}, {
            //    new Regex("DataDisposalInStopAsyncReplacementPattern"),
            //    //"SubscriptionToConsoleReadLineAsyncAsObservableDisposeHandle.Dispose();"
            //    ""
            //  },
            //});
            //foreach (var kvp in gAssemblyUnitPatternReplacement.GDictionary) {
            //  gCompilationUnitPatternReplacement.GDictionary.Add(kvp.Key, kvp.Value);
            //}
            //#endregion
            //gCompilationUnit = new GCompilationUnit(gCompilationUnitName, gFileSuffix: ".cs",
            //  gRelativePath: SubDirectoryForGeneratedFiles, gPatternReplacement: gCompilationUnitPatternReplacement);
            #region Add UsingGroups common to both the Titular Derived CompilationUnit and the Titular Base CompilationUnit
            var gUsingGroup = MUsingGroupForMicrosoftGenericHostInGHHSAndGHBS();
            gAssemblyGroupBasicConstructorResult.GTitularDerivedCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote, gUsingGroup);
            gAssemblyGroupBasicConstructorResult.GTitularBaseCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote, gUsingGroup);
            gUsingGroup = MUsingGroupForSystemGenericHostInGHHSAndGHBS();
            gAssemblyGroupBasicConstructorResult.GTitularDerivedCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote, gUsingGroup);
            gAssemblyGroupBasicConstructorResult.GTitularBaseCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote, gUsingGroup);
            #endregion
            #region Add UsingGroups specific to the Titular Base CompilationUnit
            #endregion
            #region Standard Property Group for every GenericHostHostedService
            var gPropertyGroup = new GPropertyGroup("Standard Properties for every GenericHostHostedService");
            gAssemblyGroupBasicConstructorResult.GClassBase.AddPropertyGroups(gPropertyGroup);
            foreach (var o in new List <IGProperty>()
            {
                new GProperty("ConfigurationRoot", gType: "ConfigurationRoot", gAccessors: "{ get; }",
                              gVisibility: "protected internal"),
            })
            {
                gPropertyGroup.GPropertys.Add(o.Philote, o);
            }
            #endregion
            #region Injected AutoProperty Group and their derived AutoProperty Groups for every GenericHostHostedService
            #region Injected AutoProperties whose Type IS their name
            gPropertyGroup = new GPropertyGroup("Injected AutoProperty Group for GenericHost");
            gAssemblyGroupBasicConstructorResult.GClassBase.AddPropertyGroups(gPropertyGroup);
            foreach (var ap in new List <string>()
            {
                "LoggerFactory",
                "StringLocalizerFactory",
                "HostEnvironment",
                "HostLifetime",
                "HostApplicationLifetime"
            })
            {
                gAssemblyGroupBasicConstructorResult.GClassBase.AddTConstructorAutoPropertyGroup(
                    gAssemblyGroupBasicConstructorResult.GPrimaryConstructorBase.Philote, ap, gPropertyGroupId: gPropertyGroup.Philote);
            }
            #endregion
            #region Injected AutoProperties whose Type is NOT their name
            foreach (var ap in new List <string>()
            {
                "HostConfiguration", "AppConfiguration"
            })
            {
                gAssemblyGroupBasicConstructorResult.GClassBase.AddTConstructorAutoPropertyGroup(
                    gAssemblyGroupBasicConstructorResult.GPrimaryConstructorBase.Philote, ap, gType: "IConfiguration",
                    gPropertyGroupId: gPropertyGroup.Philote);
            }
            #endregion
            #region Derived AutoProperty Group for Logger
            gPropertyGroup = new GPropertyGroup("Derived AutoProperty Group for Logger");
            gAssemblyGroupBasicConstructorResult.GClassBase.AddPropertyGroups(gPropertyGroup);
            gAssemblyGroupBasicConstructorResult.GClassBase.AddTLoggerConstructorAutoPropertyGroup(
                gAssemblyGroupBasicConstructorResult.GPrimaryConstructorBase.Philote, gPropertyGroupId: gPropertyGroup.Philote);
            #endregion
            #region Derived AutoProperty Group for Localizers
            gPropertyGroup = new GPropertyGroup("Derived AutoProperty Group for Localizers");
            gAssemblyGroupBasicConstructorResult.GClassBase.AddPropertyGroups(gPropertyGroup);
            foreach (var ap in new List <string>()
            {
                "DebugLocalizer", "ExceptionLocalizer", "UiLocalizer"
            })
            {
                gAssemblyGroupBasicConstructorResult.GClassBase.AddTLocalizerConstructorAutoPropertyGroup(
                    gAssemblyGroupBasicConstructorResult.GPrimaryConstructorBase.Philote, ap, gAssemblyGroupBasicConstructorResult.GTitularAssemblyUnitName,
                    gPropertyGroupId: gPropertyGroup.Philote);
            }
            #endregion
            #endregion

            #region standard Methods for every GenericHostHostedService
            gAssemblyGroupBasicConstructorResult.GClassBase.AddMethodGroup(MCreateHostApplicationLifetimeEventHandlerMethods());
            #endregion
            return(gAssemblyGroupBasicConstructorResult);
        }
Esempio n. 6
0
        public static IGAssemblyGroup MConsoleMonitorGHS(string gAssemblyGroupName,
                                                         string subDirectoryForGeneratedFiles     = default, string baseNamespaceName = default, bool hasInterfaces = true,
                                                         IGPatternReplacement gPatternReplacement = default)
        {
            IGPatternReplacement _gPatternReplacement =
                gPatternReplacement == default ? new GPatternReplacement() : gPatternReplacement;
            var mCreateAssemblyGroupResult = MAssemblyGroupGHHSConstructor(gAssemblyGroupName, subDirectoryForGeneratedFiles,
                                                                           baseNamespaceName, hasInterfaces, _gPatternReplacement);

            #region Initial StateMachine Configuration
            mCreateAssemblyGroupResult.GPrimaryConstructorBase.GStateConfiguration.GDOTGraphStatements.Add(
                @"
          WaitingForInitialization ->BlockingOnConsoleInReadLineAsync [label = ""InitializationCompleteReceived""]
          WaitingForRequestToWriteSomething -> WaitingForWriteToComplete [label = ""WriteStarted""]
          WaitingForWriteToComplete -> WaitingForRequestToWriteSomething [label = ""WriteFinished""]
          WaitingForWriteToComplete -> WaitingForRequestToWriteSomething [label = ""CancellationTokenActivated""]
          WaitingForRequestToWriteSomething -> ServiceFaulted [label = ""ExceptionCaught""]
          WaitingForWriteToComplete ->ServiceFaulted [label = ""ExceptionCaught""]
          WaitingForRequestToWriteSomething ->ShutdownStarted [label = ""CancellationTokenActivated""]
          WaitingForRequestToWriteSomething ->ShutdownStarted [label = ""StopAsyncActivated""]
          WaitingForWriteToComplete ->ShutdownStarted [label = ""StopAsyncActivated""]
        "
                );
            #endregion
            #region Add UsingGroups to the Titular Derived and Titular Base CompilationUnits
            #region Add UsingGroups common to both the Titular Derived and Titular Base CompilationUnits
            var gUsingGroup =
                new GUsingGroup(
                    $"UsingGroup common to both  {mCreateAssemblyGroupResult.GTitularDerivedCompilationUnit.GName} and {mCreateAssemblyGroupResult.GTitularBaseCompilationUnit.GName}");
            foreach (var gName in new List <string>()
            {
                "ATAP.Utilities.GenericHostServices.ConsoleSourceGHS", "ATAP.Utilities.GenericHostServices.ConsoleSinkGHS",
            })
            {
                var gUsing = new GUsing(gName);
                gUsingGroup.GUsings.Add(gUsing.Philote, gUsing);
            }
            mCreateAssemblyGroupResult.GTitularDerivedCompilationUnit.GUsingGroups
            .Add(gUsingGroup.Philote, gUsingGroup);
            mCreateAssemblyGroupResult.GTitularBaseCompilationUnit.GUsingGroups
            .Add(gUsingGroup.Philote, gUsingGroup);
            #endregion
            #region Add UsingGroups specific to the Titular Base CompilationUnit
            gUsingGroup =
                new GUsingGroup(
                    $"UsingGroup specific to {mCreateAssemblyGroupResult.GTitularBaseCompilationUnit.GName}");
            foreach (var gName in new List <string>()
            {
                "System.Reactive.Linq",
                "System.Reactive.Concurrency",
                $"{baseNamespaceName}ConsoleSinkGHS",
                $"{baseNamespaceName}ConsoleSourceGHS"
            })
            {
                var gUsing = new GUsing(gName);
                gUsingGroup.GUsings.Add(gUsing.Philote, gUsing);
            }
            mCreateAssemblyGroupResult.GTitularBaseCompilationUnit.GUsingGroups
            .Add(gUsingGroup.Philote, gUsingGroup);
            #endregion
            #endregion
            #region Injected PropertyGroup For ConsoleSinkAndConsoleSource
            var gPropertyGroup = new GPropertyGroup("Injected Property for ConsoleSinkGHS and ConsoleSourceGHS");
            mCreateAssemblyGroupResult.GClassBase.AddPropertyGroups(gPropertyGroup);
            foreach (var o in new List <string>()
            {
                "ConsoleSourceGHS", "ConsoleSinkGHS"
            })
            {
                mCreateAssemblyGroupResult.GClassBase.AddTConstructorAutoPropertyGroup(
                    mCreateAssemblyGroupResult.GPrimaryConstructorBase.Philote, o, gPropertyGroupId: gPropertyGroup.Philote);
            }
            #endregion
            #region Add the MethodGroup for this service
            var gMethodGroup =
                new GMethodGroup(
                    gName:
                    $"MethodGroup specific to {mCreateAssemblyGroupResult.GClassBase.GName}");
            IGMethod gMethod;
            gMethod = CreateConsoleSourceReadLineAsyncAsObservableMethod();
            gMethodGroup.GMethods.Add(gMethod.Philote, gMethod);
            gMethod = MCreateWriteMethodInConsoleMonitor();
            gMethodGroup.GMethods.Add(gMethod.Philote, gMethod);
            //gMethod = MCreateWriteAsyncMethodInConsoleMonitor();
            //gMethodGroup.GMethods.Add(gMethod.Philote, gMethod);
            mCreateAssemblyGroupResult.GClassBase.AddMethodGroup(gMethodGroup);
            #endregion
            #region Add References used by the Titular Derived and Titular Base CompilationUnits to the ProjectUnit
            #region Add References used by both the Titular Derived and Titular Base CompilationUnits
            foreach (var o in new List <IGItemGroupInProjectUnit>()
            {
                ReactiveUtilitiesReferencesItemGroupInProjectUnit(),
                new GItemGroupInProjectUnit(
                    "References used by both the {Derived} and {Base}",
                    "References to the ConsoleSourceGHS and ConsoleSinkGHS Interfaces, used by both the used by both the {Derived CompilationUnit} and {Base CompilationUnit}",
                    new GBody(new List <string>()
                {
                    "<PackageReference Include=\"ConsoleSourceGHS.Interfaces\" />",
                    "<PackageReference Include=\"ConsoleSinkGHS.Interfaces\" />",
                }))
            }
                     )
            {
                mCreateAssemblyGroupResult.GTitularAssemblyUnit.GProjectUnit.GItemGroupInProjectUnits
                .Add(o.Philote, o);
            }
            #endregion
            #region Add References unique to the Titular Base CompilationUnit
            foreach (var o in new List <IGItemGroupInProjectUnit>()
            {
            }
                     )
            {
                mCreateAssemblyGroupResult.GTitularAssemblyUnit.GProjectUnit.GItemGroupInProjectUnits
                .Add(o.Philote, o);
            }
            #endregion
            #endregion
            /*******************************************************************************/
            #region Update the Interface Assembly for this service
            #region Add UsingGroups for the Titular Derived Interface CompilationUnit and Titular Base Interface CompilationUnit
            #region Add UsingGroups common to both the Titular Derived Interface CompilationUnit and the Titular Base Interface CompilationUnit
            gUsingGroup =
                new GUsingGroup(
                    $"UsingGroups common to both {mCreateAssemblyGroupResult.GTitularInterfaceDerivedCompilationUnit.GName} and {mCreateAssemblyGroupResult.GTitularInterfaceBaseCompilationUnit.GName}");
            foreach (var gName in new List <string>()
            {
                $"{baseNamespaceName}ConsoleSinkGHS", $"{baseNamespaceName}ConsoleSourceGHS"
            })
            {
                var gUsing = new GUsing(gName);
                gUsingGroup.GUsings.Add(gUsing.Philote, gUsing);
            }
            mCreateAssemblyGroupResult.GTitularInterfaceDerivedCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote,
                                                                                                gUsingGroup);
            mCreateAssemblyGroupResult.GTitularInterfaceBaseCompilationUnit.GUsingGroups.Add(gUsingGroup.Philote,
                                                                                             gUsingGroup);
            #endregion
            #region Add UsingGroups specific to the Titular Base Interface
            #endregion
            #endregion
            #region Add References for the Titular Interface ProjectUnit
            #region Add References common to both the Titular Derived Interface and Titular Base Interface
            foreach (var o in new List <IGItemGroupInProjectUnit>()
            {
                ReactiveUtilitiesReferencesItemGroupInProjectUnit(),
                new GItemGroupInProjectUnit(
                    "References used by both the {Derived} and {Base}",
                    "References to the ConsoleSourceGHS and ConsoleSinkGHS Interfaces, used by both the used by both the {Derived CompilationUnit} and {Base CompilationUnit}",
                    new GBody(new List <string>()
                {
                    "<PackageReference Include=\"ConsoleSourceGHS.Interfaces\" />",
                    "<PackageReference Include=\"ConsoleSinkGHS.Interfaces\" />",
                })),
            }
                     )
            {
                mCreateAssemblyGroupResult.gTitularInterfaceAssemblyUnit.GProjectUnit.GItemGroupInProjectUnits
                .Add(o.Philote, o);
            }
            #endregion
            #region Add References unique to the Titular Base Interface CompilationUnit
            #endregion
            #endregion
            #endregion
            #region Finalize the GHHS
            GAssemblyGroupGHHSFinalizer(mCreateAssemblyGroupResult);
            #endregion
            return(mCreateAssemblyGroupResult.GAssemblyGroup);
        }