コード例 #1
0
        public static object Reserialize(this IBinaryLayerHandler handler, object input)
        {
            object output;

            using (var ms = new MemoryStream())
            {
                handler.Serialize(new BinaryDataWriter(ms), input);
                ms.Position = 0;
                output      = handler.Deserialize(new BinaryDataReader(ms));
                Assert.That(ms.Position, Is.EqualTo(ms.Length), "Stream should be read till the end");
            }
            return(output);
        }
コード例 #2
0
        public void Save(IniKeyCollection iniData, object data, LayerHandlerContext context)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            using (var ms = new MemoryStream())
                using (var buffer = new BinaryDataWriter(ms))
                {
                    binaryHandler.Serialize(buffer, data);
                    ms.Position = 0;
                    context.SaveExternalFile(DataFileKey, ms.ToArray());
                }
        }