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


C# ByteBuffer.ToByteArray方法代码示例

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


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

示例1: AppendAggrMsg

        internal static byte[] AppendAggrMsg(byte[] msg, BsonDocument append, bool isBigEndian)
        {
            List<byte[]> tmp = Helper.SplitByteArray(msg, 4);
            byte[] msgLength = tmp[0];
            byte[] remainning = tmp[1];
            byte[] insertor = append.ToBson();
            if (isBigEndian)
            {
                BsonEndianConvert(insertor, 0, insertor.Length, true);
            }
            int length = Helper.ByteToInt(msgLength, isBigEndian);
            int messageLength = length + Helper.RoundToMultipleXLength(insertor.Length, 4);

            ByteBuffer buf = new ByteBuffer(messageLength);
            if (isBigEndian)
                buf.IsBigEndian = true;
            buf.PushInt(messageLength);
            buf.PushByteArray(remainning);
            buf.PushByteArray(Helper.RoundToMultipleX(insertor, 4));

            if (logger.IsDebugEnabled)
            {
                StringWriter buff = new StringWriter();
                foreach (byte by in insertor)
                {
                    buff.Write(string.Format("{0:X}", by));
                }
                logger.Debug("Aggregate Append string==>" + buff.ToString() + "<==");
            }
            return buf.ToByteArray();
        }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:31,代码来源:SDBMessageHelper.cs

示例2: SetKeyPrefix

 public void SetKeyPrefix(ByteBuffer prefix)
 {
     _prefix = prefix.ToByteArray();
     _prefixKeyStart = _prefix.Length == 0 ? 0 : -1;
     _prefixKeyCount = -1;
     InvalidateCurrentKey();
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:7,代码来源:KeyValueDBTransaction.cs

示例3: SetKeyPrefix

 public void SetKeyPrefix(ByteBuffer prefix)
 {
     _prefix = prefix.ToByteArray();
     if (_prefix.Length == 0)
     {
         _prefixKeyStart = 0;
     }
     else
     {
         _prefixKeyStart = -1;
     }
     _prefixKeyCount = -1;
     InvalidateCurrentKey();
 }
开发者ID:Xamarui,项目名称:BTDB,代码行数:14,代码来源:InMemoryKeyValueDBTransaction.cs

示例4: WriteCrossReferenceTable

            /**
            * Returns the CrossReferenceTable of the <CODE>Body</CODE>.
            * @param os
            * @param root
            * @param info
            * @param encryption
            * @param fileID
            * @param prevxref
            * @throws IOException
            */
            internal void WriteCrossReferenceTable(Stream os, PdfIndirectReference root, PdfIndirectReference info, PdfIndirectReference encryption, PdfObject fileID, int prevxref)
            {
                int refNumber = 0;
                if (writer.FullCompression) {
                    FlushObjStm();
                    refNumber = IndirectReferenceNumber;
                    xrefs[new PdfCrossReference(refNumber, position)] = null;
                }
                PdfCrossReference entry = (PdfCrossReference)((DictionaryEntry)xrefs.Begin.Current).Key;
                int first = entry.Refnum;
                int len = 0;
                ArrayList sections = new ArrayList();
                for (k_Iterator i = xrefs.Begin.Clone(); i != xrefs.End; i.Next()) {
                    entry = (PdfCrossReference)((DictionaryEntry)i.Current).Key;
                    if (first + len == entry.Refnum)
                        ++len;
                    else {
                        sections.Add(first);
                        sections.Add(len);
                        first = entry.Refnum;
                        len = 1;
                    }
                }
                sections.Add(first);
                sections.Add(len);
                if (writer.FullCompression) {
                    int mid = 4;
                    uint mask = 0xff000000;
                    for (; mid > 1; --mid) {
                        if ((mask & position) != 0)
                            break;
                        mask >>= 8;
                    }
                    ByteBuffer buf = new ByteBuffer();

                    for (k_Iterator i = xrefs.Begin.Clone(); i != xrefs.End; i.Next()) {
                        entry = (PdfCrossReference)((DictionaryEntry)i.Current).Key;
                        entry.ToPdf(mid, buf);
                    }
                    PdfStream xr = new PdfStream(buf.ToByteArray());
                    buf = null;
                    xr.FlateCompress();
                    xr.Put(PdfName.SIZE, new PdfNumber(Size));
                    xr.Put(PdfName.ROOT, root);
                    if (info != null) {
                        xr.Put(PdfName.INFO, info);
                    }
                    if (encryption != null)
                        xr.Put(PdfName.ENCRYPT, encryption);
                    if (fileID != null)
                        xr.Put(PdfName.ID, fileID);
                    xr.Put(PdfName.W, new PdfArray(new int[]{1, mid, 2}));
                    xr.Put(PdfName.TYPE, PdfName.XREF);
                    PdfArray idx = new PdfArray();
                    for (int k = 0; k < sections.Count; ++k)
                        idx.Add(new PdfNumber((int)sections[k]));
                    xr.Put(PdfName.INDEX, idx);
                    if (prevxref > 0)
                        xr.Put(PdfName.PREV, new PdfNumber(prevxref));
                    PdfEncryption enc = writer.crypto;
                    writer.crypto = null;
                    PdfIndirectObject indirect = new PdfIndirectObject(refNumber, xr, writer);
                    indirect.WriteTo(writer.Os);
                    writer.crypto = enc;
                }
                else {
                    byte[] tmp = GetISOBytes("xref\n");
                    os.Write(tmp, 0, tmp.Length);
                    k_Iterator i = xrefs.Begin.Clone();
                    for (int k = 0; k < sections.Count; k += 2) {
                        first = (int)sections[k];
                        len = (int)sections[k + 1];
                        tmp = GetISOBytes(first.ToString());
                        os.Write(tmp, 0, tmp.Length);
                        os.WriteByte((byte)' ');
                        tmp = GetISOBytes(len.ToString());
                        os.Write(tmp, 0, tmp.Length);
                        os.WriteByte((byte)'\n');
                        while (len-- > 0) {
                            entry = (PdfCrossReference)((DictionaryEntry)i.Current).Key;
                            entry.ToPdf(os);
                            i.Next();
                        }
                    }
                }
            }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:96,代码来源:PdfWriter.cs

示例5: CreateInfoId

 public static PdfObject CreateInfoId(byte[] id, bool modified) {
     ByteBuffer buf = new ByteBuffer(90);
     buf.Append('[').Append('<');
     if(id.Length != 16)
         id = CreateDocumentId();
     for (int k = 0; k < 16; ++k)
         buf.AppendHex(id[k]);
     buf.Append('>').Append('<');
     if (modified)
         id = CreateDocumentId();
     for (int k = 0; k < 16; ++k)
         buf.AppendHex(id[k]);
     buf.Append('>').Append(']');
     buf.Close();
     return new PdfLiteral(buf.ToByteArray());
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:16,代码来源:PdfEncryption.cs

示例6: AlterContents

 virtual internal protected void AlterContents() {
     foreach (PageStamp ps in pagesToContent.Values) {
         PdfDictionary pageN = ps.pageN;
         MarkUsed(pageN);
         PdfArray ar = null;
         PdfObject content = PdfReader.GetPdfObject(pageN.Get(PdfName.CONTENTS), pageN);
         if (content == null) {
             ar = new PdfArray();
             pageN.Put(PdfName.CONTENTS, ar);
         }
         else if (content.IsArray()) {
             ar = new PdfArray((PdfArray)content);
             pageN.Put(PdfName.CONTENTS, ar);
         }
         else if (content.IsStream()) {
             ar = new PdfArray();
             ar.Add(pageN.Get(PdfName.CONTENTS));
             pageN.Put(PdfName.CONTENTS, ar);
         }
         else {
             ar = new PdfArray();
             pageN.Put(PdfName.CONTENTS, ar);
         }
         ByteBuffer out_p = new ByteBuffer();
         if (ps.under != null) {
             out_p.Append(PdfContents.SAVESTATE);
             ApplyRotation(pageN, out_p);
             out_p.Append(ps.under.InternalBuffer);
             out_p.Append(PdfContents.RESTORESTATE);
         }
         if (ps.over != null)
             out_p.Append(PdfContents.SAVESTATE);
         PdfStream stream = new PdfStream(out_p.ToByteArray());
         stream.FlateCompress(compressionLevel);
         ar.AddFirst(AddToBody(stream).IndirectReference);
         out_p.Reset();
         if (ps.over != null) {
             out_p.Append(' ');
             out_p.Append(PdfContents.RESTORESTATE);
             ByteBuffer buf = ps.over.InternalBuffer;
             out_p.Append(buf.Buffer, 0, ps.replacePoint);
             out_p.Append(PdfContents.SAVESTATE);
             ApplyRotation(pageN, out_p);
             out_p.Append(buf.Buffer, ps.replacePoint, buf.Size - ps.replacePoint);
             out_p.Append(PdfContents.RESTORESTATE);
             stream = new PdfStream(out_p.ToByteArray());
             stream.FlateCompress(compressionLevel);
             ar.Add(AddToBody(stream).IndirectReference);
         }
         AlterResources(ps);
     }
 }
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:52,代码来源:PdfStamperImp.cs

示例7: AssembleHeader

        private static byte[] AssembleHeader(int messageLength, ulong requestID,
            byte[] nodeID, int operationCode, bool isBigEndian)
        {
            ByteBuffer buf = new ByteBuffer(MESSAGE_HEADER_LENGTH);
            if (isBigEndian)
                buf.IsBigEndian = true;

            buf.PushInt(messageLength);
            buf.PushInt(operationCode);
            buf.PushByteArray(nodeID);
            buf.PushLong((long)requestID);

            return buf.ToByteArray();
        }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:14,代码来源:SDBMessageHelper.cs

示例8: BuildInsertRequest

        internal static byte[] BuildInsertRequest(SDBMessage sdbMessage, bool isBigEndian)
        {
            int opCode = (int)sdbMessage.OperationCode;
            string collectionName = sdbMessage.CollectionFullName;
            int version = sdbMessage.Version;
            short w = sdbMessage.W;
            short padding = sdbMessage.Padding;
            int flags = sdbMessage.Flags;
            ulong requestID = sdbMessage.RequestID;
            byte[] collByteArray = System.Text.Encoding.UTF8.GetBytes(collectionName);
            int collectionNameLength = collByteArray.Length;

            byte[] insertor = sdbMessage.Insertor.ToBson();
            byte[] nodeID = sdbMessage.NodeID;

            if (isBigEndian)
            {
                BsonEndianConvert(insertor, 0, insertor.Length, true);
            }
            // calculate the total length of the packet which to send
            int messageLength = Helper.RoundToMultipleXLength(
                MESSAGE_OPINSERT_LENGTH + collectionNameLength, 4)
                + Helper.RoundToMultipleXLength(insertor.Length, 4);
            // put all the part of packet into a list, and then transform the list into byte[]
            // we need byte[] while sending
            List<byte[]> fieldList = new List<byte[]>();
            // let's put the packet head into list
            fieldList.Add(AssembleHeader(messageLength, requestID, nodeID, opCode, isBigEndian));
            ByteBuffer buf = new ByteBuffer(16);
            if (isBigEndian)
                buf.IsBigEndian = true;
            buf.PushInt(version);
            buf.PushShort(w);
            buf.PushShort(padding);
            buf.PushInt(flags);
            buf.PushInt(collectionNameLength);

            fieldList.Add(buf.ToByteArray());
            // cl name also in the packet head, we need one more byte for '\0'
            byte[] newCollectionName = new byte[collectionNameLength + 1];
            for (int i = 0; i < collectionNameLength; i++)
                newCollectionName[i] = collByteArray[i];

            fieldList.Add(Helper.RoundToMultipleX(newCollectionName, 4));
            // we have finish preparing packet head
            // let's put the content into packet
            fieldList.Add(Helper.RoundToMultipleX(insertor, 4));
            // transform the list into byte[]
            byte[] msgInByteArray = Helper.ConcatByteArray(fieldList);

            if (logger.IsDebugEnabled)
            {
                StringWriter buff = new StringWriter();
                foreach (byte by in msgInByteArray)
                {
                    buff.Write(string.Format("{0:X}", by));
                }
                logger.Debug("Insert Request string==>" + buff.ToString() + "<==");
            }
            return msgInByteArray;
        }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:61,代码来源:SDBMessageHelper.cs

示例9: ByteStore

 internal ByteStore(PRStream str)
 {
     ByteBuffer bb = new ByteBuffer();
     int level = 100;
     SerObject(str, level, bb);
     this.b = bb.ToByteArray();
 }
开发者ID:jomamorales,项目名称:createPDF,代码行数:7,代码来源:PdfSmartCopy.cs

示例10: ReadAllBytes

        /// <summary>
        /// Read all the bytes from a stream
        /// </summary>
        private static byte[] ReadAllBytes(Stream stream)
        {
            ByteBuffer byteBuffer = new ByteBuffer();
            try
            {

                byte[] buffer = new byte[8192];

                int bytesRead = 0;

                while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) > 0)
                {
                    //append them to our byte buffer
                    byteBuffer.Append(buffer, bytesRead);
                }
            }
            catch (Exception)
            {
                byteBuffer = null;
            }

            return (byteBuffer != null) ? byteBuffer.ToByteArray() : null;
        }
开发者ID:zoompf,项目名称:SPDYCheck,代码行数:26,代码来源:SimpleRequestor.cs

示例11: AlterContents

 public void AlterContents()
 {
     if (over == null && under == null)
         return;
     PdfArray ar = null;
     PdfObject content = PdfReader.GetPdfObject(pageN.Get(PdfName.CONTENTS), pageN);
     if (content == null) {
         ar = new PdfArray();
         pageN.Put(PdfName.CONTENTS, ar);
     }
     else if (content.IsArray()) {
         ar = (PdfArray)content;
     }
     else if (content.IsStream()) {
         ar = new PdfArray();
         ar.Add(pageN.Get(PdfName.CONTENTS));
         pageN.Put(PdfName.CONTENTS, ar);
     }
     else {
         ar = new PdfArray();
         pageN.Put(PdfName.CONTENTS, ar);
     }
     ByteBuffer out_p = new ByteBuffer();
     if (under != null) {
         out_p.Append(PdfContents.SAVESTATE);
         ApplyRotation(pageN, out_p);
         out_p.Append(under.InternalBuffer);
         out_p.Append(PdfContents.RESTORESTATE);
     }
     if (over != null)
         out_p.Append(PdfContents.SAVESTATE);
     PdfStream stream = new PdfStream(out_p.ToByteArray());
     stream.FlateCompress(cstp.CompressionLevel);
     PdfIndirectReference ref1 = cstp.AddToBody(stream).IndirectReference;
     ar.AddFirst(ref1);
     out_p.Reset();
     if (over != null) {
         out_p.Append(' ');
         out_p.Append(PdfContents.RESTORESTATE);
         out_p.Append(PdfContents.SAVESTATE);
         ApplyRotation(pageN, out_p);
         out_p.Append(over.InternalBuffer);
         out_p.Append(PdfContents.RESTORESTATE);
         stream = new PdfStream(out_p.ToByteArray());
         stream.FlateCompress(cstp.CompressionLevel);
         ar.Add(cstp.AddToBody(stream).IndirectReference);
     }
     pageN.Put(PdfName.RESOURCES, pageResources.Resources);
 }
开发者ID:boecko,项目名称:iTextSharp,代码行数:49,代码来源:PdfCopy.cs

示例12: BuildSysInfoRequest

        internal static byte[] BuildSysInfoRequest()
        {
            ByteBuffer buf = new ByteBuffer(12);
            buf.PushByteArray(BitConverter.GetBytes(SequoiadbConstants.MSG_SYSTEM_INFO_LEN));
            buf.PushByteArray(BitConverter.GetBytes(SequoiadbConstants.MSG_SYSTEM_INFO_EYECATCHER));
            buf.PushInt(12);

            return buf.ToByteArray();
        }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:9,代码来源:SDBMessageHelper.cs

示例13: BuildUpdateRequest

        internal static byte[] BuildUpdateRequest(SDBMessage sdbMessage, bool isBigEndian)
        {
            int opCode = (int)sdbMessage.OperationCode;
            string collectionName = sdbMessage.CollectionFullName;
            int version = sdbMessage.Version;
            short w = sdbMessage.W;
            short padding = sdbMessage.Padding;
            int flags = sdbMessage.Flags;
            ulong requestID = sdbMessage.RequestID;
            byte[] nodeID = sdbMessage.NodeID;
            byte[] collByteArray = System.Text.Encoding.UTF8.GetBytes(collectionName);
            int collectionNameLength = collByteArray.Length;

            byte[] matcher = sdbMessage.Matcher.ToBson();
            byte[] hint = sdbMessage.Hint.ToBson();
            byte[] modifier = sdbMessage.Modifier.ToBson();
            if (isBigEndian)
            {
                BsonEndianConvert(matcher, 0, matcher.Length, true);
                BsonEndianConvert(modifier, 0, modifier.Length, true);
                BsonEndianConvert(hint, 0, hint.Length, true);
            }

            int messageLength = Helper.RoundToMultipleXLength(
                MESSAGE_OPUPDATE_LENGTH + collectionNameLength, 4)
                + Helper.RoundToMultipleXLength(matcher.Length, 4)
                + Helper.RoundToMultipleXLength(hint.Length, 4)
                + Helper.RoundToMultipleXLength(modifier.Length, 4);

            List<byte[]> fieldList = new List<byte[]>();
            fieldList.Add(AssembleHeader(messageLength, requestID, nodeID, opCode, isBigEndian));
            ByteBuffer buf = new ByteBuffer(16);
            if (isBigEndian)
                buf.IsBigEndian = true;
            buf.PushInt(version);
            buf.PushShort(w);
            buf.PushShort(padding);
            buf.PushInt(flags);
            buf.PushInt(collectionNameLength);

            fieldList.Add(buf.ToByteArray());

            byte[] newCollectionName = new byte[collectionNameLength + 1];
            for (int i = 0; i < collectionNameLength; i++)
                newCollectionName[i] = collByteArray[i];

            fieldList.Add(Helper.RoundToMultipleX(newCollectionName, 4));
            fieldList.Add(Helper.RoundToMultipleX(matcher, 4));
            fieldList.Add(Helper.RoundToMultipleX(modifier, 4));
            fieldList.Add(Helper.RoundToMultipleX(hint, 4));

            byte[] msgInByteArray = Helper.ConcatByteArray(fieldList);

            if (logger.IsDebugEnabled)
            {
                StringWriter buff = new StringWriter();
                foreach (byte by in msgInByteArray)
                {
                    buff.Write(string.Format("{0:X}", by));
                }
                logger.Debug("Update Request string==>" + buff.ToString() + "<==");
            }
            return msgInByteArray;
        }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:64,代码来源:SDBMessageHelper.cs

示例14: BuildRemoveLobRequest

        internal static byte[] BuildRemoveLobRequest(SDBMessage sdbMessage, bool isBigEndian)
        {
            /*
                /// remove lob reg msg is |MsgOpLob|bsonobj|
                struct _MsgHeader
                {
                   SINT32 messageLength ; // total message size, including this
                   SINT32 opCode ;        // operation code
                   UINT32 TID ;           // client thead id
                   MsgRouteID routeID ;   // route id 8 bytes
                   UINT64 requestID ;     // identifier for this message
                } ;

                typedef struct _MsgOpLob
                {
                   MsgHeader header ;
                   INT32 version ;
                   SINT16 w ;
                   SINT16 padding ;
                   SINT32 flags ;
                   SINT64 contextID ;
                   UINT32 bsonLen ;
                } MsgOpLob ;
             */
            // get info to build _MsgOpLob
            // MsgHeader
            int messageLength = 0;
            int opCode = (int)sdbMessage.OperationCode;
            byte[] nodeID = sdbMessage.NodeID;
            ulong requestID = sdbMessage.RequestID;
            // the rest part of _MsgOpLOb
            int version = sdbMessage.Version;
            short w = sdbMessage.W;
            short padding = sdbMessage.Padding;
            int flags = sdbMessage.Flags;
            long contextID = sdbMessage.ContextIDList[0];
            uint bsonLen = 0;
            byte[] bLob = sdbMessage.Matcher.ToBson();
            bsonLen = (uint)bLob.Length;
            if (isBigEndian)
            {
                BsonEndianConvert(bLob, 0, bLob.Length, true);
            }
            // calculate total length
            messageLength = MESSAGE_OPLOB_LENGTH +
                            Helper.RoundToMultipleXLength(bLob.Length, 4);

            // build a array list for return
            List<byte[]> fieldList = new List<byte[]>();
            // add MsgHead
            fieldList.Add(AssembleHeader(messageLength, requestID, nodeID, opCode, isBigEndian));
            // add the rest part of MsgOpLob
            ByteBuffer buf = new ByteBuffer(MESSAGE_OPLOB_LENGTH - MESSAGE_HEADER_LENGTH);
            if (isBigEndian)
            {
                buf.IsBigEndian = true;
            }
            buf.PushInt(version);
            buf.PushShort(w);
            buf.PushShort(padding);
            buf.PushInt(flags);
            buf.PushLong(contextID);
            buf.PushInt((int)bsonLen);
            // add msg header
            fieldList.Add(buf.ToByteArray());
            // add msg body
            fieldList.Add(Helper.RoundToMultipleX(bLob, 4));

            // convert to byte array and return
            byte[] msgInByteArray = Helper.ConcatByteArray(fieldList);

            if (logger.IsDebugEnabled)
            {
                StringWriter buff = new StringWriter();
                foreach (byte by in msgInByteArray)
                {
                    buff.Write(string.Format("{0:X}", by));
                }
                logger.Debug("Remove Lob Request string==>" + buff.ToString() + "<==");
            }
            return msgInByteArray;
        }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:82,代码来源:SDBMessageHelper.cs

示例15: BuildReadLobRequest

        internal static byte[] BuildReadLobRequest(SDBMessage sdbMessage, bool isBigEndian)
        {
            /*
                /// read req msg is |MsgOpLob|_MsgLobTuple|
                struct _MsgHeader
                {
                   SINT32 messageLength ; // total message size, including this
                   SINT32 opCode ;        // operation code
                   UINT32 TID ;           // client thead id
                   MsgRouteID routeID ;   // route id 8 bytes
                   UINT64 requestID ;     // identifier for this message
                } ;

                typedef struct _MsgOpLob
                {
                   MsgHeader header ;
                   INT32 version ;
                   SINT16 w ;
                   SINT16 padding ;
                   SINT32 flags ;
                   SINT64 contextID ;
                   UINT32 bsonLen ;
                } MsgOpLob ;

                union _MsgLobTuple
                {
                   struct
                   {
                      UINT32 len ;
                      UINT32 sequence ;
                      SINT64 offset ;
                   } columns ;

                   CHAR data[16] ;
                } ;
             */
            // get info to build _MsgOpLob
            // MsgHeader
            int messageLength = 0;
            int opCode = (int)sdbMessage.OperationCode;
            byte[] nodeID = sdbMessage.NodeID;
            ulong requestID = sdbMessage.RequestID;
            // the rest part of _MsgOpLOb
            int version = sdbMessage.Version;
            short w = sdbMessage.W;
            short padding = sdbMessage.Padding;
            int flags = sdbMessage.Flags;
            long contextID = sdbMessage.ContextIDList[0];
            uint bsonLen = sdbMessage.BsonLen;
            // MsgLobTuple
            uint length = sdbMessage.LobLen;
            uint sequence = sdbMessage.LobSequence;
            long offset = sdbMessage.LobOffset;
            // calculate total length
            messageLength = MESSAGE_OPLOB_LENGTH + MESSAGE_LOBTUPLE_LENGTH;
            // build a array list for return
            List<byte[]> fieldList = new List<byte[]>();
            // add MsgHead
            fieldList.Add(AssembleHeader(messageLength, requestID, nodeID, opCode, isBigEndian));
            // add the rest part of MsgOpLob and MsgLobTuple
            ByteBuffer buf = new ByteBuffer(MESSAGE_OPLOB_LENGTH - MESSAGE_HEADER_LENGTH + MESSAGE_LOBTUPLE_LENGTH);
            if (isBigEndian)
            {
                buf.IsBigEndian = true;
            }
            buf.PushInt(version);
            buf.PushShort(w);
            buf.PushShort(padding);
            buf.PushInt(flags);
            buf.PushLong(contextID);
            buf.PushInt((int)bsonLen);

            buf.PushInt((int)length);
            buf.PushInt((int)sequence);
            buf.PushLong(offset);
            fieldList.Add(buf.ToByteArray());
            // convert to byte array and return
            byte[] msgInByteArray = Helper.ConcatByteArray(fieldList);

            if (logger.IsDebugEnabled)
            {
                StringWriter buff = new StringWriter();
                foreach (byte by in msgInByteArray)
                {
                    buff.Write(string.Format("{0:X}", by));
                }
                logger.Debug("Read Lob Request string==>" + buff.ToString() + "<==");
            }
            return msgInByteArray;
        }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:90,代码来源:SDBMessageHelper.cs


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