Ejemplo n.º 1
0
        public static String Write(SourceCodeLanguage language, PropertyBody propertyBody)
        {
            var sc = Create(language);

            sc.Write(propertyBody);
            return(sc.TextWriter.ToString());
        }
Ejemplo n.º 2
0
        public void TestAutomaticProperty()
        {
            var p = new PropertyBody(PropertyBodyType.Get);
            p.IsAutomaticProperty = true;

            Assert.AreEqual("get;" + SourceCodeGenerator.NewLine
                , SourceCodeGenerator.Write(SourceCodeLanguage.CSharp, p));
        }
Ejemplo n.º 3
0
 public Property(TypeName typeName, String name)
 {
     this.Attributes = new List <string>();
     this.Modifier   = new MethodModifier(MethodAccessModifier.Public);
     this.TypeName   = typeName;
     this.Name       = name;
     this.Get        = new PropertyBody(PropertyBodyType.Get);
     this.Set        = new PropertyBody(PropertyBodyType.Set);
 }
Ejemplo n.º 4
0
        public void TestPropertyBasicFeature()
        {
            var p = new PropertyBody(PropertyBodyType.Get);
            p.Body.Add(new CodeBlock(SourceCodeLanguage.CSharp, "return _Age;"));

            var cs = new CSharpSourceCodeGenerator();
            cs.CurrentIndentLevel = 1;
            cs.Write(p);

            Assert.AreEqual("    get" + SourceCodeGenerator.NewLine
                + "    {" + SourceCodeGenerator.NewLine
                + "        return _Age;" + SourceCodeGenerator.NewLine
                + "    }" + SourceCodeGenerator.NewLine
                , cs.ToString());
        }
Ejemplo n.º 5
0
        public override void Write(PropertyBody propertyBody)
        {
            var writer = this.TextWriter;

            this.WriteIndent();
            if (propertyBody.Modifier.HasValue == true)
            {
                this.Write(propertyBody.Modifier.Value);
                writer.Write(" ");
            }
            switch (propertyBody.BodyType)
            {
            case PropertyBodyType.Get: writer.Write("get"); break;

            case PropertyBodyType.Set: writer.Write("set"); break;

            default: throw new InvalidOperationException();
            }
            if (propertyBody.IsAutomaticProperty == true)
            {
                writer.WriteLine(";");
                return;
            }

            writer.WriteLine();
            this.WriteIndent();
            writer.WriteLine("{");
            {
                this.CurrentIndentLevel += 1;
                foreach (var item in propertyBody.Body)
                {
                    this.Write(item);
                }
                this.CurrentIndentLevel -= 1;
            }
            this.WriteIndent();
            writer.WriteLine("}");
        }
 public override void Write(PropertyBody propertyBody)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 7
0
 public abstract void Write(PropertyBody propertyBody);
 public override void Write(PropertyBody propertyBody)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
 public abstract void Write(PropertyBody propertyBody);
Ejemplo n.º 10
0
 public static String Write(SourceCodeLanguage language, PropertyBody propertyBody)
 {
     var sc = Create(language);
     sc.Write(propertyBody);
     return sc.TextWriter.ToString();
 }