예제 #1
0
        public override int Read(BinaryReader reader)
        {
            int num = base.Read(reader);

            while (reader.BaseStream.Position < reader.BaseStream.Length)
            {
                MsoBaseRecord item = ImageRecordsFactory.CreateFromReader(reader);
                this.Add(item);
            }
            return(num);
        }
예제 #2
0
파일: XLSDescriptors.cs 프로젝트: ikvm/test
        public static void ParseHelper(BinaryReader br, object[] format, ref object[] loadedArgs, ref int currentArgIndex, VariableArrayCountDelegate vaCount, StringLengthDelegate lastStringLength)
        {
            foreach (object obj2 in format)
            {
                if (obj2 is string)
                {
                    Stream baseStream = br.BaseStream;
                    baseStream.Position += Utilities.GetByteArrLengthFromHexStr((string)obj2);
                    continue;
                }
                if (obj2 is Type)
                {
                    Type enumType = (Type)obj2;
                    if (enumType.IsEnum)
                    {
                        enumType = Enum.GetUnderlyingType(enumType);
                    }
                    switch (enumType.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 "ebexcel.ExcelShortString":
                        loadedArgs[currentArgIndex] = new ExcelShortString(br);
                        break;

                    case "ebexcel.ExcelLongString":
                        loadedArgs[currentArgIndex] = new ExcelLongString(br);
                        break;

                    case "ebexcel.ExcelStringWithoutLength":
                        loadedArgs[currentArgIndex] = new ExcelStringWithoutLength(br, lastStringLength(loadedArgs));
                        break;

                    case "ebexcel.ExcelLongStrings":
                    {
                        int remainingSize = vaCount(loadedArgs, null, (int)br.BaseStream.Length);
                        loadedArgs[currentArgIndex] = new ExcelLongStrings(br, remainingSize, null);
                        break;
                    }

                    case "ebexcel.CellRecordHeader":
                        loadedArgs[currentArgIndex] = new CellRecordHeader(br);
                        break;

                    case "ebexcel.SheetIndexes":
                        loadedArgs[currentArgIndex] = new SheetIndexes(br);
                        break;

                    case "ebexcel.MsoBaseRecord":
                        loadedArgs[currentArgIndex] = ImageRecordsFactory.CreateFromReader(br);
                        break;

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