Esempio n. 1
0
        private Schema CreateDictionarySchema(JsonDictionaryContract dictionaryContract)
        {
            Type type1 = dictionaryContract.get_DictionaryKeyType();

            if ((object)type1 == null)
            {
                type1 = typeof(object);
            }
            Type enumType = type1;
            Type type2    = dictionaryContract.get_DictionaryValueType();

            if ((object)type2 == null)
            {
                type2 = typeof(object);
            }
            Type valueType = type2;

            if (enumType.IsEnum)
            {
                return new Schema()
                       {
                           type       = "object",
                           properties = (IDictionary <string, Schema>)((IEnumerable <string>)Enum.GetNames(enumType)).ToDictionary <string, string, Schema>((Func <string, string>)(name => dictionaryContract.get_DictionaryKeyResolver()(name)), (Func <string, Schema>)(name => this.CreateInlineSchema(valueType)))
                       }
            }
            ;
            return(new Schema()
            {
                type = "object",
                additionalProperties = this.CreateInlineSchema(valueType)
            });
        }