Beispiel #1
0
        /// <summary>
        ///   Generates the specified entity.
        /// </summary>
        /// <param name = "entity">The entity.</param>
        public override void Generate(BaseEntity entity)
        {
            ClassEntity classEntity = (ClassEntity)entity;

            // Append License
            this.Writer.WriteLineFormat(0, License);

            // Append usings
            this.AppendStandardNamespaces();

            // Append namespace starter
            this.Writer.WriteLineFormat(0, "namespace Monobjc.{0}", classEntity.Namespace);
            this.Writer.WriteLineFormat(0, "{{");

            // Append static condition if needed
            this.AppendStartCondition(classEntity);

            // Append class starter
            this.Writer.WriteLineFormat(1, "public partial class {0}", classEntity.Name);
            this.Writer.WriteLineFormat(1, "{{");

            // Append constructors
            IEnumerable <MethodEntity> constructors = classEntity.GetConstructors(true, true);

            // Filter out constructors to avoid duplicate
            constructors = constructors.Distinct(new MethodComparer());

            foreach (MethodEntity methodEntity in constructors.Where(e => e.GenerateConstructor))
            {
                this.MethodGenerator.GenerateConstructor(classEntity, methodEntity);
                this.Writer.WriteLine();
            }

            // Append class ender
            this.Writer.WriteLineFormat(1, "}}");

            // Append static condition if needed
            this.AppendEndCondition(classEntity);

            // Append namespace ender
            this.Writer.WriteLineFormat(0, "}}");
        }