本文整理汇总了C#中SerializerSession.GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# SerializerSession.GetBuffer方法的具体用法?C# SerializerSession.GetBuffer怎么用?C# SerializerSession.GetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializerSession
的用法示例。
在下文中一共展示了SerializerSession.GetBuffer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadValue
public override object ReadValue(Stream stream, SerializerSession session)
{
var size = sizeof(UInt16);
var buffer = session.GetBuffer(size);
stream.Read(buffer, 0, size);
return BitConverter.ToUInt16(buffer, 0);
}
示例2: ReadValue
public override object ReadValue(Stream stream, SerializerSession session)
{
var size = sizeof (long);
var buffer = session.GetBuffer(size);
stream.Read(buffer, 0, size);
var ticks = BitConverter.ToInt64(buffer, 0);
return new DateTime(ticks);
}
示例3: WriteValue
public override void WriteValue(Stream stream, object value, SerializerSession session)
{
var bytes = session.GetBuffer(Int32Serializer.Size);
var data = decimal.GetBits((decimal) value);
Int32Serializer.WriteValueImpl(stream, data[0], bytes);
Int32Serializer.WriteValueImpl(stream, data[1], bytes);
Int32Serializer.WriteValueImpl(stream, data[2], bytes);
Int32Serializer.WriteValueImpl(stream, data[3], bytes);
}
示例4: ReadValue
public override object ReadValue(Stream stream, SerializerSession session)
{
var length = (int) Int32Serializer.Instance.ReadValue(stream, session);
if (length == -1)
return null;
var buffer = session.GetBuffer(length);
stream.Read(buffer, 0, length);
var res = Encoding.UTF8.GetString(buffer, 0, length);
return res;
}
示例5: ReadValue
public override object ReadValue(Stream stream, SerializerSession session)
{
var buffer = session.GetBuffer(16);
stream.Read(buffer, 0, 16);
return new Guid(buffer); //TODO: cap array?
}