BerLib.BerEncoding.EncodeLength C# (CSharp) Метод

EncodeLength() публичный статический Метод

public static EncodeLength ( IBerOutput output, int value ) : int
output IBerOutput
value int
Результат int
        public static int EncodeLength(IBerOutput output, int value)
        {
            int size = 1;

             if(value == BerDefinitions.IndefiniteLength)
             {
            output.WriteByte(0x80);
             }
             else
             {
            if(value <= 0x7F)
            {
               output.WriteByte((byte)(value & 0x7F));
            }
            else
            {
               int integerLength = GetIntegerLength((int)value);
               output.WriteByte((byte)(0x80 | integerLength));

               size += EncodeInteger(output, (int)value, integerLength);
            }
             }

             return size;
        }

Usage Example

Пример #1
0
 static void EncodeHeader(IBerOutput output, BerTag tag, int length)
 {
     BerEncoding.EncodeTag(output, tag);
     BerEncoding.EncodeLength(output, length);
 }