Exemplo n.º 1
0
        /// <summary>
        /// Determine if the property represents a type that is a clr value type as opposed to a reference type.
        /// </summary>
        /// <param name="prop"></param>
        /// <returns></returns>
        public static bool IsClrValueType(this JsonProperty prop)
        {
            //See if the clr type was provided
            Object fullClrType = prop.GetClrFullTypeName();

            if (fullClrType != null)
            {
                //Look for type in all loaded assemblies
                foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    var type = assembly.GetType(fullClrType.ToString());
                    if (type != null)
                    {
                        return(type.IsValueType);
                    }
                }
            }

            //Otherwise go off the schema type
            switch (prop.Type)
            {
            case JsonObjectType.Boolean:
            case JsonObjectType.Integer:
            case JsonObjectType.Number:
                return(true);

            default:
                return(false);
            }
        }