当前位置: 首页>>代码示例>>C#>>正文


C# BinarySerializer.Deserialize方法代码示例

本文整理汇总了C#中BinarySerializer.Deserialize方法的典型用法代码示例。如果您正苦于以下问题:C# BinarySerializer.Deserialize方法的具体用法?C# BinarySerializer.Deserialize怎么用?C# BinarySerializer.Deserialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinarySerializer的用法示例。


在下文中一共展示了BinarySerializer.Deserialize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LargeArrayTest

        public void LargeArrayTest()
        {
            var ser = new BinarySerializer();
            var data = new byte[65536 * sizeof(int) * 2];

            ser.Deserialize<IntArray64K>(data);

            using (var ms = new MemoryStream(data))
            {
                ser.Deserialize<IntArray64K>(ms);
            }
        }
开发者ID:andyvans,项目名称:BinarySerializer,代码行数:12,代码来源:LargeArrayTests.cs

示例2: LoadState

        private void LoadState()
        {
            try
            {
                var ser = new BinarySerializer();
                var stat = ser.Deserialize(StateFileName) as Dictionary<String, Object>;

                if (stat != null)
                {
                    var w = (Int32)stat["Width"];
                    var h = (Int32)stat["Height"];

                    if (w > MinimumSize.Width)
                        Width = w;

                    if (h > MinimumSize.Height)
                        Height = h;

                    var x = (Int32)stat["X"];
                    var y = (Int32)stat["Y"];

                    if (x > 0 && y > 0)
                        Location = new Point(x, y);

                    foreach (var p in GetType().GetProperties())
                    {
                        if (Attribute.IsDefined(p, typeof(StateItemAttribute)))
                            p.SetValue(this, stat[p.Name], null);
                    }
                }
            }
            catch { }
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:33,代码来源:StateForm.cs

示例3: Main

        private static void Main(string[] args)
        {
            var file = args[0];

            using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read))
            {
                var serializer = new BinarySerializer();
                serializer.MemberDeserialized += (sender, eventArgs) => Console.WriteLine(eventArgs.MemberName + " : " + eventArgs.Value);

                var iso = serializer.Deserialize<Iso9660.Iso9660>(stream);
                stream.Position = 0;

                var xmlSerializer = new XmlSerializer(typeof (Iso9660.Iso9660));

                var outfilePath = Path.GetDirectoryName(file);
                var outfileName = Path.GetFileNameWithoutExtension(file) + ".xml";
                var outfile = Path.Combine(outfilePath, outfileName);

                using (var xmlStream = new FileStream(outfile, FileMode.Create, FileAccess.Write))
                {
                    xmlSerializer.Serialize(xmlStream, iso);
                }

                Console.ReadKey();
            }
        }
开发者ID:andyvans,项目名称:BinarySerializer,代码行数:26,代码来源:Program.cs

示例4: Should_throw_exception_if_byte_array_is_null

        public void Should_throw_exception_if_byte_array_is_null()
        {
            // Arrange
            var serializer = new BinarySerializer();


            // Action
            var obj = serializer.Deserialize<Customer>(null);
        }
开发者ID:sovanesyan,项目名称:Burrow.NET,代码行数:9,代码来源:MethodDeserialize.cs

示例5: TestBinarySerializing

 public static void TestBinarySerializing()
 {
     var bs = new BinarySerializer<Test<string>>();
     using (var fileStream = File.Create(Path.Combine("save", "test.binx")))
     {
         bs.Serialize(fileStream, Program.GetTest());
     }
     using (var fileStream = File.OpenRead(Path.Combine("save", "test.binx")))
     {
         var test = bs.Deserialize(fileStream);
         Debug.Assert(test.SequenceEqual(Program.GetTest()));
     }
 }
开发者ID:RavingRabbit,项目名称:Labs,代码行数:13,代码来源:SerializingTesting.cs

示例6: Can_serialize_object

        public void Can_serialize_object()
        {
            // Arrange
            var serializer = new BinarySerializer();


            // Action
            var str = serializer.Serialize(new Customer { FullName = "Bunny", Title = "Mr" });
            Customer obj = serializer.Deserialize<Customer>(str);

            // Asert
            Assert.AreEqual("Bunny", obj.FullName);
            Assert.AreEqual("Mr", obj.Title);
        }
开发者ID:joefeser,项目名称:Burrow.NET,代码行数:14,代码来源:MethodSerialize.cs

示例7: LoadState

        private void LoadState()
        {
            try
            {
                var ser = new BinarySerializer();
                var stat = ser.Deserialize(StateFileName) as Dictionary<String, Object>;

                if (stat != null)
                {
                    foreach (var p in GetType().GetProperties())
                    {
                        if (Attribute.IsDefined(p, typeof(StateItemAttribute)))
                            p.SetValue(this, stat[p.Name], null);
                    }
                }
            }
            catch { }
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:18,代码来源:StateUserControl.cs


注:本文中的BinarySerializer.Deserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。