public void Apply(DataType model, DataTypeRegistry dataTypeRegistry, Type type)
        {
            var typeNode = _navigator.SelectSingleNode(String.Format(TypeExpression, type.FullName));
            model.Description = GetChildValueOrDefault(typeNode, SummaryExpression);

            foreach (var property in model.Properties)
            {
                var propertyNode = _navigator.SelectSingleNode(String.Format(PropertyExpression, type.FullName, property.Key));
                property.Value.Description = GetChildValueOrDefault(propertyNode, SummaryExpression);
            }
        }
예제 #2
0
        public void Apply(DataType model, DataTypeRegistry dataTypeRegistry, Type type)
        {
            var camelCasedProperties = new Dictionary<string, DataType>();
            foreach (var entry in model.Properties)
            {
                var key = entry.Key;
                camelCasedProperties[Char.ToLower(key[0]) + key.Substring(1)] = entry.Value;
            }

            model.Properties = camelCasedProperties;
        }
예제 #3
0
 private static void ModelProperty(DataType model, string name, Action<DataType> applyAssertions)
 {
     var modelProperty = model.Properties[name];
     applyAssertions(modelProperty);
 }
예제 #4
0
        private DataType CreateComplexDataType(Type type, Queue<Type> deferredTypes)
        {
            var propInfos = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)
                .Where(propInfo => !propInfo.GetIndexParameters().Any())    // Ignore indexer properties
                .ToArray();

            var properties = propInfos
                .ToDictionary(propInfo => propInfo.Name, propInfo => GetOrRegister(propInfo.PropertyType, true, deferredTypes));

            var required = propInfos.Where(propInfo => Attribute.IsDefined(propInfo, typeof (RequiredAttribute)))
                .Select(propInfo => propInfo.Name)
                .ToList();

            var polymorphicType = PolymorphicTypeFor(type);
            var subDataTypes = polymorphicType.SubTypes
                .Select(subType => GetOrRegister(subType.Type, true, deferredTypes))
                .Select(subDataType => subDataType.Ref)
                .ToList();

            var dataType = new DataType
            {
                Id = UniqueIdFor(type),
                Type = "object",
                Properties = properties,
                Required = required,
                SubTypes = subDataTypes,
                Discriminator = polymorphicType.Discriminator
            };

            foreach (var filter in _modelFilters)
            {
                filter.Apply(dataType, this, type);
            }

            return dataType;
        }