本文整理汇总了C#中IByteBuffer.SetWriterIndex方法的典型用法代码示例。如果您正苦于以下问题:C# IByteBuffer.SetWriterIndex方法的具体用法?C# IByteBuffer.SetWriterIndex怎么用?C# IByteBuffer.SetWriterIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IByteBuffer
的用法示例。
在下文中一共展示了IByteBuffer.SetWriterIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTo
void CopyTo(int index, int length, int componentId, IByteBuffer dst)
{
int dstIndex = 0;
int i = componentId;
while (length > 0)
{
ComponentEntry c = this.components[i];
IByteBuffer s = c.Buffer;
int adjustment = c.Offset;
int localLength = Math.Min(length, s.Capacity - (index - adjustment));
s.GetBytes(index - adjustment, dst, dstIndex, localLength);
index += localLength;
dstIndex += localLength;
length -= localLength;
i++;
}
dst.SetWriterIndex(dst.Capacity);
}
示例2: ReadBytes
public virtual IByteBuffer ReadBytes(IByteBuffer destination, int length)
{
if (length > destination.WritableBytes)
{
throw new IndexOutOfRangeException(string.Format("length({0}) exceeds destination.WritableBytes({1}) where destination is: {2}",
length, destination.WritableBytes, destination));
}
this.ReadBytes(destination, destination.WriterIndex, length);
destination.SetWriterIndex(destination.WriterIndex + length);
return this;
}
示例3: DoReadBytes
protected override int DoReadBytes(IByteBuffer byteBuf)
{
if (!byteBuf.HasArray)
{
throw new NotImplementedException("Only IByteBuffer implementations backed by array are supported.");
}
SocketError errorCode;
int received = this.Socket.Receive(byteBuf.Array, byteBuf.ArrayOffset + byteBuf.WriterIndex, byteBuf.WritableBytes, SocketFlags.None, out errorCode);
switch (errorCode)
{
case SocketError.Success:
if (received == 0)
{
return -1; // indicate that socket was closed
}
break;
case SocketError.WouldBlock:
if (received == 0)
{
return 0;
}
break;
default:
throw new SocketException((int)errorCode);
}
byteBuf.SetWriterIndex(byteBuf.WriterIndex + received);
return received;
}
示例4: DoReadBytes
protected override int DoReadBytes(IByteBuffer byteBuf)
{
if (!byteBuf.HasArray)
{
throw new NotImplementedException("Only IByteBuffer implementations backed by array are supported.");
}
SocketError errorCode;
int received = this.Socket.Receive(byteBuf.Array, byteBuf.ArrayOffset + byteBuf.WriterIndex, byteBuf.WritableBytes, SocketFlags.None, out errorCode);
if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock)
{
throw new SocketException((int)errorCode);
}
if (received > 0)
{
byteBuf.SetWriterIndex(byteBuf.WriterIndex + received);
}
return received;
//return byteBuf.writeBytes(javaChannel(), byteBuf.writableBytes());
}
示例5: ReadBytes
public virtual IByteBuffer ReadBytes(IByteBuffer destination, int length)
{
if (length > destination.WritableBytes)
{
throw new IndexOutOfRangeException($"length({length}) exceeds destination.WritableBytes({destination.WritableBytes}) where destination is: {destination}");
}
this.ReadBytes(destination, destination.WriterIndex, length);
destination.SetWriterIndex(destination.WriterIndex + length);
return this;
}
示例6: GetBytes
public virtual IByteBuffer GetBytes(int index, IByteBuffer destination, int length)
{
this.GetBytes(index, destination, destination.WriterIndex, length);
destination.SetWriterIndex(destination.WriterIndex + length);
return this;
}