GSF.IO.BinaryStreamBase.Write C# (CSharp) Method

Write() public method

Writes the specifed value to the underlying stream in little-endian format.
public Write ( System.Guid value ) : void
value System.Guid the value to write
return void
        public void Write(Guid value)
        {
            byte* src = (byte*)&value;
            fixed (byte* dst = m_buffer)
            {
                if (BitConverter.IsLittleEndian)
                {
                    //just copy the data
                    *(long*)(dst + 0) = *(long*)(src + 0);
                    *(long*)(dst + 8) = *(long*)(src + 8);
                }
                else
                {
                    //Guid._a (int)  //swap endian
                    dst[0] = src[3];
                    dst[1] = src[2];
                    dst[2] = src[1];
                    dst[3] = src[0];
                    //Guid._b (short) //swap endian
                    dst[4] = src[5];
                    dst[5] = src[4];
                    //Guid._c (short) //swap endian
                    dst[6] = src[7];
                    dst[7] = src[6];
                    //Guid._d - Guid._k (8 bytes)
                    *(long*)(dst + 8) = *(long*)(src + 8);
                }
            }
            Write(m_buffer, 0, 16);
        }
        /// <summary>

Same methods

BinaryStreamBase::Write ( System.DateTime value ) : void
BinaryStreamBase::Write ( bool value ) : void
BinaryStreamBase::Write ( byte value ) : void
BinaryStreamBase::Write ( byte buffer, int length ) : void
BinaryStreamBase::Write ( byte buffer, int offset, int count ) : void
BinaryStreamBase::Write ( decimal value ) : void
BinaryStreamBase::Write ( double value ) : void
BinaryStreamBase::Write ( float value ) : void
BinaryStreamBase::Write ( int value ) : void
BinaryStreamBase::Write ( long value ) : void
BinaryStreamBase::Write ( sbyte value ) : void
BinaryStreamBase::Write ( short value ) : void
BinaryStreamBase::Write ( string value ) : void
BinaryStreamBase::Write ( uint value ) : void
BinaryStreamBase::Write ( ulong value ) : void
BinaryStreamBase::Write ( ushort value ) : void

Usage Example

 public void Save(BinaryStreamBase stream)
 {
     stream.Write((byte)1);
     stream.Write(DatabaseName);
     stream.Write(KeyTypeID);
     stream.Write(ValueTypeID);
     stream.Write(SupportedStreamingModes.Count);
     foreach (var encoding in SupportedStreamingModes)
     {
         encoding.Save(stream);
     }
 }
All Usage Examples Of GSF.IO.BinaryStreamBase::Write