Ejemplo n.º 1
0
        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;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static ESystemInfo Parse(byte[] data)
        {
            var systemInfo = new ESystemInfo();

            using (var reader = new BinaryReader(new MemoryStream(data, false)))
            {
                systemInfo.ESystemVersion = new Version(reader.ReadInt16(), reader.ReadInt16());
                reader.ReadInt32(); // Skip Unknown
                systemInfo.Language = reader.ReadInt32();
                systemInfo.EProjectFormatVersion = new Version(reader.ReadInt16(), reader.ReadInt16());
                systemInfo.FileType = reader.ReadInt32();
                reader.ReadInt32(); // Skip Unknown
                systemInfo.ProjectType = reader.ReadInt32();
            }
            return(systemInfo);
        }
Ejemplo n.º 3
0
 public void Save(Stream stream)
 {
     using (var writer = new ProjectFileWriter(stream))
     {
         if (ESystemInfo != null)
         {
             writer.WriteSection(new SectionInfo(ESystemInfo.SectionKey, ESystemInfo.SectionName, false, ESystemInfo.ToBytes()));
         }
         if (ProjectConfigInfo != null)
         {
             writer.WriteSection(new SectionInfo(ProjectConfigInfo.SectionKey, ProjectConfigInfo.SectionName, true, ProjectConfigInfo.ToBytes(Encoding)));
         }
         if (Resource != null)
         {
             writer.WriteSection(new SectionInfo(ResourceSectionInfo.SectionKey, ResourceSectionInfo.SectionName, false, Resource.ToBytes(Encoding)));
         }
         if (Code != null)
         {
             writer.WriteSection(new SectionInfo(CodeSectionInfo.SectionKey, CodeSectionInfo.SectionName, false, Code.ToBytes(Encoding)));
         }
         if (EPackageInfo != null)
         {
             writer.WriteSection(new SectionInfo(EPackageInfo.SectionKey, EPackageInfo.SectionName, true, EPackageInfo.ToBytes(Encoding)));
         }
         if (InitEcSectionInfo != null)
         {
             writer.WriteSection(new SectionInfo(InitEcSectionInfo.SectionKey, InitEcSectionInfo.SectionName, false, InitEcSectionInfo.ToBytes(Encoding)));
         }
         if (EcSection != null)
         {
             writer.WriteSection(new SectionInfo(0x0C007319, "易模块记录段", false, EcSection));
         }
         if (EcSection2 != null)
         {
             writer.WriteSection(new SectionInfo(0x0F007319, "易模块记录段2", true, EcSection2));
         }
         if (AuxiliarySection2 != null)
         {
             writer.WriteSection(new SectionInfo(0x0B007319, "辅助信息段2", true, AuxiliarySection2));
         }
         if (LosableSection != null)
         {
             writer.WriteSection(new SectionInfo(LosableSectionInfo.SectionKey, LosableSectionInfo.SectionName, true, LosableSection.ToBytes(Encoding)));
         }
         if (AuxiliarySection3 != null)
         {
             writer.WriteSection(new SectionInfo(0x10007319, "辅助信息段3", true, AuxiliarySection3));
         }
         if (EditInfoSection2 != null)
         {
             writer.WriteSection(new SectionInfo(0x09007319, "编辑信息段2", true, EditInfoSection2));
         }
         if (AuxiliarySection1 != null)
         {
             writer.WriteSection(new SectionInfo(0x0A007319, "辅助信息段1", true, AuxiliarySection1));
         }
         if (FolderSection != null)
         {
             writer.WriteSection(new SectionInfo(FolderSectionInfo.SectionKey, FolderSectionInfo.SectionName, true, FolderSection.ToBytes(Encoding)));
         }
         OtherSections?.ForEach(x => writer.WriteSection(x));
     }
 }