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


C# Formatter.Deserialize方法代码示例

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


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

示例1: DeserializeGeneric_BinaryFormatted_Deserialized

        public void DeserializeGeneric_BinaryFormatted_Deserialized()
        {
            // ReSharper disable once AssignNullToNotNullAttribute
            var serializationInfo = new SerializedValue(typeof(TestData).AssemblyQualifiedName, new byte[0]);
            var subject = new Formatter(
                _binarySerializerMock.Object,
                _unityJsonSerializerMock.Object,
                _formatSelectorMock.Object);
            var testData = new TestData();
            _binarySerializerMock.Setup(mock => mock.Deserialize(It.IsAny<byte[]>()))
                .Returns(testData);

            var result = subject.Deserialize<TestData>(serializationInfo);

            Assert.AreEqual(testData, result);
        }
开发者ID:JackTheRipper42,项目名称:Binding,代码行数:16,代码来源:FormatterTest.cs

示例2: Deserialize_NullFormatted_Null

        public void Deserialize_NullFormatted_Null()
        {
            // ReSharper disable once AssignNullToNotNullAttribute
            var serializationInfo = new SerializedValue(typeof(TestData).AssemblyQualifiedName);
            var subject = new Formatter(
                _binarySerializerMock.Object,
                _unityJsonSerializerMock.Object,
                _formatSelectorMock.Object);

            var result = subject.Deserialize(serializationInfo);

            Assert.IsNull(result);
        }
开发者ID:JackTheRipper42,项目名称:Binding,代码行数:13,代码来源:FormatterTest.cs

示例3: Deserialize_TypeNotResolved_Throws

        public void Deserialize_TypeNotResolved_Throws()
        {
            var serializationInfo = new SerializedValue("12345", "12345");
            var subject = new Formatter(
                _binarySerializerMock.Object,
                _unityJsonSerializerMock.Object,
                _formatSelectorMock.Object);
            var testData = new TestData();
            _unityJsonSerializerMock.Setup(mock => mock.Deserialize(It.IsAny<Type>(), It.IsAny<string>()))
                .Returns(testData);

            Assert.Throws<InvalidOperationException>(() => subject.Deserialize(serializationInfo));
        }
开发者ID:JackTheRipper42,项目名称:Binding,代码行数:13,代码来源:FormatterTest.cs

示例4: DeserializeGeneric_TypeNotAssignalbe_Throws

        public void DeserializeGeneric_TypeNotAssignalbe_Throws()
        {
            // ReSharper disable once AssignNullToNotNullAttribute
            var serializationInfo = new SerializedValue(typeof(TestData).AssemblyQualifiedName, "12345");
            var subject = new Formatter(
                _binarySerializerMock.Object,
                _unityJsonSerializerMock.Object,
                _formatSelectorMock.Object);

            Assert.Throws<InvalidOperationException>(() => subject.Deserialize<int>(serializationInfo));
        }
开发者ID:JackTheRipper42,项目名称:Binding,代码行数:11,代码来源:FormatterTest.cs


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