本文整理汇总了C#中IReadContext.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# IReadContext.ReadBytes方法的具体用法?C# IReadContext.ReadBytes怎么用?C# IReadContext.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadContext
的用法示例。
在下文中一共展示了IReadContext.ReadBytes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Read
// #end example
// #example: Read the StringBuilder
public object Read(IReadContext readContext)
{
int length = readContext.ReadInt();
byte[] data = new byte[length];
readContext.ReadBytes(data);
return new StringBuilder(Encoding.UTF8.GetString(data));
}
示例2: Read
public override object Read(IReadContext context)
{
byte[] bytes = new byte[2];
context.ReadBytes(bytes);
return (ushort)(
bytes[1] & 255 |
(bytes[0] & 255) << 8
);
}
示例3: Read
public override object Read(IReadContext context)
{
byte[] bytes = new byte[4];
context.ReadBytes(bytes);
return (uint)(
bytes[3] & 255 |
(bytes[2] & 255) << 8 |
(bytes[1] & 255) << 16 |
(bytes[0] & 255) << 24
);
}
示例4: Read
public override object Read(IReadContext context)
{
var bytes = new byte[8];
context.ReadBytes(bytes);
return (ulong) bytes[7] & 255 |
(ulong) (bytes[6] & 255) << 8 |
(ulong) (bytes[5] & 255) << 16 |
(ulong) (bytes[4] & 255) << 24 |
(ulong) (bytes[3] & 255) << 32 |
(ulong) (bytes[2] & 255) << 40 |
(ulong) (bytes[1] & 255) << 48 |
(ulong) (bytes[0] & 255) << 56;
}
示例5: Read
public override object Read(IReadContext context)
{
byte[] bytes = new byte[16];
int[] ints = new int[4];
int offset = 4;
context.ReadBytes(bytes);
for (int i = 0; i < 4; i++)
{
ints[i] = (
bytes[--offset] & 255 |
(bytes[--offset] & 255) << 8 |
(bytes[--offset] & 255) << 16 |
(bytes[--offset] & 255) << 24
);
offset += 8;
}
return new Decimal(ints);
}
示例6: ReadInto
protected void ReadInto(IReadContext context, ArrayInfo info, object array)
{
if (array == null)
{
return;
}
if (HandleAsByteArray(array))
{
context.ReadBytes((byte[])array);
// byte[] performance optimisation
return;
}
if (HasNullBitmap(info))
{
BitMap4 nullBitMap = ReadNullBitmap(context, info.ElementCount());
for (int i = 0; i < info.ElementCount(); i++)
{
object obj = nullBitMap.IsTrue(i) ? null : context.ReadObject(_handler);
ArrayReflector(Container(context)).Set(array, i, obj);
}
}
else
{
for (int i = 0; i < info.ElementCount(); i++)
{
ArrayReflector(Container(context)).Set(array, i, context.ReadObject(_handler));
}
}
}