Ejemplo n.º 1
0
        public static List <string> Usings(this ClassGenerator generator)
        {
            var usings = new List <string>();

            for (int i = 0; i < generator.attributes.Count; i++)
            {
                usings.MergeUnique(generator.attributes[i].Usings());
            }

            for (int i = 0; i < generator.fields.Count; i++)
            {
                usings.MergeUnique(generator.fields[i].Usings());
            }

            for (int i = 0; i < generator.properties.Count; i++)
            {
                usings.MergeUnique(generator.properties[i].Usings());
            }

            for (int i = 0; i < generator.methods.Count; i++)
            {
                usings.MergeUnique(generator.methods[i].Usings());
            }

            return(usings);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a nested class generator based on required parameters.
        /// </summary>
        public static ClassGenerator Class(AccessModifier nestedScope, ClassModifier modifier, string name, Type inherits)
        {
            var @class = new ClassGenerator();

            @class.nestedScope = nestedScope;
            @class.modifier    = modifier;
            @class.name        = name;
            @class.inherits    = inherits;
            @class.isNested    = true;
            return(@class);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create a root class generator based on required parameters.
        /// </summary>
        public static ClassGenerator Class(RootAccessModifier scope, ClassModifier modifier, string name, string inherits)
        {
            var @class = new ClassGenerator();

            @class.scope          = scope;
            @class.modifier       = modifier;
            @class.name           = name;
            @class.stringInherits = inherits;
            @class.isNested       = false;
            return(@class);
        }
Ejemplo n.º 4
0
 protected override void BeforeCompiledGeneration()
 {
     if (!(string.IsNullOrEmpty(decorated.@namespace) || string.IsNullOrWhiteSpace(decorated.@namespace)))
     {
         @namespace = NamespaceGenerator.Namespace([email protected]());
     }
     @class = ClassGenerator.Class(
         RootAccessModifier.Public,
         ClassModifier.None,
         NoSpace(decorated.title),
         decorated.inheritance.type);
     guid = decorated.GetGUID();
 }
Ejemplo n.º 5
0
 protected override void BeforeLiveGeneration()
 {
     if (!(string.IsNullOrEmpty(decorated.@namespace) || string.IsNullOrWhiteSpace(decorated.@namespace)))
     {
         @namespace = NamespaceGenerator.Namespace([email protected]().LegalMemberName());
     }
     @class = ClassGenerator.Class(
         RootAccessModifier.Public,
         ClassModifier.None,
         decorated.title.LegalMemberName(),
         decorated.inheritance.type);
     @class.AddAttribute(AttributeGenerator.Attribute <IncludeInSettingsAttribute>().AddParameter(true));
     @class.AddAttribute(AttributeGenerator.Attribute <InspectableAttribute>());
     @class.AddInterface(typeof(IUAClass));
     guid = decorated.GetGUID();
 }
Ejemplo n.º 6
0
        public static string Using(this ClassGenerator generator)
        {
            var usings = new List <string>();

            for (int i = 0; i < generator.fields.Count; i++)
            {
                var @namespace = generator.fields[i].type.Namespace;
                if (!usings.Contains(@namespace))
                {
                    usings.Add(@namespace);
                }
            }

            for (int i = 0; i < generator.properties.Count; i++)
            {
                var @namespace = generator.properties[i].returnType.Namespace;
                if (!usings.Contains(@namespace))
                {
                    usings.Add(@namespace);
                }
            }

            for (int i = 0; i < generator.methods.Count; i++)
            {
                var @namespace = generator.methods[i].returnType.Namespace;
                if (!usings.Contains(@namespace))
                {
                    usings.Add(@namespace);
                }
            }

            var output = string.Empty;

            for (int i = 0; i < usings.Count; i++)
            {
                output += "using " + usings[i] + ";" + (i < usings.Count - 1 ? "\n" : string.Empty);
            }

            return(output);
        }
Ejemplo n.º 7
0
 public StructGenerator AddClass(ClassGenerator generator)
 {
     classes.Add(generator);
     return(this);
 }
Ejemplo n.º 8
0
 public NamespaceGenerator AddClass(ClassGenerator @class)
 {
     classes.Add(@class);
     return(this);
 }