public void Load(Stream stream, ProjectFileReader.OnInputPassword inputPassword = null) { ESystemInfo = null; ProjectConfigInfo = null; Resource = null; Code = null; EPackageInfo = null; InitEcSectionInfo = null; LosableSection = null; FolderSection = null; EcSection = EcSection2 = AuxiliarySection2 = AuxiliarySection3 = EditInfoSection2 = AuxiliarySection1 = null; OtherSections = new List <SectionInfo>(); using (var reader = new ProjectFileReader(stream, inputPassword)) { var processor = new Dictionary <int, Action <SectionInfo> > { { ESystemInfo.SectionKey, x => ESystemInfo = ESystemInfo.Parse(x.Data) }, { ProjectConfigInfo.SectionKey, x => ProjectConfigInfo = ProjectConfigInfo.Parse(x.Data, Encoding) }, { ResourceSectionInfo.SectionKey, x => Resource = ResourceSectionInfo.Parse(x.Data, Encoding) }, { CodeSectionInfo.SectionKey, x => Code = CodeSectionInfo.Parse(x.Data, Encoding, reader.CryptEc) }, { EPackageInfo.SectionKey, x => EPackageInfo = EPackageInfo.Parse(x.Data, Encoding) }, { InitEcSectionInfo.SectionKey, x => InitEcSectionInfo = InitEcSectionInfo.Parse(x.Data, Encoding) }, { 0x0C007319, x => EcSection = x.Data }, { 0x0F007319, x => EcSection2 = x.Data }, { 0x0B007319, x => AuxiliarySection2 = x.Data }, { LosableSectionInfo.SectionKey, x => LosableSection = LosableSectionInfo.Parse(x.Data, Encoding) }, { 0x10007319, x => AuxiliarySection3 = x.Data }, { 0x09007319, x => EditInfoSection2 = x.Data }, { 0x0A007319, x => AuxiliarySection1 = x.Data }, { FolderSectionInfo.SectionKey, x => FolderSection = FolderSectionInfo.Parse(x.Data, Encoding) } }; while (!reader.IsFinish) { var section = reader.ReadSection(); switch (section.Key) { case int key when processor.ContainsKey(key): processor[key](section); break; default: OtherSections.Add(section); break; } } } }
public static FolderSectionInfo Parse(byte[] data, Encoding encoding) { var folderSectionInfo = new FolderSectionInfo(); using (var reader = new BinaryReader(new MemoryStream(data, false), encoding)) { folderSectionInfo.allocatedKey = reader.ReadInt32(); while (!(reader.BaseStream.Position == reader.BaseStream.Length)) { bool expand = reader.ReadInt32() != 0; folderSectionInfo.Folders.Add(new CodeFolderInfo(reader.ReadInt32()) { Expand = expand, ParentKey = reader.ReadInt32(), Name = reader.ReadStringWithLengthPrefix(encoding), Children = reader.ReadInt32sWithFixedLength(reader.ReadInt32() / 4) }); } } return(folderSectionInfo); }