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

Write() public method

Writes the specifed value to the underlying stream in little-endian format.
public Write ( decimal value ) : void
value decimal the value to write
return void
        public void Write(decimal value)
        {
            if (BitConverter.IsLittleEndian)
            {
                fixed (byte* lp = m_buffer)
                {
                    *(decimal*)(lp) = value;
                }
            }
            else
            {
                byte* ptr = (byte*)&value;
                m_buffer[0] = ptr[3];
                m_buffer[1] = ptr[2];
                m_buffer[2] = ptr[1];
                m_buffer[3] = ptr[0];
                m_buffer[4] = ptr[7];
                m_buffer[5] = ptr[6];
                m_buffer[6] = ptr[5];
                m_buffer[7] = ptr[4];
                m_buffer[8] = ptr[11];
                m_buffer[9] = ptr[10];
                m_buffer[10] = ptr[9];
                m_buffer[11] = ptr[8];
                m_buffer[12] = ptr[15];
                m_buffer[13] = ptr[14];
                m_buffer[14] = ptr[13];
                m_buffer[15] = ptr[12];
            }
            Write(m_buffer, 0, 16);
        }
        /// <summary>

Same methods

BinaryStreamBase::Write ( System.DateTime value ) : void
BinaryStreamBase::Write ( System.Guid 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 ( 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