本文整理汇总了C#中IWriteContext.WriteBytes方法的典型用法代码示例。如果您正苦于以下问题:C# IWriteContext.WriteBytes方法的具体用法?C# IWriteContext.WriteBytes怎么用?C# IWriteContext.WriteBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWriteContext
的用法示例。
在下文中一共展示了IWriteContext.WriteBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
// #end example
// #example: Write the StringBuilder
public void Write(IWriteContext writeContext, object o)
{
StringBuilder builder = (StringBuilder) o;
string str = builder.ToString();
byte[] bytes = Encoding.UTF8.GetBytes(str);
writeContext.WriteInt(bytes.Length);
writeContext.WriteBytes(bytes);
}
示例2: Write
public override void Write(IWriteContext context, object obj)
{
ushort us = (ushort)obj;
context.WriteBytes(
new byte[] {
(byte)(us>>8),
(byte)us,
});
}
示例3: Write
public override void Write(IWriteContext context, object obj)
{
var charValue = ((char) obj);
context.WriteBytes(new[]
{
(byte) (charValue & unchecked(0xff)), (byte
) (charValue >> 8)
});
}
示例4: Write
public override void Write(IWriteContext context, object obj)
{
uint ui = (uint)obj;
context.WriteBytes(
new byte[] {
(byte)(ui>>24),
(byte)(ui>>16),
(byte)(ui>>8),
(byte)ui,
});
}
示例5: Write
public override void Write(IWriteContext context, object obj)
{
ulong ui = (ulong)obj;
context.WriteBytes(
new byte[] {
(byte)(ui>>56),
(byte)(ui>>48),
(byte)(ui>>40),
(byte)(ui>>32),
(byte)(ui>>24),
(byte)(ui>>16),
(byte)(ui>>8),
(byte)ui,
});
}
示例6: Write
public override void Write(IWriteContext context, object obj)
{
decimal dec = (decimal)obj;
byte[] bytes = new byte[16];
int offset = 4;
int[] ints = Decimal.GetBits(dec);
for (int i = 0; i < 4; i++)
{
bytes[--offset] = (byte)ints[i];
bytes[--offset] = (byte)(ints[i] >>= 8);
bytes[--offset] = (byte)(ints[i] >>= 8);
bytes[--offset] = (byte)(ints[i] >>= 8);
offset += 8;
}
context.WriteBytes(bytes);
}
示例7: Write
public override void Write(IWriteContext context, object obj)
{
int shortValue = ((short) obj);
context.WriteBytes(new[] {(byte) (shortValue >> 8), (byte) shortValue});
}
示例8: WriteElements
protected virtual void WriteElements(IWriteContext context, object obj, ArrayInfo
info)
{
if (HandleAsByteArray(obj))
{
context.WriteBytes((byte[])obj);
}
else
{
// byte[] performance optimisation
if (HasNullBitmap(info))
{
BitMap4 nullItems = NullItemsMap(ArrayReflector(Container(context)), obj);
WriteNullBitmap(context, nullItems);
for (int i = 0; i < info.ElementCount(); i++)
{
if (!nullItems.IsTrue(i))
{
context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i));
}
}
}
else
{
for (int i = 0; i < info.ElementCount(); i++)
{
context.WriteObject(_handler, ArrayReflector(Container(context)).Get(obj, i));
}
}
}
}
示例9: Write
public override void Write(IWriteContext context, object obj)
{
var dec = (decimal) obj;
var bytes = new byte[16];
var offset = 4;
var ints = decimal.GetBits(dec);
for (var i = 0; i < 4; i++)
{
bytes[--offset] = (byte) ints[i];
bytes[--offset] = (byte) (ints[i] >>= 8);
bytes[--offset] = (byte) (ints[i] >>= 8);
bytes[--offset] = (byte) (ints[i] >>= 8);
offset += 8;
}
context.WriteBytes(bytes);
}