本文整理汇总了C#中ByteBuffer类的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer类的具体用法?C# ByteBuffer怎么用?C# ByteBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteBuffer类属于命名空间,在下文中一共展示了ByteBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ExtNegotiation
/*
internal ExtNegotiation(BinaryReader din, int len)
{
int uidLen = din.ReadUInt16();
this.asuid = AAssociateRQAC.ReadASCII(din, uidLen);
this.m_info = new byte[len - uidLen - 2];
din.BaseStream.Read( m_info, 0, m_info.Length);
}
*/
internal ExtNegotiation(ByteBuffer bb, int len)
{
int uidLen = bb.ReadInt16();
this.asuid = bb.ReadString(uidLen);
this.m_info = new byte[len - uidLen - 2];
bb.Read( m_info, 0, m_info.Length );
}
开发者ID:sleighter,项目名称:dicom-sharp,代码行数:16,代码来源:ExtNegotiation.cs
示例2: Read
public int Read (ByteBuffer buffer)
{
int offset = buffer.Position () + buffer.ArrayOffset ();
int num2 = s.Read (buffer.Array (), offset, (buffer.Limit () + buffer.ArrayOffset ()) - offset);
buffer.Position (buffer.Position () + num2);
return num2;
}
开发者ID:renaud91,项目名称:n-metadata-extractor,代码行数:7,代码来源:FileChannel.cs
示例3: ReadMessageAsync
public static async Task<WebSocketMessage> ReadMessageAsync(WebSocket webSocket, byte[] buffer, int maxMessageSize)
{
ArraySegment<byte> arraySegment = new ArraySegment<byte>(buffer);
WebSocketReceiveResult receiveResult = await webSocket.ReceiveAsync(arraySegment, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
// special-case close messages since they might not have the EOF flag set
if (receiveResult.MessageType == WebSocketMessageType.Close)
{
return new WebSocketMessage(null, WebSocketMessageType.Close);
}
if (receiveResult.EndOfMessage)
{
// we anticipate that single-fragment messages will be common, so we optimize for them
switch (receiveResult.MessageType)
{
case WebSocketMessageType.Binary:
return new WebSocketMessage(BufferSliceToByteArray(buffer, receiveResult.Count), WebSocketMessageType.Binary);
case WebSocketMessageType.Text:
return new WebSocketMessage(BufferSliceToString(buffer, receiveResult.Count), WebSocketMessageType.Text);
default:
throw new Exception("This code path should never be hit.");
}
}
else
{
// for multi-fragment messages, we need to coalesce
ByteBuffer bytebuffer = new ByteBuffer(maxMessageSize);
bytebuffer.Append(BufferSliceToByteArray(buffer, receiveResult.Count));
WebSocketMessageType originalMessageType = receiveResult.MessageType;
while (true)
{
// loop until an error occurs or we see EOF
receiveResult = await webSocket.ReceiveAsync(arraySegment, CancellationToken.None).ConfigureAwait(continueOnCapturedContext: false);
if (receiveResult.MessageType != originalMessageType)
{
throw new InvalidOperationException("Incorrect message type");
}
bytebuffer.Append(BufferSliceToByteArray(buffer, receiveResult.Count));
if (receiveResult.EndOfMessage)
{
switch (receiveResult.MessageType)
{
case WebSocketMessageType.Binary:
return new WebSocketMessage(bytebuffer.GetByteArray(), WebSocketMessageType.Binary);
case WebSocketMessageType.Text:
return new WebSocketMessage(bytebuffer.GetString(), WebSocketMessageType.Text);
default:
throw new Exception("This code path should never be hit.");
}
}
}
}
}
开发者ID:TerenceLewis,项目名称:SignalR,代码行数:60,代码来源:WebSocketMessageReader.cs
示例4: serialize
public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje)
{
var obj = (DebugProperty) obje;
serializer.serialize(buffer, obj.key);
serializer.serialize(buffer, obj.value);
}
开发者ID:khangnguyen,项目名称:robocode,代码行数:7,代码来源:DebugProperty.cs
示例5: GetBytesFromCString
public static byte[] GetBytesFromCString(string cStr, DataCoding dataCoding)
{
if (cStr == null) { throw new ArgumentNullException("cStr"); }
if (cStr.Length == 0) { return new byte[] { 0x00 }; }
byte[] bytes = null;
switch (dataCoding)
{
case DataCoding.ASCII:
bytes = System.Text.Encoding.ASCII.GetBytes(cStr);
break;
case DataCoding.Latin1:
bytes = Latin1Encoding.GetBytes(cStr);
break;
case DataCoding.UCS2:
bytes = System.Text.Encoding.Unicode.GetBytes(cStr);
break;
case DataCoding.SMSCDefault:
bytes = SMSCDefaultEncoding.GetBytes(cStr);
break;
default:
throw new SmppException(SmppErrorCode.ESME_RUNKNOWNERR, "Unsupported encoding");
}
ByteBuffer buffer = new ByteBuffer(bytes, bytes.Length + 1);
buffer.Append(new byte[] { 0x00 }); //Append a null charactor a the end
return buffer.ToBytes();
}
开发者ID:James226,项目名称:SMSWeb,代码行数:26,代码来源:SMPPEncodingUtil.cs
示例6: DicomAttributeMultiValueText
internal DicomAttributeMultiValueText(DicomTag tag, ByteBuffer item)
: base(tag)
{
string valueArray;
valueArray = item.GetString();
// store the length before removing pad chars
StreamLength = (uint) valueArray.Length;
// Saw some Osirix images that had padding on SH attributes with a null character, just
// pull them out here.
// Leading and trailing space characters are non-significant in all multi-valued VRs,
// so pull them out here as well since some devices seem to pad UI attributes with spaces too.
valueArray = valueArray.Trim(new [] {tag.VR.PadChar, '\0', ' '});
if (valueArray.Length == 0)
{
_values = new string[0];
Count = 1;
StreamLength = 0;
}
else
{
_values = valueArray.Split(new char[] {'\\'});
Count = (long) _values.Length;
StreamLength = (uint) valueArray.Length;
}
}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:30,代码来源:DicomAttributeMultiValueText.cs
示例7: WriteIteratorScopes
private void WriteIteratorScopes(Function function)
{
if (function.IteratorScopes.Count == 0)
return;
var buffer = new ByteBuffer();
buffer.WriteByte(4);
buffer.WriteByte(1);
buffer.Align(4);
buffer.WriteByte(4);
buffer.WriteByte(3);
buffer.Align(4);
var scopes = function.IteratorScopes;
buffer.WriteInt32(scopes.Count * 8 + 12);
buffer.WriteInt32(scopes.Count);
foreach (var scope in scopes)
{
buffer.WriteInt32(scope.Offset);
buffer.WriteInt32(scope.Offset + scope.Length);
}
pdb.SetSymAttribute(function.Token, "MD2", buffer.length, buffer.buffer);
}
开发者ID:ArsenShnurkov,项目名称:SyntaxTree.Pdb,代码行数:27,代码来源:PdbWriter.cs
示例8: Allocate
/// <summary>
/// Allocates a new byte buffer.
/// The new buffer's position will be zero, its limit will be its capacity,
/// and its mark will be undefined.
/// It will have a backing array, and its array offset will be zero.
/// </summary>
/// <param name="capacity"></param>
/// <returns></returns>
public static ByteBuffer Allocate(int capacity)
{
MemoryStream ms = new MemoryStream(capacity);
ByteBuffer buffer = new ByteBuffer(ms);
buffer.Limit = capacity;
return buffer;
}
开发者ID:ResQue1980,项目名称:LoLTeamChecker,代码行数:15,代码来源:ByteBuffer.cs
示例9: serialize
override public void serialize(ByteBuffer bu)
{
base.serialize(bu)
bu.writeUnsignedInt8(byCmd);
bu.writeUnsignedInt8(byParam);
bu.writeUnsignedInt32(dwTimestamp);
}
开发者ID:quinsmpang,项目名称:Tools,代码行数:7,代码来源:NullUserCmd.cs
示例10: derialize
override public void derialize(ByteBuffer bu)
{
base.derialize(bu)
bu.readUnsignedInt8(ref byCmd);
bu.readUnsignedInt8(ref byParam);
bu.readUnsignedInt32(ref dwTimestamp);
}
开发者ID:quinsmpang,项目名称:Tools,代码行数:7,代码来源:NullUserCmd.cs
示例11: OnDecode
protected override void OnDecode(ByteBuffer buffer, int count)
{
if (count-- > 0)
{
this.Durable = AmqpCodec.DecodeBoolean(buffer);
}
if (count-- > 0)
{
this.Priority = AmqpCodec.DecodeUByte(buffer);
}
if (count-- > 0)
{
this.Ttl = AmqpCodec.DecodeUInt(buffer);
}
if (count-- > 0)
{
this.FirstAcquirer = AmqpCodec.DecodeBoolean(buffer);
}
if (count-- > 0)
{
this.DeliveryCount = AmqpCodec.DecodeUInt(buffer);
}
}
开发者ID:modulexcite,项目名称:IL2JS,代码行数:27,代码来源:Header.cs
示例12: Find
int Find(byte[] prefix, ByteBuffer key)
{
var left = 0;
var right = _keyvalues.Length;
var keyBytes = _keyBytes;
while (left < right)
{
var middle = (left + right) / 2;
int currentKeyOfs = _keyvalues[middle].KeyOffset;
int currentKeyLen = _keyvalues[middle].KeyLength;
var result = BitArrayManipulation.CompareByteArray(prefix, 0, prefix.Length,
keyBytes, currentKeyOfs, Math.Min(currentKeyLen, prefix.Length));
if (result == 0)
{
result = BitArrayManipulation.CompareByteArray(key.Buffer, key.Offset, key.Length,
keyBytes, currentKeyOfs + prefix.Length, currentKeyLen - prefix.Length);
if (result == 0)
{
return middle * 2 + 1;
}
}
if (result < 0)
{
right = middle;
}
else
{
left = middle + 1;
}
}
return left * 2;
}
开发者ID:Xamarui,项目名称:BTDB,代码行数:33,代码来源:BTreeLeafComp.cs
示例13: allocate
public static ByteBuffer allocate(int capacity)
{
ByteBuffer b = new ByteBuffer();
b.buffer = new byte[capacity];
b.limit = 0;
return b;
}
开发者ID:BraynStorm,项目名称:Tanks,代码行数:7,代码来源:ByteBuffer.cs
示例14: Find
int Find(byte[] prefix, ByteBuffer key)
{
var left = 0;
var right = _keys.Length;
while (left < right)
{
var middle = (left + right) / 2;
var currentKey = _keys[middle];
var result = BitArrayManipulation.CompareByteArray(prefix, prefix.Length,
currentKey, Math.Min(currentKey.Length, prefix.Length));
if (result == 0)
{
result = BitArrayManipulation.CompareByteArray(key.Buffer, key.Offset, key.Length,
currentKey, prefix.Length, currentKey.Length - prefix.Length);
}
if (result < 0)
{
right = middle;
}
else
{
left = middle + 1;
}
}
return left;
}
开发者ID:Xamarui,项目名称:BTDB,代码行数:26,代码来源:BTreeBranch.cs
示例15: NESSoftReset
public override void NESSoftReset()
{
lock_regs = false;
cur_reg = 0;
regs = new ByteBuffer(4);
base.NESSoftReset();
}
开发者ID:ddugovic,项目名称:RASuite,代码行数:7,代码来源:Mapper045.cs
示例16: OnDecode
protected override void OnDecode(ByteBuffer buffer, int count)
{
if (count-- > 0)
{
this.Role = AmqpCodec.DecodeBoolean(buffer);
}
if (count-- > 0)
{
this.First = AmqpCodec.DecodeUInt(buffer);
}
if (count-- > 0)
{
this.Last = AmqpCodec.DecodeUInt(buffer);
}
if (count-- > 0)
{
this.Settled = AmqpCodec.DecodeBoolean(buffer);
}
if (count-- > 0)
{
this.State = (DeliveryState)AmqpCodec.DecodeAmqpDescribed(buffer);
}
if (count-- > 0)
{
this.Batchable = AmqpCodec.DecodeBoolean(buffer);
}
}
开发者ID:Azure,项目名称:azure-amqp,代码行数:32,代码来源:Disposition.cs
示例17: GetDebugHeader
public ImageDebugDirectory GetDebugHeader(out byte [] header)
{
var section = GetSectionAtVirtualAddress (Debug.VirtualAddress);
var buffer = new ByteBuffer (section.Data);
buffer.position = (int) (Debug.VirtualAddress - section.VirtualAddress);
var directory = new ImageDebugDirectory {
Characteristics = buffer.ReadInt32 (),
TimeDateStamp = buffer.ReadInt32 (),
MajorVersion = buffer.ReadInt16 (),
MinorVersion = buffer.ReadInt16 (),
Type = buffer.ReadInt32 (),
SizeOfData = buffer.ReadInt32 (),
AddressOfRawData = buffer.ReadInt32 (),
PointerToRawData = buffer.ReadInt32 (),
};
if (directory.SizeOfData == 0 || directory.PointerToRawData == 0) {
header = Empty<byte>.Array;
return directory;
}
buffer.position = (int) (directory.PointerToRawData - section.PointerToRawData);
header = new byte [directory.SizeOfData];
Buffer.BlockCopy (buffer.buffer, buffer.position, header, 0, header.Length);
return directory;
}
开发者ID:ttRevan,项目名称:cecil,代码行数:29,代码来源:Image.cs
示例18: ReadFrom
internal static Broker ReadFrom(ByteBuffer buffer)
{
var id = buffer.GetInt();
var host = ApiUtils.ReadShortString(buffer);
var port = buffer.GetInt();
return new Broker(id, host, port);
}
开发者ID:ajperrins,项目名称:kafka-net,代码行数:7,代码来源:Broker.cs
示例19: _CreateByteBuffer
static int _CreateByteBuffer(IntPtr L)
{
try
{
int count = LuaDLL.lua_gettop(L);
if (count == 0)
{
ByteBuffer obj = new ByteBuffer();
ToLua.PushObject(L, obj);
return 1;
}
else if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(byte[])))
{
byte[] arg0 = ToLua.CheckByteBuffer(L, 1);
ByteBuffer obj = new ByteBuffer(arg0);
ToLua.PushObject(L, obj);
return 1;
}
else
{
return LuaDLL.luaL_throw(L, "invalid arguments to ctor method: ByteBuffer.New");
}
}
catch(Exception e)
{
return LuaDLL.toluaL_exception(L, e);
}
}
开发者ID:woshihuo12,项目名称:UnityHello,代码行数:29,代码来源:ByteBufferWrap.cs
示例20: createImagePatternBCH
public static void createImagePatternBCH(int i, ByteBuffer bb)
{
JNI.Frame frame = (JNI.Frame) null;
if (ARToolKitPlus.__\u003Cjniptr\u003EcreateImagePatternBCH\u0028ILjava\u002Fnio\u002FByteBuffer\u003B\u0029V == IntPtr.Zero)
ARToolKitPlus.__\u003Cjniptr\u003EcreateImagePatternBCH\u0028ILjava\u002Fnio\u002FByteBuffer\u003B\u0029V = JNI.Frame.GetFuncPtr(ARToolKitPlus.__\u003CGetCallerID\u003E(), "com/googlecode/javacv/cpp/ARToolKitPlus", "createImagePatternBCH", "(ILjava/nio/ByteBuffer;)V");
// ISSUE: explicit reference operation
IntPtr num1 = ((JNI.Frame) @frame).Enter(ARToolKitPlus.__\u003CGetCallerID\u003E());
try
{
IntPtr num2 = num1;
// ISSUE: explicit reference operation
IntPtr num3 = ((JNI.Frame) @frame).MakeLocalRef((object) ClassLiteral<ARToolKitPlus>.Value);
int num4 = i;
// ISSUE: explicit reference operation
IntPtr num5 = ((JNI.Frame) @frame).MakeLocalRef((object) bb);
// ISSUE: cast to a function pointer type
// ISSUE: function pointer call
__calli((__FnPtr<void (IntPtr, IntPtr, int, IntPtr)>) ARToolKitPlus.__\u003Cjniptr\u003EcreateImagePatternBCH\u0028ILjava\u002Fnio\u002FByteBuffer\u003B\u0029V)(num2, (int) num3, (IntPtr) num4, num5);
}
catch (object ex)
{
Console.WriteLine((object) "*** exception in native code ***");
Console.WriteLine(ex);
throw;
}
finally
{
// ISSUE: explicit reference operation
((JNI.Frame) @frame).Leave();
}
}
开发者ID:NALSS,项目名称:SmartDashboard.NET,代码行数:31,代码来源:ARToolKitPlus.cs
注:本文中的ByteBuffer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论