当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.Append方法代码示例

本文整理汇总了C#中System.ByteBuffer.Append方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Append方法的具体用法?C# ByteBuffer.Append怎么用?C# ByteBuffer.Append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Encode

 public void Encode(ByteBuffer buffer)
 {
     byte[] bytes = this.uuid.ToByteArray();
     buffer.Validate(true, bytes.Length);
     Buffer.BlockCopy(bytes, 0, buffer.Buffer, buffer.WritePos, bytes.Length);
     buffer.Append(bytes.Length);
 }
开发者ID:Eclo,项目名称:amqpnetlite,代码行数:7,代码来源:EmployeeId.cs

示例2: ReadFrameBuffer

        public static ByteBuffer ReadFrameBuffer(ITransport transport, byte[] sizeBuffer, uint maxFrameSize)
        {
            ReadBuffer(transport, sizeBuffer, 0, FixedWidth.UInt);
            int size = AmqpBitConverter.ReadInt(sizeBuffer, 0);
            if ((uint)size > maxFrameSize)
            {
                throw new AmqpException(ErrorCode.InvalidField,
                    Fx.Format(SRAmqp.InvalidFrameSize, size, maxFrameSize));
            }

            ByteBuffer frameBuffer = new ByteBuffer(size, true);
            AmqpBitConverter.WriteInt(frameBuffer, size);
            ReadBuffer(transport, frameBuffer.Buffer, frameBuffer.Length, frameBuffer.Size);
            frameBuffer.Append(frameBuffer.Size);
            return frameBuffer;
        }
开发者ID:Eclo,项目名称:amqpnetlite,代码行数:16,代码来源:Reader.cs

示例3: WriteAsync

        public override bool WriteAsync(TransportAsyncCallbackArgs args)
        {
            Fx.Assert(this.writeState.Args == null, "Cannot write when a write is still in progress");
            ArraySegment<byte> buffer;
            if (args.Buffer != null)
            {
                buffer = new ArraySegment<byte>(args.Buffer, args.Offset, args.Count);
                this.writeState.Args = args;
            }
            else
            {
                Fx.Assert(args.ByteBufferList != null, "Buffer list should not be null when buffer is null");
                if (args.ByteBufferList.Count == 1)
                {
                    ByteBuffer byteBuffer = args.ByteBufferList[0];
                    buffer = new ArraySegment<byte>(byteBuffer.Buffer, byteBuffer.Offset, byteBuffer.Length);
                    this.writeState.Args = args;
                }
                else
                {
                    // Copy all buffers into one big buffer to avoid SSL overhead
                    Fx.Assert(args.Count > 0, "args.Count should be set");
                    ByteBuffer temp = new ByteBuffer(args.Count, false, false);
                    for (int i = 0; i < args.ByteBufferList.Count; ++i)
                    {
                        ByteBuffer byteBuffer = args.ByteBufferList[i];
                        Buffer.BlockCopy(byteBuffer.Buffer, byteBuffer.Offset, temp.Buffer, temp.Length, byteBuffer.Length);
                        temp.Append(byteBuffer.Length);
                    }

                    buffer = new ArraySegment<byte>(temp.Buffer, 0, temp.Length);
                    this.writeState.Args = args;
                    this.writeState.Buffer = temp;
                }
            }

            IAsyncResult result = this.sslStream.BeginWrite(buffer.Array, buffer.Offset, buffer.Count, onWriteComplete, this);
            bool completedSynchronously = result.CompletedSynchronously;
            if (completedSynchronously)
            {
                this.HandleOperationComplete(result, true, true);
            }

            return !completedSynchronously;
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:45,代码来源:TlsTransport.cs

示例4: WriteFloat

        public static void WriteFloat(ByteBuffer buffer, float data)
        {
            buffer.EnsureSize(FixedWidth.Float);
            fixed (byte* d = &buffer.Buffer[buffer.End])
            {
                byte* p = (byte*)&data;
                d[0] = p[3];
                d[1] = p[2];
                d[2] = p[1];
                d[3] = p[0];
            }

            buffer.Append(FixedWidth.Float);
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:14,代码来源:AmqpBitConverter.cs

示例5: WriteUShort

        public static void WriteUShort(ByteBuffer buffer, ushort data)
        {
            buffer.EnsureSize(FixedWidth.UShort);
            fixed (byte* d = &buffer.Buffer[buffer.End])
            {
                byte* p = (byte*)&data;
                d[0] = p[1];
                d[1] = p[0];
            }

            buffer.Append(FixedWidth.UShort);
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:12,代码来源:AmqpBitConverter.cs

示例6: WriteUByte

 public static void WriteUByte(ByteBuffer buffer, byte data)
 {
     buffer.EnsureSize(FixedWidth.UByte);
     buffer.Buffer[buffer.End] = data;
     buffer.Append(FixedWidth.UByte);
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:6,代码来源:AmqpBitConverter.cs

示例7: Encode

        static void Encode(AmqpSymbol value, int width, ByteBuffer buffer)
        {
            int stringSize = Encoding.ASCII.GetByteCount(value.Value);
            if (width == 0)
            {
                width = AmqpEncoding.GetEncodeWidthBySize(stringSize);
            }

            if (width == FixedWidth.UByte)
            {
                AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol8);
                AmqpBitConverter.WriteUByte(buffer, (byte)stringSize);
            }
            else
            {
                AmqpBitConverter.WriteUByte(buffer, (byte)FormatCode.Symbol32);
                AmqpBitConverter.WriteUInt(buffer, (uint)stringSize);
            }

            buffer.EnsureSize(stringSize);
            int written = Encoding.ASCII.GetBytes(value.Value, 0, value.Value.Length, buffer.Buffer, buffer.End);
            buffer.Append(written);
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:23,代码来源:SymbolEncoding.cs

示例8: SignDeferred

 /**
  * Signs a PDF where space was already reserved.
  * @param reader the original PDF
  * @param fieldName the field to sign. It must be the last field
  * @param outs the output PDF
  * @param externalSignatureContainer the signature container doing the actual signing. Only the 
  * method ExternalSignatureContainer.sign is used
  * @throws DocumentException
  * @throws IOException
  * @throws GeneralSecurityException 
  */
 public static void SignDeferred(PdfReader reader, String fieldName, Stream outs, IExternalSignatureContainer externalSignatureContainer) {
     AcroFields af = reader.AcroFields;
     PdfDictionary v = af.GetSignatureDictionary(fieldName);
     if (v == null)
         throw new DocumentException("No field");
     if (!af.SignatureCoversWholeDocument(fieldName))
         throw new DocumentException("Not the last signature");
     PdfArray b = v.GetAsArray(PdfName.BYTERANGE);
     long[] gaps = b.AsLongArray();
     if (b.Size != 4 || gaps[0] != 0)
         throw new DocumentException("Single exclusion space supported");
     IRandomAccessSource readerSource = reader.SafeFile.CreateSourceView();
     Stream rg = new RASInputStream(new RandomAccessSourceFactory().CreateRanged(readerSource, gaps));
     byte[] signedContent = externalSignatureContainer.Sign(rg);
     int spaceAvailable = (int)(gaps[2] - gaps[1]) - 2;
     if ((spaceAvailable & 1) != 0)
         throw new DocumentException("Gap is not a multiple of 2");
     spaceAvailable /= 2;
     if (spaceAvailable < signedContent.Length)
         throw new DocumentException("Not enough space");
     StreamUtil.CopyBytes(readerSource, 0, gaps[1] + 1, outs);
     ByteBuffer bb = new ByteBuffer(spaceAvailable * 2);
     foreach (byte bi in signedContent) {
         bb.AppendHex(bi);
     }
     int remain = (spaceAvailable - signedContent.Length) * 2;
     for (int k = 0; k < remain; ++k) {
         bb.Append((byte)48);
     }
     bb.WriteTo(outs);
     StreamUtil.CopyBytes(readerSource, gaps[2] - 1, gaps[3] + 1, outs);
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:43,代码来源:MakeSignature.cs

示例9: WriteAsync

        public override bool WriteAsync(TransportAsyncCallbackArgs args)
        {
            Fx.Assert(this.writeState.Args == null, "Cannot write when a write is still in progress");
            Windows.Storage.Streams.IBuffer ibuffer;
            if (args.Buffer != null)
            {
                this.writeState.Args = args;
                ibuffer = args.Buffer.AsBuffer(args.Offset, args.Count);
            }
            else
            {
                Fx.Assert(args.ByteBufferList != null, "Buffer list should not be null when buffer is null");
                ArraySegment<byte> buffer;
                if (args.ByteBufferList.Count == 1)
                {
                    ByteBuffer byteBuffer = args.ByteBufferList[0];
                    buffer = new ArraySegment<byte>(byteBuffer.Buffer, byteBuffer.Offset, byteBuffer.Length);
                    this.writeState.Args = args;
                }
                else
                {
                    // Copy all buffers into one big buffer to avoid SSL overhead
                    Fx.Assert(args.Count > 0, "args.Count should be set");
                    ByteBuffer temp = new ByteBuffer(args.Count, false, false);
                    for (int i = 0; i < args.ByteBufferList.Count; ++i)
                    {
                        ByteBuffer byteBuffer = args.ByteBufferList[i];
                        Buffer.BlockCopy(byteBuffer.Buffer, byteBuffer.Offset, temp.Buffer, temp.Length, byteBuffer.Length);
                        temp.Append(byteBuffer.Length);
                    }

                    buffer = new ArraySegment<byte>(temp.Buffer, 0, temp.Length);
                    this.writeState.Args = args;
                    this.writeState.Buffer = temp;
                }

                ibuffer = buffer.Array.AsBuffer(0, buffer.Count);
            }

            var t = this.socket.OutputStream.WriteAsync(ibuffer).AsTask();
            t.ContinueWith(completion =>
            {
                var args2 = this.readState.Args;
                if (completion.IsFaulted)
                {
                    if (Fx.IsFatal(completion.Exception))
                    {
                        throw completion.Exception;
                    }
                    args2.Exception = completion.Exception;
                }
                else
                {
                    args2 = this.writeState.Args;
                    ByteBuffer buffer = this.writeState.Buffer;
                    this.writeState.Reset();

                    if (buffer != null)
                    {
                        buffer.Dispose();
                    }

                    Fx.Assert(args2.Count == completion.Result, "completion must have the same write count");
                    args2.BytesTransfered = args2.Count;
                }

                args2.CompletedSynchronously = false;

                Action<TransportAsyncCallbackArgs> callback = args2.CompletedCallback;
                if (callback != null)
                {
                    args2.CompletedCallback(args2);
                }
            });

            return true;
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:77,代码来源:TlsTransport.UWP.cs

示例10: WriteBytes

 public static void WriteBytes(ByteBuffer buffer, byte[] data, int offset, int count)
 {
     buffer.Validate(true, count);
     Buffer.BlockCopy(data, offset, buffer.Buffer, buffer.WritePos, count);
     buffer.Append(count);
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:6,代码来源:AmqpBitConverter.cs

示例11: WriteFloat

        public static void WriteFloat(ByteBuffer buffer, float data)
        {
            buffer.Validate(true, FixedWidth.Float);
            fixed (byte* d = &buffer.Buffer[buffer.WritePos])
            {
                byte* p = (byte*)&data;
                d[0] = p[3];
                d[1] = p[2];
                d[2] = p[1];
                d[3] = p[0];
            }

            buffer.Append(FixedWidth.Float);
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:14,代码来源:AmqpBitConverter.cs

示例12: WriteULong

        public static void WriteULong(ByteBuffer buffer, ulong data)
        {
            buffer.Validate(true, FixedWidth.ULong);
            fixed (byte* d = &buffer.Buffer[buffer.WritePos])
            {
                byte* p = (byte*)&data;
                d[0] = p[7];
                d[1] = p[6];
                d[2] = p[5];
                d[3] = p[4];
                d[4] = p[3];
                d[5] = p[2];
                d[6] = p[1];
                d[7] = p[0];
            }

            buffer.Append(FixedWidth.ULong);
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:18,代码来源:AmqpBitConverter.cs

示例13: WriteUShort

        public static void WriteUShort(ByteBuffer buffer, ushort data)
        {
            buffer.Validate(true, FixedWidth.UShort);
            fixed (byte* d = &buffer.Buffer[buffer.WritePos])
            {
                byte* p = (byte*)&data;
                d[0] = p[1];
                d[1] = p[0];
            }

            buffer.Append(FixedWidth.UShort);
        }
开发者ID:Azure,项目名称:azure-amqp,代码行数:12,代码来源:AmqpBitConverter.cs

示例14: WriteUByte

 public static void WriteUByte(ByteBuffer buffer, byte data)
 {
     buffer.Validate(true, FixedWidth.UByte);
     buffer.Buffer[buffer.WritePos] = data;
     buffer.Append(FixedWidth.UByte);
 }
开发者ID:Azure,项目名称:azure-amqp,代码行数:6,代码来源:AmqpBitConverter.cs

示例15: WriteDouble

        public static void WriteDouble(ByteBuffer buffer, double data)
        {
            buffer.EnsureSize(FixedWidth.Double);
            fixed (byte* d = &buffer.Buffer[buffer.End])
            {
                byte* p = (byte*)&data;
                d[0] = p[7];
                d[1] = p[6];
                d[2] = p[5];
                d[3] = p[4];
                d[4] = p[3];
                d[5] = p[2];
                d[6] = p[1];
                d[7] = p[0];
            }

            buffer.Append(FixedWidth.Double);
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:18,代码来源:AmqpBitConverter.cs


注:本文中的System.ByteBuffer.Append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。