Пример #1
0
 public override bool Equals(object obj)
 {
     if (obj is MonthSpan)
     {
         MonthSpan span = (MonthSpan)obj;
         return(this.TotalMonths == span.TotalMonths);
     }
     return(false);
 }
Пример #2
0
 public static int Compare(MonthSpan t1, MonthSpan t2)
 {
     if (t1.TotalMonths == t2.TotalMonths)
     {
         return(0);
     }
     if (t1.TotalMonths < t2.TotalMonths)
     {
         return(-1);
     }
     return(1);
 }
Пример #3
0
        public static bool TryParse(string s, out MonthSpan val)
        {
            val = MinValue;
            if (s == null)
            {
                return(false);
            }
            s = s.Trim();
            if (string.IsNullOrEmpty(s))
            {
                throw new ArgumentNullException();
            }
            int length = s.LastIndexOf('-');

            switch (length)
            {
            case -1:
            case 0:
                int num4;
                if (!int.TryParse(s, out num4))
                {
                    return(false);
                }
                val = new MonthSpan(num4);
                break;

            default:
                int num2;
                int num3;
                if (!int.TryParse(s.Substring(length + 1), out num2))
                {
                    return(false);
                }
                if (!int.TryParse(s.Substring(0, length), out num3))
                {
                    return(false);
                }
                if ((num2 > 11) || (num2 < 0))
                {
                    return(false);
                }
                if (s[0] == '-')
                {
                    num2 = -num2;
                }
                val = new MonthSpan(num3, num2);
                break;
            }
            return(true);
        }
Пример #4
0
        private void SetParameter(int i, UtlParameter param)
        {
            object o = param.Value;

            if ((o == null) || (o == DBNull.Value))
            {
                this._parameterValues[i] = null;
                return;
            }
            ISessionInterface sessionProxy = this._command.Connection.InnerConnection.SessionProxy;
            SqlType           type         = this._parameterTypes[i];
            int typeCode = type.TypeCode;

            if (typeCode <= 30)
            {
                if (typeCode > 0x15)
                {
                    switch (typeCode)
                    {
                    case 0x19:
                    case 30:
                        goto Label_028B;
                    }
                    this._parameterValues[i] = o;
                    return;
                }
                switch (typeCode)
                {
                case 0x15:
                {
                    DataTable dataTable = o as DataTable;
                    if (dataTable != null)
                    {
                        dataTable.TableName = this._parameterNames[i];
                        if (!((TableType)this._parameterTypes[i]).IsCompatible(dataTable))
                        {
                            goto Label_0379;
                        }
                        goto Label_03AF;
                    }
                    DbDataReader reader = o as DbDataReader;
                    if (reader == null)
                    {
                        goto Label_03AF;
                    }
                    dataTable = new DataTable(this._parameterNames[i]);
                    UtlMetaData.PopulateDataTable(dataTable, reader);
                    if (((TableType)this._parameterTypes[i]).IsCompatible(dataTable))
                    {
                        o = dataTable;
                        goto Label_03AF;
                    }
                    goto Label_0379;
                }
                }
            }
            else
            {
                if (typeCode <= 0x3d)
                {
                    if (typeCode == 40)
                    {
                        this._parameterValues[i] = o;
                        return;
                    }
                    if ((typeCode - 60) > 1)
                    {
                        goto Label_028B;
                    }
                    byte[] data = o as byte[];
                    if (data != null)
                    {
                        o = new BinaryData(data, !this._command.Connection.IsNetConnection);
                    }
                    else
                    {
                        try
                        {
                            if (o is string)
                            {
                                o = type.ConvertToDefaultType(sessionProxy, o);
                                goto Label_03AF;
                            }
                        }
                        catch (CoreException exception1)
                        {
                            UtlException.ThrowError(exception1);
                        }
                        UtlException.ThrowError(Error.GetError(0x15bd));
                    }
                    goto Label_03AF;
                }
                switch (typeCode)
                {
                case 0x5b:
                case 0x5c:
                case 0x5d:
                case 0x5e:
                case 0x5f:
                    try
                    {
                        if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase)))
                        {
                            o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar);
                        }
                        else
                        {
                            o = type.ConvertCSharpToSQL(sessionProxy, o);
                        }
                    }
                    catch (CoreException exception2)
                    {
                        UtlException.ThrowError(exception2);
                    }
                    goto Label_03AF;

                case 0x65:
                case 0x66:
                case 0x6b:
                {
                    MonthSpan span = (MonthSpan)o;
                    o = new IntervalMonthData((long)span.TotalMonths);
                    goto Label_03AF;
                }

                case 0x67:
                case 0x68:
                case 0x69:
                case 0x6a:
                case 0x6c:
                case 0x6d:
                case 110:
                case 0x6f:
                case 0x70:
                case 0x71:
                {
                    TimeSpan span2        = (TimeSpan)o;
                    long     totalSeconds = (long)span2.TotalSeconds;
                    int      nanos        = (int)((span2.TotalSeconds - totalSeconds) * 1000000000.0);
                    o = new IntervalSecondData(totalSeconds, nanos);
                    goto Label_03AF;
                }

                case 0x457:
                    try
                    {
                        if (o.GetType().IsSerializable)
                        {
                            o = new OtherData(o);
                            goto Label_03AF;
                        }
                    }
                    catch (CoreException exception3)
                    {
                        UtlException.ThrowError(exception3);
                    }
                    UtlException.ThrowError(Error.GetError(0x15bd));
                    goto Label_03AF;
                }
            }
            Label_028B :;
            try
            {
                if (((param.UtlType == UtlType.Null) && (o is string)) || (((param.UtlType == UtlType.VarChar) || (param.UtlType == UtlType.Char)) || (param.UtlType == UtlType.VarCharIngnoreCase)))
                {
                    o = type.ConvertToType(sessionProxy, o, SqlType.SqlVarchar);
                }
                else if (param.UtlType == UtlType.Null)
                {
                    o = type.ConvertToDefaultType(sessionProxy, o);
                }
                else
                {
                    SqlType type2 = this.UtlType2SqlType(param.UtlType);
                    o = type.ConvertToType(sessionProxy, o, type2);
                }
            }
            catch (CoreException exception4)
            {
                UtlException.ThrowError(exception4);
            }
            goto Label_03AF;
            Label_0379 :;
            try
            {
                if (param.UtlType == UtlType.Null)
                {
                    o = type.ConvertToDefaultType(sessionProxy, o);
                }
                else
                {
                    SqlType type3 = this.UtlType2SqlType(param.UtlType);
                    o = type.ConvertToType(sessionProxy, o, type3);
                }
            }
            catch (CoreException exception5)
            {
                UtlException.ThrowError(exception5);
            }
Label_03AF:
            this._parameterValues[i] = o;
        }
Пример #5
0
 public MonthSpan(MonthSpan from)
 {
     this._months = from.TotalMonths;
 }
Пример #6
0
 static MonthSpan()
 {
     Zero     = new MonthSpan(0);
     MaxValue = new MonthSpan(0x7fffffff);
     MinValue = new MonthSpan(-2147483648);
 }
Пример #7
0
 public static MonthSpan Negate(MonthSpan t)
 {
     return(new MonthSpan(-t.TotalMonths));
 }
Пример #8
0
 public static MonthSpan Plus(MonthSpan t)
 {
     return(new MonthSpan(t.TotalMonths));
 }
Пример #9
0
 public static MonthSpan Subtract(MonthSpan t1, MonthSpan t2)
 {
     return(t1 - t2);
 }
Пример #10
0
 public static MonthSpan Add(MonthSpan t1, MonthSpan t2)
 {
     return(t1 + t2);
 }