Inheritance: ISerializer
コード例 #1
0
ファイル: Program.cs プロジェクト: ufcpp/UfcppSample
        private static void WriteSerializedData(IRecord record)
        {
            byte[] buffer;
            using (var s = new MemoryStream())
            using (var sw = new StreamWriter(s))
            {
                var serializer = new Serialization.MySerializer(sw);
                serializer.Serialize(record);
                sw.Flush();

                var len = s.Length;
                s.Seek(0, SeekOrigin.Begin);
                buffer = new byte[len];
                s.Read(buffer, 0, (int)len);
            }

            var serialized = Encoding.UTF8.GetString(buffer);
            Console.WriteLine(serialized);
        }
コード例 #2
0
        private static void WriteSerializedData(IRecord record)
        {
            byte[] buffer;
            using (var s = new MemoryStream())
                using (var sw = new StreamWriter(s))
                {
                    var serializer = new Serialization.MySerializer(sw);
                    serializer.Serialize(record);
                    sw.Flush();

                    var len = s.Length;
                    s.Seek(0, SeekOrigin.Begin);
                    buffer = new byte[len];
                    s.Read(buffer, 0, (int)len);
                }

            var serialized = Encoding.UTF8.GetString(buffer);

            Console.WriteLine(serialized);
        }