private IEnumerable <string> GenerateSetterBody()
        {
            if (setterBody.Count == 0)
            {
                return new List <string> {
                           "{ set; }"
                }
            }
            ;
            if (getterBody.Count == 1)
            {
                return new List <string> {
                           "set { " + setterBody.First() + " }"
                }
            }
            ;

            var lines = new IndentedList();

            lines.Add("set");
            lines.Add("{");
            lines.AddLevel();
            lines.AddRange(setterBody);
            lines.SubtractLevel();
            lines.Add("}");

            return(lines);
        }
    }
}
        public IEnumerable<string> Generate()
        {
            var lines = new IndentedList();

            foreach (var t in namespaces)
            {
                lines.Add(t);
            }

            if (namespaces.Count > 0)
                lines.Add(string.Empty);

            if (HasNamespace)
            {
                lines.Add($"namespace {@namespace}");
                lines.Add("{");
                lines.AddLevel();
            }

            for (int i = 0; i < classes.Count; i++)
            {
                var @class = classes[i];

                lines.AddRange(@class.Generate());
            }


            if (HasNamespace)
            {
                lines.SubtractLevel();
                lines.Add("}");
            }

            return lines;
        }
示例#3
0
        private IEnumerable <string> GenerateGetterBody()
        {
            if (getterBody.Count == 0)
            {
                return new List <string> {
                           "{ get; }"
                }
            }
            ;
            if (getterBody.Count == 1)
            {
                return new List <string> {
                           $"get {{ {getterBody.First()} }}"
                }
            }
            ;

            IndentedList lines = new IndentedList();

            lines.Add("get");
            lines.Add("{");
            lines.AddLevel();
            lines.AddRange(getterBody);
            lines.SubtractLevel();
            lines.Add("}");

            return(lines);
        }
示例#4
0
        public string[] Generate()
        {
            IndentedList lines = new IndentedList();

            lines.Add(GenerateStub());

            lines.Add("{");

            lines.AddLevel();

            foreach (Class @class in classes)
            {
                lines.AddRange(@class.Generate());
            }

            if (classes.Count > 0 && (fields.Count > 0 || properties.Count > 0))
            {
                lines.Add(string.Empty);
            }

            foreach (Field field in fields)
            {
                lines.Add(field.Generate());
            }

            if ((classes.Count > 0 || fields.Count > 0) && properties.Count > 0)
            {
                lines.Add(string.Empty);
            }

            for (int i = 0; i < properties.Count; i++)
            {
                Property property = properties[i];
                lines.AddRange(property.Generate());

                if (i < properties.Count - 1)
                {
                    lines.Add(string.Empty);
                }
            }

            lines.SubtractLevel();

            lines.Add("}");

            return(lines.ToArray());
        }
        public IEnumerable <string> Generate()
        {
            var lines = new IndentedList();

            lines.Add(GenerateIdentifier());

            lines.Add("{");
            lines.AddLevel();

            if (CanRead)
            {
                lines.AddRange(GenerateGetterBody());
            }

            if (CanWrite)
            {
                lines.AddRange(GenerateSetterBody());
            }

            lines.SubtractLevel();
            lines.Add("}");

            return(lines);
        }