Exemplo n.º 1
0
        private SchemaPropertyEntry GenerateForProperty(StructuredProperty propertyInfo)
        {
            var propType = propertyInfo.PropertyType;

            var propEntry = new SchemaPropertyEntry
            {
                Required = propertyInfo.IsRequiredForConstructor,
                Access   = propertyInfo.AccessMode,
                Name     = propertyInfo.Name,
                Type     = propType.GetSchemaTypeName()
            };

            var enumerablePropType = propType as EnumerableTypeSpec;

            if (enumerablePropType != null)
            {
                propEntry.Items = new List <SchemaArrayItem>
                {
                    new SchemaArrayItem
                    {
                        Type   = enumerablePropType.ItemType.GetSchemaTypeName(),
                        Access = propertyInfo.ItemAccessMode
                    }
                };
            }

            var dictPropType = propType as DictionaryTypeSpec;

            if (dictPropType != null && propEntry.Type == "dictionary")
            {
                propEntry.Items = new List <SchemaArrayItem>()
                {
                    new SchemaArrayItem()
                    {
                        Type   = dictPropType.ValueType.GetSchemaTypeName(),
                        Access = propertyInfo.ItemAccessMode
                    }
                };
            }

            return(propEntry);
        }
Exemplo n.º 2
0
        private SchemaPropertyEntry GenerateForProperty(PropertyMapping propertyInfo)
        {
            var propType = propertyInfo.PropertyType;

            var propEntry = new SchemaPropertyEntry
            {
                Required = propertyInfo.IsRequiredForConstructor,
                Access = propertyInfo.AccessMode,
                Name = propertyInfo.Name,
                Type = propType.GetSchemaTypeName()
            };

            var enumerablePropType = propType as EnumerableTypeSpec;
            if (enumerablePropType != null)
            {
                propEntry.Items = new List<SchemaArrayItem>
                {
                    new SchemaArrayItem
                    {
                        Type = enumerablePropType.ItemType.GetSchemaTypeName(),
                        Access = propertyInfo.ItemAccessMode
                    }
                };
            }

            var dictPropType = propType as DictionaryTypeSpec;
            if (dictPropType != null && propEntry.Type == "dictionary")
            {
                propEntry.Items = new List<SchemaArrayItem>()
                {
                    new SchemaArrayItem()
                    {
                        Type = dictPropType.ValueType.GetSchemaTypeName(),
                        Access = propertyInfo.ItemAccessMode
                    }
                };
            }

            return propEntry;
        }