当前位置: 首页>>代码示例>>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;未经允许,请勿转载。