예제 #1
0
        public static object[] Parse(object[] format, byte[] body, VariableArrayCountDelegate vaCount, StringLengthDelegate lastStringLength)
        {
            if (format == null)
            {
                return(new object[0]);
            }
            object[] objArray1 = new object[format.Length];
            int      num1      = 0;

            using (MemoryStream stream1 = new MemoryStream(body))
            {
                using (BinaryReader reader1 = new BinaryReader(stream1, new UnicodeEncoding()))
                {
                    XLSDescriptors.ParseHelper(reader1, format, ref objArray1, ref num1, vaCount, lastStringLength);
                }
            }
            object[] objArray2 = new object[num1];
            Array.Copy(objArray1, objArray2, num1);
            return(objArray2);
        }
예제 #2
0
        public static void ParseHelper(BinaryReader br, object[] format, ref object[] loadedArgs, ref int currentArgIndex, VariableArrayCountDelegate vaCount, StringLengthDelegate lastStringLength)
        {
            object[] objArray4 = format;
            for (int num5 = 0; num5 < objArray4.Length; num5++)
            {
                object obj1 = objArray4[num5];
                if (obj1 is string)
                {
                    Stream stream1 = br.BaseStream;
                    stream1.Position += Utilities.GetByteArrLengthFromHexStr((string)obj1);
                }
                else if (obj1 is Type)
                {
                    Type type1 = (Type)obj1;
                    if (type1.IsEnum)
                    {
                        type1 = Enum.GetUnderlyingType(type1);
                    }
                    switch (type1.FullName)
                    {
                    case "System.Int16":
                    {
                        loadedArgs[currentArgIndex] = br.ReadInt16();
                        break;
                    }

                    case "System.UInt16":
                    {
                        loadedArgs[currentArgIndex] = br.ReadUInt16();
                        break;
                    }

                    case "System.UInt32":
                    {
                        loadedArgs[currentArgIndex] = br.ReadUInt32();
                        break;
                    }

                    case "System.UInt64":
                    {
                        loadedArgs[currentArgIndex] = br.ReadUInt64();
                        break;
                    }

                    case "System.Byte":
                    {
                        loadedArgs[currentArgIndex] = br.ReadByte();
                        break;
                    }

                    case "System.Char":
                    {
                        loadedArgs[currentArgIndex] = br.ReadChar();
                        break;
                    }

                    case "System.Single":
                    {
                        loadedArgs[currentArgIndex] = br.ReadSingle();
                        break;
                    }

                    case "System.Double":
                    {
                        loadedArgs[currentArgIndex] = br.ReadDouble();
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelShortString":
                    {
                        loadedArgs[currentArgIndex] = new ExcelShortString(br);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelLongString":
                    {
                        loadedArgs[currentArgIndex] = new ExcelLongString(br);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelStringWithoutLength":
                    {
                        loadedArgs[currentArgIndex] = new ExcelStringWithoutLength(br, lastStringLength(loadedArgs));
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelLongStrings":
                    {
                        int num1 = vaCount(loadedArgs, null, (int)br.BaseStream.Length);
                        loadedArgs[currentArgIndex] = new ExcelLongStrings(br, num1, 0);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.CellRecordHeader":
                    {
                        loadedArgs[currentArgIndex] = new CellRecordHeader(br);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.SheetIndexes":
                    {
                        loadedArgs[currentArgIndex] = new SheetIndexes(br);
                        break;
                    }

                    default:
                    {
                        throw new Exception("Internal error: unsupported type in format.");
                    }
                    }
                    currentArgIndex += 1;
                }
                else
                {
                    if (!(obj1 is object[]))
                    {
                        throw new Exception("Internal error: wrong format in descriptor.");
                    }
                    object[] objArray1 = (object[])obj1;
                    int      num2      = vaCount(loadedArgs, objArray1, (int)br.BaseStream.Length);
                    object[] objArray2 = new object[objArray1.Length * num2];
                    int      num3      = 0;
                    for (int num4 = 0; num4 < num2; num4++)
                    {
                        XLSDescriptors.ParseHelper(br, objArray1, ref objArray2, ref num3, vaCount, lastStringLength);
                    }
                    object[] objArray3 = new object[num3];
                    Array.Copy(objArray2, objArray3, num3);
                    loadedArgs[currentArgIndex] = objArray3;
                    currentArgIndex            += 1;
                }
            }
        }