예제 #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
파일: Dex.cs 프로젝트: shuixi2013/Dexer
        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;
                }
            }
        }