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


C# ByteBuffer.Put方法代码示例

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


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

示例1: WritePayload

 public void WritePayload(ByteBuffer buffer)
 {
     buffer.Put(ClassId);
     buffer.Put(Weight);
     buffer.Put(BodySize);
     buffer.Put(Properties.PropertyFlags);
     Properties.WritePropertyListPayload(buffer);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:8,代码来源:ContentHeaderBody.cs

示例2: WritePayload

 public void WritePayload(ByteBuffer buffer)
 {
     foreach (char c in Header)
     {
         buffer.Put((byte) c);
     }
     buffer.Put(ProtocolClass);
     buffer.Put(ProtocolInstance);
     buffer.Put(ProtocolMajor);
     buffer.Put(ProtocolMinor);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:11,代码来源:ProtocolInitiation.cs

示例3: Read

        //Reads bytes from the Filestream into the bytebuffer
        public static int Read(this FileStream file, ByteBuffer dst, long position)
        {
            lock (_fsReadLock)
            {
                // TODO: check this logic, could probably optimize
                if (position >= file.Length)
                    return 0;

                var original = file.Position;

                file.Seek(position, SeekOrigin.Begin);

                int count = 0;

                for (int i = dst.Position; i < dst.Limit; i++)
                {
                    int v = file.ReadByte();
                    if (v == -1)
                        break;
                    dst.Put((byte) v);
                    count++;
                }

                file.Seek(original, SeekOrigin.Begin);

                return count;
            }
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:29,代码来源:FileStreamExtensions.cs

示例4: Setup

 public void Setup()
 {
    const int size = 50;
    _baseBuffer = ByteBuffer.Allocate(size);
    for ( byte b = 0; b < 10; b++ )
    {
       _baseBuffer.Put(b);
    }
    _baseBuffer.Flip();
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:10,代码来源:SlicedByteBufferTests.cs

示例5: WriteShortStringBytes

      public static void WriteShortStringBytes(ByteBuffer buffer, string s)
      {
         if ( s != null )
         {
            //try
            //{
            //final byte[] encodedString = s.getBytes(STRING_ENCODING);
            byte[] encodedString;
            lock ( DEFAULT_ENCODER )
            {
               encodedString = DEFAULT_ENCODER.GetBytes(s);
            }
            // TODO: check length fits in an unsigned byte
            buffer.Put((byte)encodedString.Length);
            buffer.Put(encodedString);

         } else
         {
            // really writing out unsigned byte
            buffer.Put((byte)0);
         }
      }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:22,代码来源:EncodingUtils.cs

示例6: Read

        //Reads bytes from the Filestream into the bytebuffer
        public static int Read(this FileStream file, ByteBuffer dst, long position)
        {
            // TODO: check this logic, could probably optimize
            if (position >= file.Length)
                return 0;

            var original = file.Position;

            var count = dst.Limit - dst.Position;
            // TODO: (.net port) consider move to async all the way.
            var bytes = ReadBytesAsync(file, (int) position, count).Result;
            dst.Put(bytes);

            file.Seek(original, SeekOrigin.Begin);
            return count;
        }
开发者ID:eladmarg,项目名称:lucene.net,代码行数:17,代码来源:FileStreamExtensions.cs

示例7: WriteShort

 public static void WriteShort(ByteBuffer buffer, short value)
 {
    buffer.Put(value);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:4,代码来源:EncodingUtils.cs

示例8: WriteSByte

 public static void WriteSByte(ByteBuffer buffer, sbyte value)
 {
    buffer.Put(value);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:4,代码来源:EncodingUtils.cs

示例9: WriteChar

 public static void WriteChar(ByteBuffer buffer, char value)
 {
    buffer.Put((byte)value);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:4,代码来源:EncodingUtils.cs

示例10: WriteBoolean

 public static void WriteBoolean(ByteBuffer buffer, bool value)
 {
    buffer.Put((byte)(value ? 1 : 0));
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:4,代码来源:EncodingUtils.cs

示例11: Put

		/// <summary>
		/// Puts an in buffer stream onto an out buffer stream and returns the bytes written.
		/// </summary>
		/// <param name="output"></param>
		/// <param name="input"></param>
		/// <param name="numBytesMax"></param>
		/// <returns></returns>
		public static int Put(ByteBuffer output, ByteBuffer input, int numBytesMax) 
		{
			int limit = input.Limit;
			int numBytesRead = (numBytesMax > input.Remaining) ? input.Remaining : numBytesMax;
			/*
			input.Limit = (int)input.Position + numBytesRead;
			output.Put(input);
			input.Limit = limit;
			*/
			output.Put(input, numBytesRead);
			return numBytesRead;
		}
开发者ID:ResQue1980,项目名称:LoLTeamChecker,代码行数:19,代码来源:ByteBuffer.cs

示例12: WriteLong

 public static void WriteLong(ByteBuffer buffer, long value)
 {
    buffer.Put(value);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:4,代码来源:EncodingUtils.cs

示例13: WriteUnsignedInteger

 public static void WriteUnsignedInteger(ByteBuffer buffer, uint value)
 {
    buffer.Put(value);
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:4,代码来源:EncodingUtils.cs

示例14: WriteLongStringBytes

 public static void WriteLongStringBytes(ByteBuffer buffer, string s, Encoding encoding)
 {
    if ( !(s == null || s.Length <= 0xFFFE) )
    {
       throw new ArgumentException("String too long");
    }
    if ( s != null )
    {
       lock ( encoding )
       {
          byte[] encodedString = encoding.GetBytes(s);
          buffer.Put((uint)encodedString.Length);
          buffer.Put(encodedString);
       }
    } else
    {
       buffer.Put((uint)0);
    }
 }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:19,代码来源:EncodingUtils.cs

示例15: MatFileWriter

        /// <summary>
        /// Writes MLArrays into <c>OutputStream</c>
        /// </summary>
        /// <remarks>
        /// Writes MAT-file header and compressed data (<c>miCompressed</c>).
        /// </remarks>
        /// <param name="stream"><c>Stream</c></param>
        /// <param name="data"><c>Collection</c> of <c>MLArray</c> elements.</param>
        /// <param name="compress">Use data compression?</param>
        public MatFileWriter( BinaryWriter stream, ICollection data, bool compress )
        {
            // Write header
            WriteHeader( stream );

            foreach( MLArray matrix in data )
            {
                if (compress)
                {
                    // Prepare buffer for MATRIX data
                    MemoryStream memstrm = new MemoryStream();
                    BinaryWriter bw = new BinaryWriter(memstrm);
                    // Write MATRIX bytes into buffer
                    WriteMatrix(bw, matrix);

                    // Compress data to save storage
                    memstrm.Position = 0; // Rewind the stream

                    MemoryStream compressed = new MemoryStream();
                    zlib.ZOutputStream zos = new zlib.ZOutputStream(compressed, zlib.zlibConst.Z_DEFAULT_COMPRESSION);

                    byte[] input = new byte[128];
                    int len = 0;
                    while ((len = memstrm.Read(input, 0, input.Length)) > 0)
                        zos.Write(input, 0, len);
                    zos.Flush();
                    zos.Close();  // important to note that the zlib.ZOutputStream needs to close before writting out the data to the Base.stream

                    //write COMPRESSED tag and compressed data into output channel
                    byte[] compressedBytes = compressed.ToArray();
                    ByteBuffer buf = new ByteBuffer(2 * 4 + compressedBytes.Length);
                    buf.PutInt(MatDataTypes.miCOMPRESSED);
                    buf.PutInt(compressedBytes.Length);
                    buf.Put(compressedBytes, 0, compressedBytes.Length);

                    stream.Write(buf.Array());

                    compressed.Close();
                }
                else
                {
                    // Write MATRIX bytes into buffer
                    WriteMatrix(stream, matrix);
                }

            }

            stream.Close();
        }
开发者ID:patrickmaster,项目名称:electre-tri,代码行数:58,代码来源:MatFileWriter.cs


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