Пример #1
0
 /// <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="resolver">The resolver.</param>
 /// <param name="settings">The settings.</param>
 public PropertyModel(ClassTemplateModel classTemplateModel, JsonProperty property, CSharpTypeResolver resolver, CSharpGeneratorSettings settings)
     : base(property, classTemplateModel, new CSharpDefaultValueGenerator(resolver, settings), settings)
 {
     _property = property;
     _settings = settings;
     _resolver = resolver;
 }
Пример #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, JsonSchema 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();

            Id = _schema.Id;
            if (schema.InheritedSchema != null)
            {
                BaseClass     = new ClassTemplateModel(BaseClassName, settings, resolver, schema.InheritedSchema, rootObject);
                AllProperties = Properties.Concat(BaseClass.AllProperties).ToArray();
            }
            else
            {
                AllProperties = Properties;
            }
        }
Пример #3
0
 /// <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,
     JsonSchemaProperty property,
     CSharpTypeResolver typeResolver,
     CSharpGeneratorSettings settings)
     : base(property, classTemplateModel, typeResolver, settings)
 {
     _property = property;
     _settings = settings;
     _resolver = typeResolver;
 }
Пример #4
0
        /// <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,
            JsonSchemaProperty property,
            CSharpTypeResolver typeResolver,
            CSharpGeneratorSettings settings)
            : base(property, classTemplateModel, typeResolver, settings)
        {
            _property = property;
            _settings = settings;
            _resolver = typeResolver;

            Id = property.Id;
            if (property.Reference != null && string.IsNullOrEmpty(Id))
            {
                Id = property.Reference.Id;
            }
        }
 /// <summary>Initializes the template with a model.</summary>
 /// <param name="model">The model.</param>
 public void Initialize(object model)
 {
     Model = (ClassTemplateModel) model;
 }