Ejemplo n.º 1
0
        public IMust CreateSchemaNodeFrom(Type type)
        {
            if (type != typeof(string))
            {
                return(null);
            }
            var schema = new MustHaveType <ContentText>(new ContentSchemaRule[] { });

            return(schema);
        }
Ejemplo n.º 2
0
        public IMust CreateSchemaNodeFrom(Type type)
        {
            if (!(type == typeof(bool) || type == typeof(bool?)))
            {
                return(null);
            }
            var schema = new MustHaveType <ContentBoolean>(new ContentSchemaRule[] { });

            return((type == typeof(bool))
                ? (IMust)schema
                : new MustBeOneOf(new IMust[]
            {
                schema,
                new MustBeNull()
            }));
        }
Ejemplo n.º 3
0
        public IMust CreateSchemaNodeFrom(Type t)
        {
            var nullable = t.IsNullableType();

            t = nullable ? Nullable.GetUnderlyingType(t) : t;
            if (!_numberTypes.Any(n => n.IsAssignableFrom(t)))
            {
                return(null);
            }
            var schema = new MustHaveType <ContentNumber>(new ContentSchemaRule[] { });

            return(!nullable
                ? (IMust)schema
                : new MustBeOneOf(new IMust[]
            {
                schema,
                new MustBeNull()
            }));
        }
Ejemplo n.º 4
0
        //public IContentNode CreateFrom(object from)
        //{
        //    var t = from.GetType();
        //    t = t.IsNullableType() ? Nullable.GetUnderlyingType(t) : t;

        //    if (!typeof(Enum).IsAssignableFrom(t)) return null;

        //    return new ContentEntity(GetEntityName(t), from.ToString());
        //}

        public IMust CreateSchemaNodeFrom(Type t)
        {
            var nullable = t.IsNullableType();

            t = nullable ? Nullable.GetUnderlyingType(t) : t;
            if (!typeof(Enum).IsAssignableFrom(t))
            {
                return(null);
            }

            //var schema = new MustBeEntityWithName(GetEntityName(t), new ContentSchemaRule[] { });
            var schema = new MustHaveType <ContentNumber>(new ContentSchemaRule[] { });

            return(!nullable
                ? (IMust)schema
                : new MustBeOneOf(new IMust[]
            {
                schema,
                new MustBeNull()
            }));
        }