Exemplo n.º 1
0
        public static IJsonSchemaValidator Create(ListTreeNode <JsonValue> value)
        {
            foreach (var x in value.ArrayItems())
            {
                if (x.IsInteger() || x.IsFloat())
                {
                    return(JsonIntEnumValidator.Create(value.ArrayItems()
                                                       .Where(y => y.IsInteger() || y.IsFloat())
                                                       .Select(y => y.GetInt32())
                                                       ));
                }
                else if (x.IsString())
                {
                    return(JsonStringEnumValidator.Create(value.ArrayItems()
                                                          .Where(y => y.IsString())
                                                          .Select(y => y.GetString())
                                                          , EnumSerializationType.AsString
                                                          ));
                }
                else
                {
                }
            }

            throw new NotImplementedException();
        }
Exemplo n.º 2
0
        public static IJsonSchemaValidator Create(IEnumerable <JsonSchema> composition, EnumSerializationType type)
        {
            foreach (var x in composition)
            {
                if (x.Validator is JsonStringEnumValidator)
                {
                    return(JsonStringEnumValidator.Create(composition
                                                          .Select(y => y.Validator as JsonStringEnumValidator)
                                                          .Where(y => y != null)
                                                          .SelectMany(y => y.Values),
                                                          type
                                                          ));
                }
                if (x.Validator is JsonIntEnumValidator)
                {
                    return(JsonIntEnumValidator.Create(composition
                                                       .Select(y => y.Validator as JsonIntEnumValidator)
                                                       .Where(y => y != null)
                                                       .SelectMany(y => y.Values)
                                                       ));
                }
            }

            throw new NotImplementedException();
        }
Exemplo n.º 3
0
        public static IJsonSchemaValidator Create(object[] values, EnumSerializationType type)
        {
            foreach (var x in values)
            {
                if (x is string)
                {
                    return(JsonStringEnumValidator.Create(values.Select(y => (string)y), type));
                }
                if (x is int)
                {
                    return(JsonIntEnumValidator.Create(values.Select(y => (int)y)));
                }
            }

            throw new NotImplementedException();
        }
Exemplo n.º 4
0
        public static IJsonSchemaValidator Create(Type t, EnumSerializationType serializationType, object[] excludes)
        {
            switch (serializationType)
            {
            case EnumSerializationType.AsInt:
                return(JsonIntEnumValidator.Create(GetIntValues(t, excludes)));

            case EnumSerializationType.AsString:
                return(JsonStringEnumValidator.Create(GetStringValues(t, excludes, x => x), serializationType));

            case EnumSerializationType.AsLowerString:
                return(JsonStringEnumValidator.Create(GetStringValues(t, excludes, x => x.ToLower()),
                                                      serializationType));

            case EnumSerializationType.AsUpperString:
                return(JsonStringEnumValidator.Create(GetStringValues(t, excludes, x => x.ToUpper()),
                                                      serializationType));

            default:
                throw new NotImplementedException();
            }
        }