當前位置: 首頁>>代碼示例>>C#>>正文


C# BinaryTokenStreamReader.ReadBytes方法代碼示例

本文整理匯總了C#中Orleans.Serialization.BinaryTokenStreamReader.ReadBytes方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryTokenStreamReader.ReadBytes方法的具體用法?C# BinaryTokenStreamReader.ReadBytes怎麽用?C# BinaryTokenStreamReader.ReadBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Orleans.Serialization.BinaryTokenStreamReader的用法示例。


在下文中一共展示了BinaryTokenStreamReader.ReadBytes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Deserialize

        public object Deserialize(Type expectedType, BinaryTokenStreamReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            var n = reader.ReadInt();
            var bytes = reader.ReadBytes(n);
            var formatter = new BinaryFormatter();
            object retVal = null;
            using (var memoryStream = new MemoryStream(bytes))
            {
                retVal = formatter.Deserialize(memoryStream);
            }

            return retVal;
        }
開發者ID:sbambach,項目名稱:orleans,代碼行數:18,代碼來源:BinaryFormatterSerializer.cs

示例2: Deserialize

        /// <summary>
        /// Deserializes an object from a binary stream
        /// </summary>
        /// <param name="expectedType">The type that is expected to be deserialized</param>
        /// <param name="reader">The <see cref="BinaryTokenStreamReader"/></param>
        /// <returns>The deserialized object</returns>
        public object Deserialize(Type expectedType, BinaryTokenStreamReader reader)
        {
            if (expectedType == null)
            {
                throw new ArgumentNullException("expectedType");
            }

            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            var typeHandle = expectedType.TypeHandle;
            object parser = null;
            if (!Parsers.TryGetValue(typeHandle, out parser))
            {
                throw new ArgumentException("No parser found for the expected type " + expectedType, "expectedType");
            }

            int length = reader.ReadInt();
            if (length == 0)
            {
                // the special null case.
                return null;
            }
            byte[] data = reader.ReadBytes(length);

            dynamic dynamicParser = parser;
            object message = dynamicParser.ParseFrom(data);

            return message;
        }
開發者ID:PaulNorth,項目名稱:orleans,代碼行數:38,代碼來源:ProtobufSerializer.cs

示例3: Deserializer

 public static object Deserializer(Type expected, BinaryTokenStreamReader stream) =>
     Deserialize(stream.ReadBytes(stream.ReadInt()));
開發者ID:lmagyar,項目名稱:Orleans.Activities,代碼行數:2,代碼來源:InstanceValueDictionarySerializer.cs


注:本文中的Orleans.Serialization.BinaryTokenStreamReader.ReadBytes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。