Beispiel #1
0
        /// <summary>
        /// Primitive Type of member or Collection of primitive types .
        /// </summary>
        /// <param name="tmember"></param>
        /// <param name="jsValue"></param>
        /// <returns></returns>
        public bool GetPrimitiveEmptyValue(Type tmember, out string jsValue)
        {
            jsValue = "";

            if (tmember == typeof(string))
            {
                jsValue = GetScriptTypeInfo.TString;
            }
            else if (TypeHelper.IsNumber(tmember) || TypeHelper.IsEnum(tmember))
            {
                jsValue = GetScriptTypeInfo.TNumber;
            }
            else if (TypeHelper.IsDateTime(tmember))
            {
                jsValue = GetScriptTypeInfo.TDatetime;
            }
            else if (TypeHelper.IsBoolean(tmember))
            {
                jsValue = GetScriptTypeInfo.TBoolean;
            }
            else if (TypeHelper.IsCollection(tmember))
            {
                //-- member is collection
                Type telement;
                if (TypeHelper.GetElementTypeOfCollection(tmember, out telement))
                {
                    if (this.GetPrimitiveEmptyValue(telement, out jsValue) == false)
                    {
                        jsValue = "";
                    }
                    else
                    {
                        jsValue = GetScriptTypeInfo.TArrayFactoryFunctionDefinitionCall(jsValue);
                    }
                }
                else
                {
                    jsValue = GetScriptTypeInfo.TArray;
                }
            }

            return(string.IsNullOrWhiteSpace(jsValue) == false);
        }
Beispiel #2
0
        /// <summary>
        /// Primitive Type of member or Collection of primitive types .
        /// </summary>
        /// <param name="tmember"></param>
        /// <returns></returns>
        static public EnumType GetCategoryType(Type tmember)
        {
            EnumType result = EnumType.tcomplex;

            if (tmember == typeof(string))
            {
                result = EnumType.tstring;
            }
            else if (TypeHelper.IsNumber(tmember))
            {
                result = EnumType.tnumber;
            }
            else if (TypeHelper.IsEnum(tmember))
            {
                result = EnumType.tenum;
            }
            else if (TypeHelper.IsDateTime(tmember))
            {
                result = EnumType.tdatetime;
            }
            else if (TypeHelper.IsBoolean(tmember))
            {
                result = EnumType.tboolean;
            }
            else if (TypeHelper.IsCollection(tmember))
            {
                //-- member is collection
                Type telement;
                if (TypeHelper.GetElementTypeOfCollection(tmember, out telement))
                {
                    result = ScriptHelper.GetCategoryType(telement);
                }
                else
                {
                    result = EnumType.tpurecollection;
                }
            }

            return(result);
        }