public PM1ElementEPL(BinaryReader reader, PM1Table.Element element, PM1ElementEPLHead headers)
        {
            reader.BaseStream.Position = element.Position;
            using (BinaryReader temp = new BinaryReader(new MemoryStream(reader.ReadBytes(element.Size))))
            {
                var pos = headers.List.Select(x => x.Position - headers.List.First().Position).ToList();
                pos.Add((int)temp.BaseStream.Length);

                for (int i = 0; i < pos.Count - 1; i++)
                {
                    List.Add(temp.ReadBytes(pos[i + 1] - pos[i]));
                }
            }
        }
Пример #2
0
        private void Update()
        {
            foreach (var element in List)
            {
                switch (element.Type)
                {
                case (TypeMap.RMDHead):
                    PM1ElementRMDHead rmdhead = element as PM1ElementRMDHead;
                    PM1ElementRMD     rmd     = List.Find(x => x.Type == TypeMap.RMD) as PM1ElementRMD;
                    for (int i = 0; i < rmdhead.List.Count; i++)
                    {
                        int ret = 0;
                        List.ForEach(x =>
                        {
                            if (x.Type < TypeMap.RMD)
                            {
                                ret += x.Size;
                            }
                        });

                        rmdhead.List[i].Position = rmd.Position(i) + Header.Size + Table.Size + ret;
                        rmdhead.List[i].Size     = (int)rmd.List[i].Length;
                    }
                    break;

                case (TypeMap.EPLHead):
                    PM1ElementEPLHead eplhead = element as PM1ElementEPLHead;
                    PM1ElementEPL     epl     = List.Find(x => x.Type == TypeMap.EPL) as PM1ElementEPL;
                    for (int i = 0; i < eplhead.List.Count; i++)
                    {
                        int ret = 0;
                        List.ForEach(x =>
                        {
                            if (x.Type < TypeMap.EPL)
                            {
                                ret += x.Size;
                            }
                        });

                        eplhead.List[i].Position = epl.Position(i) + Header.Size + Table.Size + ret;
                    }
                    break;

                default:
                    break;
                }
            }
        }