Esempio n. 1
0
        internal static ServerType GetServerType(Type propertyType)
        {
            var st = new ServerType { RuntimeType = propertyType };

            if (propertyType == typeof(string))
            {
                st.IsNullable = true;
                st.Name = SupportedServerType.String;
            }
            else if (propertyType == typeof(int)) { st.Name = SupportedServerType.Int32; }
            else if (propertyType.IsEnum) { st.Name = SupportedServerType.Enum; }
            else if (propertyType == typeof(double)) { st.Name = SupportedServerType.Double; }
            else if (propertyType == typeof(bool)) { st.Name = SupportedServerType.Boolean; }
            else if (propertyType == typeof(DateTime)) { st.Name = SupportedServerType.DateTime; }
            else if (propertyType == typeof(Guid)) { st.Name = SupportedServerType.Guid; }
            else if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
            {
                var innerType = propertyType.GetGenericArguments()[0];
                st = GetServerType(innerType);
                st.IsNullable = true;
                return st;
            }
            else
            {
                st.Name = SupportedServerType.Unknown;
                return st;
            }

            st.JSType = GetClientType(st);

            return st;
        }
Esempio n. 2
0
        internal static string GetClientFieldTypeName(ServerType type)
        {
            if (type.JSType == JavascriptType.Reference)
            {
                return "string";
            }

            return type.JSType.ToString().ToLower();
        }
Esempio n. 3
0
 internal static string GetColumnXType(ServerType type)
 {
     switch (type.JSType)
     {
         case JavascriptType.Int:
         case JavascriptType.Float:
             return "numbercolumn";
         case JavascriptType.Date:
             return "datecolumn";
         case JavascriptType.Boolean:
             return "booleancolumn";
         case JavascriptType.String:
         case JavascriptType.Reference:
         default:
             return null;
     }
 }
Esempio n. 4
0
 private static JavascriptType GetClientType(ServerType type)
 {
     switch (type.Name)
     {
         case SupportedServerType.String:
         case SupportedServerType.Enum:
             return JavascriptType.String;
         case SupportedServerType.Int32:
             return JavascriptType.Int;
         case SupportedServerType.Double:
             return JavascriptType.Float;
         case SupportedServerType.Boolean:
             return JavascriptType.Boolean;
         case SupportedServerType.DateTime:
             return JavascriptType.Date;
         case SupportedServerType.Guid:
             return JavascriptType.Reference;
         default:
             throw new NotSupportedException();
     }
 }