當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。