Пример #1
0
        private void TestReadWrite(string file, out DexReader dexreader, out DexWriter dexwriter)
        {
            TestContext.WriteLine("Testing {0}", file);

            var dex = new Dex();
            dexreader = new DexReader(dex);

            using (Stream fs = new FileStream(file, FileMode.Open))
            using (var reader = new BinaryReader(fs))
                dexreader.ReadFrom(reader);

            dexwriter = new DexWriter(dex);
            dexwriter.WriteTo(new BinaryWriter(new MemoryStream()));
        }
Пример #2
0
        public static Dex Read(string filename, bool bufferize)
        {
            var result = new Dex();

            using (var filestream = new FileStream(filename, FileMode.Open))
            {
                Stream sourcestream = filestream;
                if (bufferize)
                {
                    var memorystream = new MemoryStream();
                    filestream.CopyTo(memorystream);
                    memorystream.Position = 0;
                    sourcestream = memorystream;
                }

                using (var binaryReader = new BinaryReader(sourcestream))
                {
                    var reader = new DexReader(result);
                    reader.ReadFrom(binaryReader);
                    return result;
                }
            }
        }