private static void AddPropertyCode(MemberData member, CodeGenFile codeGenFile, ComponentData component)
        {
            string typeAndName  = $" {member.type} {component.ComponentName().UppercaseFirst()}";
            string withProperty = $"{ValueAndPropertyStringStart}{typeAndName}{ValueAndPropertyStringEnd}";

            ReplaceWithResolvedNames(codeGenFile, component, ValueBaseString, withProperty);
        }
        private static string ReplacePropertyIfSingleValue(string template, ComponentData data)
        {
            MemberData[] members = data.GetMemberData();
            if (!members.IsSingleValueComponent())
            {
                return(template.Replace(PropertyCode, StandardProperty));
            }

            string modifiedProperty = $"{members[0].type} {data.ComponentName().UppercaseFirst()} {{ get; }} \n    {StandardProperty}";

            return(template.Replace(PropertyCode, modifiedProperty));
        }
        private CodeGenFile GenerateInterface(ComponentData data)
        {
            string template = IsFlag(data)
        ? FLAG_TEMPLATE
        : StandardTemplate;

            return(new CodeGenFile(
                       "Components" + Path.DirectorySeparatorChar +
                       "Interfaces" + Path.DirectorySeparatorChar +
                       "I" + data.ComponentName() + "Entity.cs",
                       ReplacePropertyIfSingleValue(template, data).Replace(data, string.Empty),
                       GetType().FullName
                       ));
        }
        CodeGenFile generateInterface(ComponentData data)
        {
            var template = data.GetMemberData().Length == 0
                ? FLAG_TEMPLATE
                : STANDARD_TEMPLATE;

            if (data.ComponentName().EndsWith("Listener"))
            {
                template = template.Replace("${ListenerMethod}",
                                            ListenerTemplate.Replace("${EventListener}", data.ComponentName()));
            }
            else
            {
                template = template.Replace("${ListenerMethod}", string.Empty);
            }

            return(new CodeGenFile(
                       "Components" + Path.DirectorySeparatorChar +
                       "Interfaces" + Path.DirectorySeparatorChar +
                       "I" + data.ComponentName() + "Entity.cs",
                       template.Replace(data, string.Empty),
                       GetType().FullName
                       ));
        }
Beispiel #5
0
        private static IEnumerable <CodeGenFile> FileByComponentNameIn(CodeGenFile[] codeGenFiles, ComponentData component)
        {
            foreach (CodeGenFile file in codeGenFiles)
            {
                string   contextName           = file.ContextName();
                string[] componentContextNames = component.GetContextNames();

                string componentNameStripped = component.ComponentName()
                                               .Replace("Component", "");

                if (componentContextNames.Any(x => x == contextName) && file.fileName.EndsWith($"{contextName}{componentNameStripped}Component.cs"))
                {
                    yield return(file);
                }
            }
        }
Beispiel #6
0
        private static CodeGenFile FindByComponentNameIn(CodeGenFile[] codeGenFiles, ComponentData component)
        {
            CodeGenFile byName = null;

            foreach (var file in codeGenFiles)
            {
                var contextName           = file.ContextName();
                var componentContextNames = component.GetContextNames();

                string componentNameStripped = component.ComponentName()
                                               .Replace("Component", "");

                if (componentContextNames.Any(x => x == contextName) && file.fileName.EndsWith($"{contextName}{componentNameStripped}Component.cs"))
                {
                    byName = file;
                    break;
                }
            }

            return(byName);
        }
 public static CodeGenFile CorrespondingFile(this ComponentData component, CodeGenFile[] codeGenFiles) =>
 codeGenFiles.FirstOrDefault(f => f.fileName.EndsWith($"{component.GetContextNames().First()}{component.ComponentName()}Component.cs"));