示例#1
0
        internal static MetaExpression FromRoute(Type type, Implementations? implementations, PropertyRoute pr)
        {
            if (pr == null)
                return new MetaExpression(type.UnNullify().CleanType(), new DirtyMeta(implementations, new Meta[0]));

            return new MetaExpression(type.UnNullify().CleanType(), new CleanMeta(implementations, new[] { pr }));
        }
示例#2
0
        public static FilterType? TryGetFilterType(Type type)
        {
            var uType = type.UnNullify();

            if (uType == typeof(Guid))
                return FilterType.Guid;

            if (uType.IsEnum)
                return FilterType.Enum;

            switch (Type.GetTypeCode(uType))
            {
                case TypeCode.Boolean:
                    return FilterType.Boolean;
                case TypeCode.Double:
                case TypeCode.Decimal:
                case TypeCode.Single:
                    return FilterType.Decimal;
                case TypeCode.Byte:
                case TypeCode.SByte:
                case TypeCode.Int16:
                case TypeCode.Int32:
                case TypeCode.Int64:
                case TypeCode.UInt16:
                case TypeCode.UInt32:
                case TypeCode.UInt64:
                    return FilterType.Integer;
                case TypeCode.DateTime:
                    return FilterType.DateTime;

                case TypeCode.Char:
                case TypeCode.String:
                    return FilterType.String;
                case TypeCode.Object:
                    if (type.IsLite())
                        return FilterType.Lite;

                    if (type.IsIIdentifiable())
                        return FilterType.Lite;

                    if (type.IsEmbeddedEntity())
                        return FilterType.Embedded;

                    goto default;
                default:
                    return null;

            }
        }
示例#3
0
 bool IsBasicType(Type type)
 {
     var unType = type.UnNullify();
     return CSharpRenderer.IsBasicType(unType) || unType == typeof(DateTime);
 }
 public override bool CanConvert(Type objectType)
 {
     return typeof(TimeSpan).IsAssignableFrom(objectType.UnNullify());
 }
示例#5
0
        internal static Type UnwrapPrimaryKey(Type type, PropertyRoute[] routes)
        {
            if (type.UnNullify() == typeof(PrimaryKey))
            {
                return routes.Select(r => PrimaryKey.Type(r.RootType)).Distinct().SingleEx().Nullify();
            }

            return type;
        }
        protected virtual bool IsSimpleValueType(Type type)
        {
            var t = CurrentSchema.Settings.GetSqlDbTypePair(type.UnNullify());

            return t != null && t.UserDefinedTypeName == null && t.SqlDbType != SqlDbType.Image && t.SqlDbType != SqlDbType.VarBinary;
        }
示例#7
0
        static double GetColumnWidth(Type type)
        { 
            type = type.UnNullify();

            if (type == typeof(DateTime))
                return 20;
            if (type == typeof(string))
                return 50;
            if (type.IsLite())
                return 50;

            return 10;
        }
示例#8
0
        public virtual ValueLineType GetDefaultValueLineType(Type type)
        {
            type = type.UnNullify();

            if (type.IsEnum)
                return ValueLineType.Enum;
            else if (type == typeof(ColorEntity))
                return ValueLineType.Color;
            else if (type == typeof(TimeSpan))
                return ValueLineType.TimeSpan;
            else
            {
                switch (Type.GetTypeCode(type))
                {
                    case TypeCode.Boolean:
                        return ValueLineType.Boolean;
                    case TypeCode.Double:
                    case TypeCode.Decimal:
                    case TypeCode.Single:
                    case TypeCode.Byte:
                    case TypeCode.SByte:
                    case TypeCode.Int16:
                    case TypeCode.Int32:
                    case TypeCode.Int64:
                    case TypeCode.UInt16:
                    case TypeCode.UInt32:
                    case TypeCode.UInt64:
                        return ValueLineType.Number;
                    case TypeCode.DateTime:
                        return ValueLineType.DateTime;
                    case TypeCode.Empty:
                    case TypeCode.Object:
                    case TypeCode.Char:
                    case TypeCode.String:
                    default:
                        return ValueLineType.String;
                }        
            }
        }
示例#9
0
        protected virtual bool IsValue(Type type)
        {
            type = type.UnNullify();

            if (type.IsEnum || type == typeof(TimeSpan) || type == typeof(ColorEntity))
                return true;

            TypeCode tc = Type.GetTypeCode(type);

            return tc != TypeCode.DBNull &&
                tc != TypeCode.Empty &&
                tc != TypeCode.Object;
        }
示例#10
0
        public DbParameter CreateParameter(string parameterName, object value, Type type)
        {
            var pair = Schema.Current.Settings.GetSqlDbTypePair(type.UnNullify());

            return CreateParameter(parameterName, pair.SqlDbType, pair.UserDefinedTypeName, type == null || type.IsByRef || type.IsNullable(), value);
        }
        public static object Convert(string value, Type type)
        {
            if (type.UnNullify() == typeof(bool))
            {
                if (!value.HasText())
                    return null;

                string[] vals = ((string)value).Split(',');
                return (vals[0] == "true" || vals[0] == "True");
            }
            if (type.UnNullify() == typeof(DateTime))
            {
                if (!value.HasText())
                    return null;

                return DateTime.Parse(value).FromUserInterface();
            }
            if (type.UnNullify().IsLite())
                return Database.FillToString(Lite.Parse(value));

            return ReflectionTools.Parse(value, type);
        }
示例#12
0
        public static void SetCellValue(this Cell cell, object value, Type type)
        {
            if(type == typeof(string))
            {
                cell.RemoveAllChildren();
                cell.Append(new InlineString(new Text((string)value)));
                cell.DataType = CellValues.InlineString;
            }
            else
            {
                string excelValue = value == null ? "" :
                            type.UnNullify() == typeof(DateTime) ? ExcelExtensions.ToExcelDate(((DateTime)value)) :
                            type.UnNullify() == typeof(bool) ? (((bool)value) ? "TRUE": "FALSE") :
                            IsNumber(type.UnNullify()) ? ExcelExtensions.ToExcelNumber(Convert.ToDecimal(value)) :
                            value.ToString();

                cell.CellValue = new CellValue(excelValue);
            }
        }
        private static string TypeScriptType(Type type)
        {
            type = CleanMList(type);

            type = type.UnNullify().CleanType();

            return BasicType(type) ?? ReflectionServer.GetTypeName(type) ?? "any";
        }