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


C# BinaryTokenStreamWriter.WriteNull方法代碼示例

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


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

示例1: Serialize

        public void Serialize(object item, BinaryTokenStreamWriter writer, Type expectedType)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (item == null)
            {
                writer.WriteNull();
                return;
            }

            var formatter = new BinaryFormatter();
            byte[] bytes;
            using (var memoryStream = new MemoryStream())
            {
                formatter.Serialize(memoryStream, item);
                memoryStream.Flush();
                bytes = memoryStream.ToArray();
            }
            
            writer.Write(bytes.Length);
            writer.Write(bytes);
        }
開發者ID:sbambach,項目名稱:orleans,代碼行數:25,代碼來源:BinaryFormatterSerializer.cs

示例2: Serialize

        /// <summary>
        /// Tries to serialize an item.
        /// </summary>
        /// <param name="item">The instance of the object being serialized</param>
        /// <param name="writer">The writer used for serialization</param>
        /// <param name="expectedType">The type that the deserializer will expect</param>
        public void Serialize(object item, BinaryTokenStreamWriter writer, Type expectedType)
        {
            if (item == null)
            {
                writer.WriteNull();
                return;
            }

            var actualType = item.GetType();
            this.WriteType(actualType, expectedType, writer);
            this.serializers.Get(actualType).Serialize(item, writer, expectedType);
        }
開發者ID:osjimenez,項目名稱:orleans,代碼行數:18,代碼來源:ILBasedFallbackSerializer.cs

示例3: Serialize

        /// <summary>
        /// Serialize the event sequence token.
        /// </summary>
        /// <param name="untypedInput">The object to serialize.</param>
        /// <param name="writer">The writer to write the binary stream to.</param>
        /// <param name="expected">The expected type.</param>
        public static void Serialize(object untypedInput, BinaryTokenStreamWriter writer, Type expected)
        {
            var typed = untypedInput as EventSequenceTokenV2;
            if (typed == null)
            {
                writer.WriteNull();
                return;
            }

            writer.Write(typed.SequenceNumber);
            writer.Write(typed.EventIndex);
        }
開發者ID:Carlm-MS,項目名稱:orleans,代碼行數:18,代碼來源:EventSequenceTokenV2.cs

示例4: Serialize

        /// <summary>
        /// Serializes an object to a binary stream
        /// </summary>
        /// <param name="item">The object to serialize</param>
        /// <param name="writer">The <see cref="BinaryTokenStreamWriter"/></param>
        /// <param name="expectedType">The type the deserializer should expect</param>
        public void Serialize(object item, BinaryTokenStreamWriter writer, Type expectedType)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            if (item == null)
            {
                writer.WriteNull();
                return;
            }

            var str = JsonConvert.SerializeObject(item, expectedType, defaultSettings);
            writer.Write(str);
        }
開發者ID:PaulNorth,項目名稱:orleans,代碼行數:22,代碼來源:OrleansJsonSerializer.cs

示例5: Serialize

 public void Serialize(object item, BinaryTokenStreamWriter writer, Type expectedType)
 {
     SerializeCalled = true;
     writer.WriteNull();
 }
開發者ID:Rejendo,項目名稱:orleans,代碼行數:5,代碼來源:ExternalSerializerTest.cs


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