예제 #1
0
        //public static IDictionary<IGExceptionId<TValue>, IGException<TValue>> ConvertToInterfaceExceptions(this IGClass gClass) {
        //  return new Dictionary<IGExceptionId<TValue>, IGException<TValue>>();
        //}

        //public static IDictionary<IGExceptionGroupId<TValue>, IGExceptionGroup<TValue>> ConvertToInterfaceExceptionGroups(this IGClass gClass) {
        //  return new Dictionary<IGExceptionGroupId<TValue>, IGExceptionGroup<TValue>>();
        //}

        //public static IDictionary<IGEventId<TValue>, IGEvent<TValue>> ConvertToInterfaceEvents(this IGClass gClass) {
        //  return new Dictionary<IGEventId<TValue>, IGEvent<TValue>>();
        //}

        //public static IDictionary<IGEventGroupId<TValue>, IGEventGroup<TValue>> ConvertToInterfaceEventGroups(this IGClass gClass) {
        //  return new Dictionary<IGEventGroupId<TValue>, IGEventGroup<TValue>>();
        //}
        static public void PopulateInterface(IGClass gClass, IGInterface gInterface)
        {
            //gClass.ConvertToInterfacePropertys().ForEach(x => gInterface.GPropertys.Add(x.Key, x.Value));
            //gClass.ConvertToInterfacePropertyGroups().ForEach(x => gInterface.GPropertyGroups.Add(x.Key, x.Value));
            //gClass.ConvertToInterfaceMethods().ForEach(x => gInterface.GMethods.Add(x.Key, x.Value));
            //gClass.ConvertToInterfaceMethodGroups().ForEach(x => gInterface.GMethodGroups.Add(x.Key, x.Value));
            //gClass.ConvertToInterfaceExceptions().ForEach(x => gInterface.GExceptions.Add(x.Key, x.Value));
            //gClass.ConvertToInterfaceExceptionGroups().ForEach(x => gInterface.GExceptionGroups.Add(x.Key, x.Value));
            //gClass.ConvertToInterfaceEvents().ForEach(x => gInterface.GEvents.Add(x.Key, x.Value));
            //gClass.ConvertToInterfaceEventGroups().ForEach(x => gInterface.GEventGroups.Add(x.Key, x.Value));
            foreach (var kvp in gClass.ConvertToInterfacePropertys())
            {
                gInterface.GPropertys.Add(kvp.Key, kvp.Value);
            }
            foreach (var kvp in gClass.ConvertToInterfacePropertyGroups())
            {
                gInterface.GPropertyGroups.Add(kvp.Key, kvp.Value);
            }
            //baseClass.ConvertToInterfacePropertyGroups().ForEach(x => gInterface.GPropertyGroups.Add(x.Key, x.Value));
            foreach (var kvp in gClass.ConvertToInterfaceMethods())
            {
                gInterface.GMethods.Add(kvp.Key, kvp.Value);
            }
            foreach (var kvp in gClass.ConvertToInterfaceMethodGroups())
            {
                gInterface.GMethodGroups.Add(kvp.Key, kvp.Value);
            }
        }
예제 #2
0
 public static IGClass AddDelegate(this IGClass gClass, IEnumerable <IGDelegate> gDelegates)
 {
     foreach (var o in gDelegates)
     {
         gClass.GDelegates[o.Id] = o;
     }
     return(gClass);
 }
예제 #3
0
 public static IGClass AddMethod(this IGClass gClass, IDictionary <IGMethodId <TValue>, IGMethod <TValue> > gMethods)
 {
     foreach (var kvp in gMethods)
     {
         gClass.GMethods.Add(kvp.Key, kvp.Value);
     }
     return(gClass);
 }
예제 #4
0
 public static IGClass AddMethodGroup(this IGClass gClass, IEnumerable <IGMethodGroup> gMethodGroups)
 {
     foreach (var o in gMethodGroups)
     {
         gClass.AddMethodGroup(o);
     }
     return(gClass);
 }
        public static void MMethodGroupForFileSystemToObjectGraphBaseAssembly(IGClass gClass)
        {
            var gMethodGroup =
                new GMethodGroup(gName: "MethodGroup specific to the FileSystemToObjectGraph");

            // None
            gClass.AddMethodGroup(gMethodGroup);
        }
예제 #6
0
 public static IGClass AddProperty(this IGClass gClass, IDictionary <IGPropertyId <TValue>, IGProperty <TValue> > gPropertys)
 {
     foreach (var kvp in gPropertys)
     {
         gClass.GPropertys.Add(kvp.Key, kvp.Value);
     }
     return(gClass);
 }
예제 #7
0
 public static IGClass AddDelegateGroup(this IGClass gClass, IEnumerable <IGDelegateGroup> gDelegateGroups)
 {
     foreach (var o in gDelegateGroups)
     {
         gClass.AddDelegateGroup(o);
     }
     return(gClass);
 }
예제 #8
0
 public static IGClass AddDelegate(this IGClass gClass, IDictionary <IGDelegateId <TValue>, IGDelegate <TValue> > gDelegates)
 {
     foreach (var kvp in gDelegates)
     {
         gClass.GDelegates.Add(kvp.Key, kvp.Value);
     }
     return(gClass);
 }
예제 #9
0
 public static IGClass AddMethod(this IGClass gClass, IEnumerable <IGMethod> gMethods)
 {
     foreach (var o in gMethods)
     {
         gClass.GMethods[o.Id] = o;
     }
     return(gClass);
 }
예제 #10
0
 public static IGClass AddPropertyGroups(this IGClass gClass, IEnumerable <IGPropertyGroup> gPropertyGroups)
 {
     foreach (var o in gPropertyGroups)
     {
         gClass.GPropertyGroups[o.Id] = o;
     }
     return(gClass);
 }
예제 #11
0
 /*************************************************************************************/
 public static IEnumerable <KeyValuePair <IGPropertyID, IGProperty> > ConvertToInterfacePropertys(
     this IGClass gClass)
 {
     //var IEKVP = gClass.GPropertys.Where(kvp => kvp.Value.GVisibility == "public");
     //Dictionary<IGPropertyId<TValue>, IGProperty<TValue>> t1 = IEKVP.ToDictionary(kvp=>kvp.Key,kvp=>kvp.Value);
     //return gClass.GPropertys.Where(kvp => kvp.Value.GVisibility == "public").ToDictionary(kvp=>kvp.Key,kvp=>kvp.Value);
     return(gClass.GPropertys.Where(kvp =>
                                    kvp.Value.GVisibility == "public"));
 }
        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);
        }
예제 #14
0
 public static IEnumerable <IGMethod> CombinedMethods(this IGClass gClass)
 {
     foreach (var o in gClass.GMethods)
     {
         yield return(o.Value);
     }
     foreach (var mg in gClass.GMethodGroups)
     {
         foreach (var o in mg.Value.GMethods)
         {
             yield return(o.Value);
         }
     }
 }
예제 #15
0
 public static IDictionary <IGPropertyGroupId <TValue>, IGPropertyGroup <TValue> > ConvertToInterfacePropertyGroups(
     this IGClass gClass)
 {
     foreach (var pG in gClass.GPropertyGroups)
     {
         var newDictionary = new Dictionary <IGPropertyId <TValue>, IGProperty <TValue> >();
         var IEKVP         = pG.Value.GPropertys.Where(kvp => kvp.Value.GVisibility == "public");
     }
     //var newDictionary = gClass.GPropertyGroups.Where(x=>x.Value.GVisibility == "public").ToDictionary<IGPropertyGroupId<TValue>, IGPropertyGroup<TValue>>(x=>x.Value.GVisibility == "public")
     //var newDictionary = gClass.GPropertyGroups.SelectMany(kvp =>
     //  kvp.Value
     //    .Where(x => x.GVisibility == "public")
     //    .ToDictionary<IGPropertyGroupId<TValue>, IGPropertyGroup<TValue>>(_ => true);
     return(new Dictionary <IGPropertyGroupId <TValue>, IGPropertyGroup <TValue> >());
 }
예제 #16
0
        public static IGInterface ConvertToInterface(this IGClass gClass)
        {
            var inheritanceRegex1     = new Regex(@":.*?{", RegexOptions.Multiline);
            var gInterfaceInheritance = gClass.GInheritance;
            var gInterfaceImplements  = gClass.GImplements;
            var gInterface            = new GInterface(
                gName: gClass.GName,
                gVisibility: gClass.GVisibility,
                gImplements: gInterfaceImplements,
                gInheritance: gInterfaceInheritance
                );

            foreach (var kvp in gClass.ConvertToInterfacePropertys())
            {
                gInterface.GPropertys.Add(kvp.Key, kvp.Value);
            }
            foreach (var kvp in gClass.ConvertToInterfacePropertyGroups())
            {
                gInterface.GPropertyGroups.Add(kvp.Key, kvp.Value);
            }
            foreach (var kvp in gClass.ConvertToInterfaceMethods())
            {
                gInterface.GMethods.Add(kvp.Key, kvp.Value);
            }
            foreach (var kvp in gClass.ConvertToInterfaceMethodGroups())
            {
                gInterface.GMethodGroups.Add(kvp.Key, kvp.Value);
            }
            //foreach (var kvp in gClass.ConvertToInterfaceExceptionss()) {
            //  gInterface.GExceptionss.Add(kvp.Key, kvp.Value);
            //}
            //foreach (var kvp in gClass.ConvertToInterfaceExceptionsGroups()) {
            //  gInterface.GExceptionsGroups.Add(kvp.Key, kvp.Value);
            //}
            //foreach (var kvp in gClass.ConvertToInterfaceEventss()) {
            //  gInterface.GEventss.Add(kvp.Key, kvp.Value);
            //}
            //foreach (var kvp in gClass.ConvertToInterfaceEventsGroups()) {
            //  gInterface.GEventsGroups.Add(kvp.Key, kvp.Value);
            //}
            //foreach (var kvp in gClass.ConvertToInterfaceConstructors()) {
            //  gInterface.GMethods.Add(kvp.Key, kvp.Value);
            //}
            //foreach (var kvp in gClass.ConvertToInterfaceConstructorGroups()) {
            //  gInterface.GConstructorGroups.Add(kvp.Key, kvp.Value);
            //}
            return(gInterface);
        }
예제 #17
0
        public static IGClass AddTConstructorAutoPropertyGroup(this IGClass gClass, IPhilote <IGMethod> gMethodId, string gAutoPropertyName, string gType, IPhilote <IGPropertyGroup> gPropertyGroupId = default, string?gAccessors = "{ get;}", string?gVisibility = default)
        {
            var gProperty = new GProperty(gAutoPropertyName.ToUpperFirstChar(), gType, gAccessors, gVisibility);

            if (gClass.GPropertyGroups != null && gClass.GPropertyGroups.ContainsKey(gPropertyGroupId))
            {
                gClass.GPropertyGroups[gPropertyGroupId].GPropertys[gProperty.Philote] = gProperty;
            }
            else
            {
                throw new Exception(string.Format("{0} not found in the PropertyGroups of {1}", gPropertyGroupId.ID.ToString(), gClass.GName));
            }
            IGMethod gMethod = default;

            if (gClass.GMethods != null && gClass.GMethods.ContainsKey(gMethodId))
            {
                gMethod = gClass.GMethods[gMethodId];
            }
            else if (gClass.GMethodGroups != null)
            {
                foreach (var kvp in gClass.GMethodGroups)
                {
                    if (kvp.Value.GMethods.ContainsKey(gMethodId))
                    {
                        var gMethodGroup = kvp.Value;
                        gMethod = gMethodGroup.GMethods[gMethodId];
                    }
                }
            }

            if (gMethod == null)
            {
                throw new Exception(string.Format("{0} not found in the Methods or MethodGroups of {1}", gMethodId.ID.ToString(), gClass.GName));
            }

            GArgument gArgument = new GArgument(gAutoPropertyName.ToLowerFirstChar(), gType);

            gMethod.GDeclaration.GArguments[gArgument.Philote] = gArgument;

            gMethod.GBody.GStatements.Add($"{gAutoPropertyName.ToUpperFirstChar()} = {gAutoPropertyName.ToLowerFirstChar()} ?? throw new ArgumentNullException(nameof({gAutoPropertyName.ToLowerFirstChar()}));");
            return(gClass);
        }
예제 #18
0
 public static IEnumerable <IGMethod> CombinedConstructors(this IGClass gClass)
 {
     foreach (var o in gClass.GMethods)
     {
         if (o.Value.GDeclaration.IsConstructor)
         {
             yield return(o.Value);
         }
     }
     foreach (var mg in gClass.GMethodGroups)
     {
         foreach (var o in mg.Value.GMethods)
         {
             if (o.Value.GDeclaration.IsConstructor)
             {
                 yield return(o.Value);
             }
         }
     }
 }
        public static IGClass AddTLocalizerConstructorAutoPropertyGroup(this IGClass gClass, IPhilote <IGMethod> gMethodId, string gAutoPropertyName, string assemblyUnitName, IPhilote <IGPropertyGroup> gPropertyGroupId = default, string?gAccessors = "{ get; }", string?gVisibility = default)
        {
            IGMethod gMethod = default;

            if (gClass.GMethods != null && gClass.GMethods.ContainsKey(gMethodId))
            {
                gMethod = gClass.GMethods[gMethodId];
            }
            else if (gClass.GMethodGroups != null)
            {
                foreach (var kvp in gClass.GMethodGroups)
                {
                    if (kvp.Value.GMethods.ContainsKey(gMethodId))
                    {
                        //GMethodGroup gMethodGroup = kvp.Value;
                        gMethod = kvp.Value.GMethods[gMethodId];
                    }
                }
            }
            if (gMethod == null)
            {
                throw new Exception(string.Format("{0} not found in the Constructors, Methods or MethodGroups of {1}", gMethodId.ID.ToString(), gClass.GName));
            }

            var       gMethodDeclaration = gMethod.GDeclaration;
            string    gName     = gMethodDeclaration.GName;
            GProperty gProperty = new GProperty(gName: $"{gAutoPropertyName}", gType: $"IStringLocalizer", gAccessors: gAccessors);

            if (gClass.GPropertyGroups != null && gClass.GPropertyGroups.ContainsKey(gPropertyGroupId))
            {
                gClass.GPropertyGroups[gPropertyGroupId].GPropertys[gProperty.Philote] = gProperty;
            }
            else
            {
                throw new Exception(string.Format("{0} not found in the PropertyGroups of {1}", gPropertyGroupId.ID.ToString(), gClass.GName));
            }

            //gMethod.GBody.StatementList.Add($"{gAutoPropertyName} = StringLocalizerFactory.Create(nameof({assemblyUnitName}.Resources), \"{assemblyUnitName}\");");
            gMethod.GBody.GStatements.Add($"{gAutoPropertyName} = StringLocalizerFactory.Create(nameof(Resources), \"{assemblyUnitName}\");");
            return(gClass);
        }
        public static IGClass AddTLoggerConstructorAutoPropertyGroup(this IGClass gClass, IPhilote <IGMethod> gMethodId, IPhilote <IGPropertyGroup> gPropertyGroupId = default, string?gAccessors = "{ get; }", string?gVisibility = default)
        {
            IGMethod gMethod = default;

            if (gClass.GMethods != null && gClass.GMethods.ContainsKey(gMethodId))
            {
                gMethod = gClass.GMethods[gMethodId];
            }
            else if (gClass.GMethodGroups != null)
            {
                foreach (var kvp in gClass.GMethodGroups)
                {
                    if (kvp.Value.GMethods.ContainsKey(gMethodId))
                    {
                        var gMethodGroup = kvp.Value;
                        gMethod = gMethodGroup.GMethods[gMethodId];
                    }
                }
            }
            if (gMethod == null)
            {
                throw new Exception(string.Format("{0} not found in the Constructors, Methods or MethodGroups of {1}", gMethodId.ID.ToString(), gClass.GName));
            }

            var       gMethodDeclaration = gMethod.GDeclaration;
            string    gName     = gMethodDeclaration.GName;
            GProperty gProperty = new GProperty(gName: $"Logger", gType: $"ILogger<{gName}>", gAccessors: gAccessors);

            if (gClass.GPropertyGroups != null && gClass.GPropertyGroups.ContainsKey(gPropertyGroupId))
            {
                gClass.GPropertyGroups[gPropertyGroupId].GPropertys[gProperty.Philote] = gProperty;
            }
            else
            {
                throw new Exception(string.Format("{0} not found in the PropertyGroups of {1}", gPropertyGroupId.ID.ToString(), gClass.GName));
            }

            gMethod.GBody.GStatements.Add($"Logger = LoggerFactory.CreateLogger<{gName}>();");
            return(gClass);
        }
        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));
        }
예제 #22
0
        public static IGClass AddTConstructorAutoPropertyGroup(this IGClass gClass, IPhilote <IGMethod> gMethodId, string gAutoPropertyName, IPhilote <IGPropertyGroup> gPropertyGroupId)
        {
            string gType = "I" + gAutoPropertyName;

            return(gClass.AddTConstructorAutoPropertyGroup(gMethodId, gAutoPropertyName, gType, gPropertyGroupId));
        }
예제 #23
0
        public static IGCompilationUnit TClassMakeBase(this IGCompilationUnit gCompilationUnit, IGClass gClass)
        {
            string          name     = gClass.GName + "Base";
            List <IGMethod> gMethods = new List <IGMethod>();

            foreach (var kvp in gClass.GMethods)
            {
                var    oldGMethod = kvp.Value;
                string newgAccessModifier;
                newgAccessModifier = oldGMethod.GDeclaration.GVisibility == "public" ? "virtual" : "";
                gMethods.Add(new GMethod(new GMethodDeclaration(gName: oldGMethod.GDeclaration.GName,
                                                                gType: oldGMethod.GDeclaration.GType,
                                                                gAccessModifier: newgAccessModifier,
                                                                isStatic: oldGMethod.GDeclaration.IsStatic,
                                                                gArguments: oldGMethod.GDeclaration.GArguments
                                                                )
                                         , oldGMethod.GBody));
            }
            return(gCompilationUnit);
        }
예제 #24
0
        public static IDictionary <IGMethodId <TValue>, IGMethod <TValue> > ConvertToInterfaceMethods(this IGClass gClass)
        {
            var gInterfaceMethods = new Dictionary <IGMethodId <TValue>, IGMethod <TValue> >();

            foreach (var kvp in gClass.GMethods)
            {
                var gInterfaceMethod = ConvertMethodToInterfaceMethod(kvp.Value);
                if (gInterfaceMethod != default)
                {
                    gInterfaceMethods.Add(gInterfaceMethod.Id, gInterfaceMethod);
                }
            }
            return(gInterfaceMethods);
        }
예제 #25
0
        public static IDictionary <IGMethodGroupId <TValue>, IGMethodGroup <TValue> > ConvertToInterfaceMethodGroups(this IGClass gClass)
        {
            var           gInterfaceMethodGroups = new Dictionary <IGMethodGroupId <TValue>, IGMethodGroup <TValue> >();
            IGMethodGroup gInterfaceMethodGroup;
            IGMethod      gInterfaceMethod = default;

            foreach (var kvp in gClass.GMethodGroups)
            {
                gInterfaceMethodGroup = new GMethodGroup(gName: kvp.Value.GName);
                foreach (var mkvp in kvp.Value.GMethods)
                {
                    gInterfaceMethod = ConvertMethodToInterfaceMethod(mkvp.Value);
                    if (gInterfaceMethod != default)
                    {
                        gInterfaceMethodGroup.GMethods.Add(gInterfaceMethod.Id, gInterfaceMethod);
                    }
                }
                gInterfaceMethodGroups.Add(gInterfaceMethodGroup.Id, gInterfaceMethodGroup);
            }
            return(gInterfaceMethodGroups);
        }
예제 #26
0
 public static IGClass AddPropertyGroups(this IGClass gClass, IGPropertyGroup gPropertyGroup)
 {
     gClass.GPropertyGroups[gPropertyGroup.Id] = gPropertyGroup;
     return(gClass);
 }
예제 #27
0
 public static IGClass AddMethodGroup(this IGClass gClass, IGMethodGroup gMethodGroup)
 {
     gClass.GMethodGroups[gMethodGroup.Id] = gMethodGroup;
     return(gClass);
 }
        public static IGClass AddTConstructorAutoProperty(this IGClass gClass, Philote <IGMethod> gMethodID, string gAutoPropertyName)
        {
            string gType = "I" + gAutoPropertyName;

            return(gClass.AddTConstructorAutoProperty(gMethodID, gAutoPropertyName, gType));
        }
        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);
        }
예제 #30
0
 public static IGClass AddMethod(this IGClass gClass, IGMethod gMethod)
 {
     gClass.GMethods[gMethod.Id] = gMethod;
     return(gClass);
 }