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


C# BinaryTokenStreamReader.ReadToken方法代码示例

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


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

示例1: Deserialize

 /// <summary>
 /// Tries to deserialize an item.
 /// </summary>
 /// <param name="reader">The reader used for binary deserialization</param>
 /// <param name="expectedType">The type that should be deserialzied</param>
 /// <returns>The deserialized object</returns>
 public object Deserialize(Type expectedType, BinaryTokenStreamReader reader)
 {
     var token = reader.ReadToken();
     if (token == SerializationTokenType.Null) return null;
     var actualType = this.ReadType(token, reader, expectedType);
     var methods = this.serializers.Get(actualType);
     var deserializer = methods.Deserialize;
     return deserializer(expectedType, reader);
 }
开发者ID:osjimenez,项目名称:orleans,代码行数:15,代码来源:ILBasedFallbackSerializer.cs

示例2: VerifyUsingFallbackSerializer

        public static void VerifyUsingFallbackSerializer(object ob)
        {
            var writer = new BinaryTokenStreamWriter();
            SerializationManager.FallbackSerializer(ob, writer, ob.GetType());
            var bytes = writer.ToByteArray();

            var reader = new BinaryTokenStreamReader(bytes);
            var serToken = reader.ReadToken();
            Assert.Equal(SerializationTokenType.Fallback, serToken);
        }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:10,代码来源:SerializationTestsUtils.cs

示例3: VerifyUsingFallbackSerializer

        private static void VerifyUsingFallbackSerializer(object ob)
        {
            var writer = new BinaryTokenStreamWriter();
            SerializationManager.FallbackSerializer(ob, writer, ob.GetType());
            var bytes = writer.ToByteArray();

            byte[] defaultFormatterBytes;
            var formatter = new BinaryFormatter();
            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, ob);
                stream.Flush();
                defaultFormatterBytes = stream.ToArray();
            }

            var reader = new BinaryTokenStreamReader(bytes);
            var serToken = reader.ReadToken();
            Assert.Equal(SerializationTokenType.Fallback, serToken);
            var length = reader.ReadInt();
            Assert.Equal(length, defaultFormatterBytes.Length);
            var segment = new ArraySegment<byte>(bytes, reader.CurrentPosition, bytes.Length - reader.CurrentPosition);
            Assert.True(segment.SequenceEqual(defaultFormatterBytes));
        }
开发者ID:amccool,项目名称:orleans,代码行数:23,代码来源:StreamTypeSerializationTests.cs

示例4: DeserializeGrainCancellationToken

 internal static object DeserializeGrainCancellationToken(Type expected, BinaryTokenStreamReader stream)
 {
     var cancellationRequested = stream.ReadToken() == SerializationTokenType.True;
     var tokenId = stream.ReadGuid();
     return new GrainCancellationToken(tokenId, cancellationRequested);
 }
开发者ID:osjimenez,项目名称:orleans,代码行数:6,代码来源:GrainCancellationToken.cs

示例5: Deserialize

 public object Deserialize(Type expectedType, BinaryTokenStreamReader reader)
 {
     DeserializeCalled = true;
     reader.ReadToken();
     return (FakeSerialized)Activator.CreateInstance(expectedType);
 }
开发者ID:Carlm-MS,项目名称:orleans,代码行数:6,代码来源:FakeSerializer.cs


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