Пример #1
0
        public void Test1()
        {
            var ticks = Enumerable.Range(0, 100).Select(i => new Struct1 {
            }).ToList();

            using (var ms = new MemoryStream())
            {
                //create raw serialization logic
                Persist <Struct1> persist = new Persist <Struct1>();
                //write tick by tick
                BinaryWriter writer = new BinaryWriter(ms);
                for (int i = 0; i < ticks.Count; i++)
                {
                    persist.Write(writer, ticks[i]);
                }

                //read
                var reader = new BinaryReader(ms);
                var tmp    = new List <Struct1>();
                ms.Seek(0, SeekOrigin.Begin);
                for (int i = 0; i < ticks.Count; i++)
                {
                    var tick = persist.Read(reader);
                    tmp.Add(tick);
                }
            }
        }