Exemplo n.º 1
0
        public static string Partition(long Number, long Start, long Stop, long Interval)
        {
            string buffer = null;
            long   num    = 0;
            bool   flag   = false;
            bool   flag2  = false;
            long   num2;
            long   num3 = 0;

            if (Start < 0L)
            {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", new string[] { "Start" }));
            }
            if (Stop <= Start)
            {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", new string[] { "Stop" }));
            }
            if (Interval < 1L)
            {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValue1", new string[] { "Interval" }));
            }
            if (Number < Start)
            {
                num3 = Start - 1L;
                flag = true;
            }
            else if (Number > Stop)
            {
                num   = Stop + 1L;
                flag2 = true;
            }
            else if (Interval == 1L)
            {
                num  = Number;
                num3 = Number;
            }
            else
            {
                num  = (((Number - Start) / Interval) * Interval) + Start;
                num3 = (num + Interval) - 1L;
                if (num3 > Stop)
                {
                    num3 = Stop;
                }
                if (num < Start)
                {
                    num = Start;
                }
            }
            string expression = Conversions.ToString((long)(Stop + 1L));
            string str3       = Conversions.ToString((long)(Start - 1L));

            if (Strings.Len(expression) > Strings.Len(str3))
            {
                num2 = Strings.Len(expression);
            }
            else
            {
                num2 = Strings.Len(str3);
            }
            if (flag)
            {
                expression = Conversions.ToString(num3);
                if (num2 < Strings.Len(expression))
                {
                    num2 = Strings.Len(expression);
                }
            }
            if (flag)
            {
                InsertSpaces(ref buffer, num2);
            }
            else
            {
                InsertNumber(ref buffer, num, num2);
            }
            buffer = buffer + ":";
            if (flag2)
            {
                InsertSpaces(ref buffer, num2);
                return(buffer);
            }
            InsertNumber(ref buffer, num3, num2);
            return(buffer);
        }
        internal static object ParseInputField(object Value, VariantType vtInput)
        {
            int    num2;
            char   ch;
            int    num6;
            string str = Conversions.ToString(Value);

            if ((vtInput == VariantType.Empty) && ((Value == null) || (Strings.Len(Conversions.ToString(Value)) == 0)))
            {
                return(null);
            }
            ProjectData projectData = ProjectData.GetProjectData();

            byte[] numprsPtr  = projectData.m_numprsPtr;
            byte[] digitArray = projectData.m_DigitArray;
            Array.Copy(BitConverter.GetBytes(Convert.ToInt32(digitArray.Length)), 0, numprsPtr, 0, 4);
            Array.Copy(BitConverter.GetBytes(Convert.ToInt32(0x954)), 0, numprsPtr, 4, 4);
            if (UnsafeNativeMethods.VarParseNumFromStr(str, 0x409, -2147483648, numprsPtr, digitArray) < 0)
            {
                if (vtInput != VariantType.Empty)
                {
                    return(0);
                }
                return(str);
            }
            int num3 = BitConverter.ToInt32(numprsPtr, 8);
            int num  = BitConverter.ToInt32(numprsPtr, 12);
            int num4 = BitConverter.ToInt32(numprsPtr, 0x10);
            int num5 = BitConverter.ToInt32(numprsPtr, 20);

            if (num < str.Length)
            {
                ch = str[num];
            }
            char ch2 = ch;

            switch (ch2)
            {
            case '%':
                num6 = 2;
                num2 = 0;
                break;

            case '&':
                num6 = 3;
                num2 = 0;
                break;

            case '@':
                num6 = 14;
                num2 = 4;
                break;

            case '!':
                if (vtInput == VariantType.Double)
                {
                    num6 = 5;
                }
                else
                {
                    num6 = 4;
                }
                num2 = 0x7fffffff;
                break;

            default:
                if (ch2 == '#')
                {
                    num6 = 5;
                    num2 = 0x7fffffff;
                }
                else
                {
                    if (vtInput == VariantType.Empty)
                    {
                        int dwVtBits = 0x402c;
                        if ((num3 & 0x800) != 0)
                        {
                            dwVtBits = 0x20;
                        }
                        return(UnsafeNativeMethods.VarNumFromParseNum(numprsPtr, digitArray, dwVtBits));
                    }
                    if (num4 == 0)
                    {
                        return(UnsafeNativeMethods.VarNumFromParseNum(numprsPtr, digitArray, ShiftVTBits((int)vtInput)));
                    }
                    Value = UnsafeNativeMethods.VarNumFromParseNum(numprsPtr, digitArray, 8);
                    int num8 = Conversions.ToInteger(Value);
                    if ((num8 & -65536) == 0)
                    {
                        num8 = (short)num8;
                    }
                    UnsafeNativeMethods.VariantChangeType(out Value, ref Value, 0, (short)vtInput);
                    return(Value);
                }
                break;
            }
            if ((0 - num5) > num2)
            {
                throw ExceptionUtils.VbMakeException(13);
            }
            Value = UnsafeNativeMethods.VarNumFromParseNum(numprsPtr, digitArray, ShiftVTBits(num6));
            if (vtInput != VariantType.Empty)
            {
                UnsafeNativeMethods.VariantChangeType(out Value, ref Value, 0, (short)vtInput);
            }
            return(Value);
        }
        public static object GetObject(string PathName = null, string Class = null)
        {
            IPersistFile activeObject;

            if (Strings.Len(Class) == 0)
            {
                try
                {
                    return(Marshal.BindToMoniker(PathName));
                }
                catch (StackOverflowException exception)
                {
                    throw exception;
                }
                catch (OutOfMemoryException exception2)
                {
                    throw exception2;
                }
                catch (ThreadAbortException exception3)
                {
                    throw exception3;
                }
                catch (Exception)
                {
                    throw ExceptionUtils.VbMakeException(0x1ad);
                }
            }
            if (PathName == null)
            {
                try
                {
                    return(Marshal.GetActiveObject(Class));
                }
                catch (StackOverflowException exception4)
                {
                    throw exception4;
                }
                catch (OutOfMemoryException exception5)
                {
                    throw exception5;
                }
                catch (ThreadAbortException exception6)
                {
                    throw exception6;
                }
                catch (Exception)
                {
                    throw ExceptionUtils.VbMakeException(0x1ad);
                }
            }
            if (Strings.Len(PathName) == 0)
            {
                try
                {
                    return(Activator.CreateInstance(System.Type.GetTypeFromProgID(Class)));
                }
                catch (StackOverflowException exception7)
                {
                    throw exception7;
                }
                catch (OutOfMemoryException exception8)
                {
                    throw exception8;
                }
                catch (ThreadAbortException exception9)
                {
                    throw exception9;
                }
                catch (Exception)
                {
                    throw ExceptionUtils.VbMakeException(0x1ad);
                }
            }
            try
            {
                activeObject = (IPersistFile)Marshal.GetActiveObject(Class);
            }
            catch (StackOverflowException exception10)
            {
                throw exception10;
            }
            catch (OutOfMemoryException exception11)
            {
                throw exception11;
            }
            catch (ThreadAbortException exception12)
            {
                throw exception12;
            }
            catch (Exception)
            {
                throw ExceptionUtils.VbMakeException(0x1b0);
            }
            try
            {
                activeObject.Load(PathName, 0);
            }
            catch (StackOverflowException exception13)
            {
                throw exception13;
            }
            catch (OutOfMemoryException exception14)
            {
                throw exception14;
            }
            catch (ThreadAbortException exception15)
            {
                throw exception15;
            }
            catch (Exception)
            {
                throw ExceptionUtils.VbMakeException(0x1ad);
            }
            return(activeObject);
        }