/// <summary>Initializes a new instance of the <see cref="PropertyModel"/> class.</summary>
 /// <param name="classTemplateModel">The class template model.</param>
 /// <param name="property">The property.</param>
 /// <param name="typeResolver">The type resolver.</param>
 /// <param name="settings">The settings.</param>
 public PropertyModel(
     ClassTemplateModel classTemplateModel,
     JsonProperty property,
     CSharpTypeResolver typeResolver,
     CSharpGeneratorSettings settings)
     : base(property, classTemplateModel, typeResolver, settings)
 {
     _property = property;
     _settings = settings;
     _resolver = typeResolver;
 }
Exemplo n.º 2
0
        /// <summary>Initializes a new instance of the <see cref="ClassTemplateModel"/> class.</summary>
        /// <param name="typeName">Name of the type.</param>
        /// <param name="settings">The settings.</param>
        /// <param name="resolver">The resolver.</param>
        /// <param name="schema">The schema.</param>
        /// <param name="rootObject">The root object.</param>
        public ClassTemplateModel(string typeName, CSharpGeneratorSettings settings,
                                  CSharpTypeResolver resolver, JsonSchema4 schema, object rootObject)
            : base(resolver, schema, rootObject)
        {
            _resolver = resolver;
            _schema   = schema;
            _settings = settings;

            ClassName  = typeName;
            Properties = _schema.ActualProperties.Values
                         .Where(p => !p.IsInheritanceDiscriminator)
                         .Select(property => new PropertyModel(this, property, _resolver, _settings))
                         .ToArray();

            if (HasInheritance)
            {
                BaseClass     = new ClassTemplateModel(BaseClassName, settings, resolver, schema.InheritedSchema, rootObject);
                AllProperties = Properties.Concat(BaseClass.AllProperties).ToArray();
            }
            else
            {
                AllProperties = Properties;
            }
        }