示例#1
0
        public static int EncodeAsciiString(IBerOutput output, string value)
        {
            byte[] bytes = AsciiEncoding.GetBytes(value);

            output.WriteBytes(bytes);

            return(bytes.Length);
        }
示例#2
0
        internal override sealed void EncodeOverride(IBerOutput output)
        {
            if (IsDirty)
            {
                Update();
            }

            output.WriteBytes(_encodedFrameHeader);

            foreach (var node in this)
            {
                node.Encode(output);
            }

            output.WriteBytes(BerEncoding.IndefiniteLengthTerminator);
            output.Flush();
        }
示例#3
0
        public static int EncodeUtf8String(IBerOutput output, string value)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(value);

            output.WriteBytes(bytes);

            return(bytes.Length);
        }
示例#4
0
        /// <summary>
        /// Writes the binary BER representaion of this node to output.
        /// </summary>
        /// <param name="output">The output to write to.</param>
        internal override void EncodeOverride(IBerOutput output)
        {
            if (_encoded == null)
            {
                Update();
            }

            output.WriteBytes(_encoded);
        }
示例#5
0
        static int EncodeObjectSubidentifier(IBerOutput output, int value, List <byte> bytes)
        {
            var size = 1;

            bytes.Clear();
            bytes.Add((byte)(value & 0x7F));

            while ((value = value >> 7) > 0)
            {
                bytes.Add((byte)((value & 0x7F) | 0x80));
                size++;
            }

            bytes.Reverse();
            output.WriteBytes(bytes.ToArray());

            return(size);
        }
示例#6
0
        /// <summary>
        /// Writes the binary BER representaion of this node and its children to output.
        /// </summary>
        /// <param name="output">The output to write to.</param>
        internal override void EncodeOverride(IBerOutput output)
        {
            if (IsDirty)
            {
                Update();
            }

            output.WriteBytes(_encodedHeader);

            var orderedNodes = OrderChildren(_nodes);

            foreach (var node in orderedNodes)
            {
                node.Encode(output);
            }

            if (Parent == null) // root node
            {
                output.Flush();
            }
        }
示例#7
0
        public static int EncodeByteArray(IBerOutput output, byte[] value)
        {
            output.WriteBytes(value);

            return(value.Length);
        }
示例#8
0
        static int EncodeObjectSubidentifier(IBerOutput output, int value, List<byte> bytes)
        {
            var size = 1;

             bytes.Clear();
             bytes.Add((byte)(value & 0x7F));

             while((value = value >> 7) > 0)
             {
            bytes.Add((byte)((value & 0x7F) | 0x80));
            size++;
             }

             bytes.Reverse();
             output.WriteBytes(bytes.ToArray());

             return size;
        }
示例#9
0
        public static int EncodeUtf8String(IBerOutput output, string value)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(value);

             output.WriteBytes(bytes);

             return bytes.Length;
        }
示例#10
0
        public static int EncodeByteArray(IBerOutput output, byte[] value)
        {
            output.WriteBytes(value);

             return value.Length;
        }
示例#11
0
        public static int EncodeAsciiString(IBerOutput output, string value)
        {
            byte[] bytes = AsciiEncoding.GetBytes(value);

             output.WriteBytes(bytes);

             return bytes.Length;
        }
示例#12
0
        internal override sealed void EncodeOverride(IBerOutput output)
        {
            if(IsDirty)
            Update();

             output.WriteBytes(_encodedFrameHeader);

             foreach(var node in this)
            node.Encode(output);

             output.WriteBytes(BerEncoding.IndefiniteLengthTerminator);
             output.Flush();
        }