本文整理汇总了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);
}
示例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);
}
示例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));
}
示例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);
}
示例5: Deserialize
public object Deserialize(Type expectedType, BinaryTokenStreamReader reader)
{
DeserializeCalled = true;
reader.ReadToken();
return (FakeSerialized)Activator.CreateInstance(expectedType);
}