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

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

public static DecodeLength ( IBerInput input ) : int
input IBerInput
Результат int
        public static int DecodeLength(IBerInput input)
        {
            int value;
             int byteCount;

             value = input.ReadByte();

             if((value & 0x80) != 0)
             {
            byteCount = value & 0x7F;

            if(byteCount == 0)
            {
               value = BerDefinitions.IndefiniteLength; // indefinite length form
            }
            else
            {
               value = 0;

               for( ; byteCount > 0; byteCount--)
                  value = (value << 8) | input.ReadByte();
            }
             }

             return value;
        }

Usage Example

Пример #1
0
        static int DecodeHeader(IBerInput input, BerTag expectedTag)
        {
            var tag = BerEncoding.DecodeTag(input);

            if (tag != expectedTag)
            {
                throw new BerException(4001, String.Format("Expected tag {0}, found tag {1}", tag, expectedTag));
            }

            return(BerEncoding.DecodeLength(input));
        }