本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例5: Serialize
public void Serialize(object item, BinaryTokenStreamWriter writer, Type expectedType)
{
SerializeCalled = true;
writer.WriteNull();
}