WriteSmallInt32() public méthode

Writes a 32-bit integer in compressed format, accomodating rooms for some negative values. The minNegativeValue simply offsets the written value. Use CKBinaryReader.ReadNonNegativeSmallInt32(int,int) with the same minNegativeValue to read it back.

Writing a negative value lower than the minNegativeValue is totally possible, however more than 4 bytes will be required for them.

The default value of -1 is perfect to write small integers that are greater or equal to -1.

public WriteSmallInt32 ( int value, int minNegativeValue = -1 ) : void
value int A 32-bit integer (greater or equal to ).
minNegativeValue int Lowest possible negative value.
Résultat void
Exemple #1
0
        void WriteWithoutVersion(CKBinaryWriter w)
        {
            if (w == null)
            {
                throw new ArgumentNullException("w");
            }
            w.Write(_message);
            w.Write(_exceptionTypeName);
            w.Write(_exceptionTypeAQName);
            w.WriteNullableString(_stackTrace);
            w.WriteNullableString(_fileName);
            w.WriteNullableString(_detailedInfo);

            if (_aggregatedExceptions != null)
            {
                w.WriteSmallInt32(_aggregatedExceptions.Length);
                foreach (var agg in _aggregatedExceptions)
                {
                    agg.WriteWithoutVersion(w);
                }
            }
            else
            {
                if (_innerException != null)
                {
                    w.WriteSmallInt32(0);
                    _innerException.WriteWithoutVersion(w);
                }
                else
                {
                    w.WriteSmallInt32(-1);
                }
            }

            if (_loaderExceptions != null)
            {
                w.WriteNonNegativeSmallInt32(_loaderExceptions.Length);
                foreach (var ld in _loaderExceptions)
                {
                    ld.WriteWithoutVersion(w);
                }
            }
            else
            {
                w.WriteNonNegativeSmallInt32(0);
            }
        }
        void WriteWithoutVersion( CKBinaryWriter w )
        {
            if( w == null ) throw new ArgumentNullException( "w" );
            w.Write( _message );
            w.Write( _exceptionTypeName );
            w.Write( _exceptionTypeAQName );
            w.WriteNullableString( _stackTrace );
            w.WriteNullableString( _fileName );
            w.WriteNullableString( _detailedInfo );

            if( _aggregatedExceptions != null )
            {
                w.WriteSmallInt32( _aggregatedExceptions.Length );
                foreach( var agg in _aggregatedExceptions ) agg.WriteWithoutVersion( w );
            }
            else
            {
                if( _innerException != null )
                {
                    w.WriteSmallInt32( 0 );
                    _innerException.WriteWithoutVersion( w );
                }
                else w.WriteSmallInt32( -1 );
            }

            if( _loaderExceptions != null )
            {
                w.WriteNonNegativeSmallInt32( _loaderExceptions.Length );
                foreach( var ld in _loaderExceptions ) ld.WriteWithoutVersion( w );
            }
            else w.WriteNonNegativeSmallInt32( 0 );
        }