Esempio n. 1
0
        protected override void WriteObjectConstraint(ICSharpFormatter formatter)
        {
            string baseClasses = null;

            if (!DisableBaseClassImplementation)
            {
                baseClasses = string.Join(", ", Extends.Concat(Implements).ToList().ConvertAll(cls => cls.Name));
                if (!string.IsNullOrEmpty(baseClasses))
                {
                    baseClasses = " : " + baseClasses;
                }
                formatter.Write(baseClasses);
            }
            base.WriteObjectConstraint(formatter);
        }
Esempio n. 2
0
 public override void Write(ICSharpFormatter formatter, bool comment = true)
 {
     if (comment)
     {
         Comment?.Write(formatter);
     }
     foreach (var attr in Attributes)
     {
         formatter.WriteLine($"[{attr}]");
     }
     formatter.Write($"{Access.ToString().ToLower()}{(Static ? " static" : "")}{(Readonly ? " readonly" : "")} {Type} {Name}{(InitialValue != null ? $" = {InitialValue}" : "")}");
     if (Closure.ClosureType != ClosureType.Argument)
     {
         formatter.WriteLine(";");
     }
 }
Esempio n. 3
0
 public override void Write(ICSharpFormatter formatter, bool comment = true)
 {
     if (!IsParams)
     {
         if (Optional)
         {
             //InitialValue = Type.DefaultValue;
         }
         base.Write(formatter, comment);
         //if (!IsLastParameter)
         //{
         //    formatter.Write(", ");
         //}
     }
     else
     {
         formatter.Write($"params {Type} {Name}");
     }
 }
 public override void Write(ICSharpFormatter formatter, bool comment = true)
 {
     formatter.Write($"delegate {Return} {Name}");
     base.Write(formatter, comment);
 }
 public override void Write(ICSharpFormatter formatter, bool comment = true)
 {
     formatter.Write($"{Name}");
 }
Esempio n. 6
0
        public override void Write(ICSharpFormatter formatter, bool comment = true)
        {
            if (comment)
            {
                if (Comment != null)
                {
                    Comment.Write(formatter);
                }
            }
            PreObjectWrite(formatter);
            formatter.Write(Definition);
            WriteObjectConstraint(formatter);
            formatter.WriteLine("");
            formatter.WriteLine("{");
            foreach (var m in InnerObjects.Distinct())
            {
                m.Write(formatter, comment);
            }
            List <ICSharpSyntax> generatedFields = new List <ICSharpSyntax>();
            List <string>        generatedNames  = new List <string>();
            int ix = 1;

            foreach (var m in Variables)
            {
                if (!generatedFields.Any(f => f.Equals(m)))
                {
                    string originalName = m.Name;
                    string name         = m.Name;
                    if (generatedNames.Contains(name))
                    {
                        //name += ix++;
                        //m.Attributes.Add($"Name(\"{originalName}\")");
                        //m.Name = name;
                    }
                    m.Write(formatter, comment);
                    generatedNames.Add(name);
                    generatedFields.Add(m);
                }
            }
            ix = 1;
            foreach (var property in Properties)
            {
                if (!generatedFields.Any(f => f.Equals(property)))
                {
                    string originalName = property.Name;
                    string name         = property.Name;
                    if (generatedNames.Contains(name))
                    {
                        //name += ix++;
                        //property.Attributes.Add($"Name(\"{originalName}\")");
                        //property.Name = name;
                    }
                    property.Write(formatter, comment);
                    generatedNames.Add(name);
                    generatedFields.Add(property);
                }
            }
            ix = 1;
            foreach (var m in Methods)
            {
                if (!generatedFields.Any(f => f.Equals(m)))
                {
                    string originalName = m.Name;
                    string name         = m.Name;
                    if (generatedNames.Contains(name) && !m.IsConstructor)
                    {
                        //name += ix++;
                        //m.Attributes.Add($"Name(\"{originalName}\")");
                        //m.Name = name;
                    }
                    m.Write(formatter, comment);
                    generatedNames.Add(name);
                    generatedFields.Add(m);
                }
            }
            WriteObjectFields(formatter, comment);
            formatter.WriteLine("}");
        }
 public override void Write(ICSharpFormatter formatter, bool comment = true)
 {
     formatter.Write($"Func<object>");
 }