Пример #1
0
 /// <summary>
 /// Encodes the content of the object by PER.
 /// </summary>
 /// <param name="buffer">A buffer to which the encoding result will be written.</param>
 /// <remarks>Length is included.</remarks>
 protected override void ValuePerEncode(IAsn1PerEncodingBuffer buffer)
 {
     Asn1StandardProcedure.PerEncodeArray(buffer, Elements, (encodingBuffer, obj) =>
     {
         obj.PerEncode(encodingBuffer);
     },
                                          Constraint != null && Constraint.HasMinSize ? Constraint.MinSize : (long?)null, Constraint != null && Constraint.HasMaxSize ? Constraint.MaxSize : (long?)null);
 }
Пример #2
0
 /// <summary>
 /// Encodes the content of the object by PER.
 /// </summary>
 /// <param name="buffer">A buffer to which the encoding result will be written.</param>
 /// <remarks>Length is included.</remarks>
 protected override void ValuePerEncode(IAsn1PerEncodingBuffer buffer)
 {
     Asn1StandardProcedure.PerEncodeArray(buffer, Value.ToCharArray(),
                                          (encodingBuffer, b) =>
     {
         byte[] result = Encoding.BigEndianUnicode.GetBytes("" + b);
         encodingBuffer.WriteBytes(result);
     }
                                          , Constraint != null && Constraint.HasMinSize ? Constraint.MinSize : (long?)null, Constraint != null && Constraint.HasMaxSize ? Constraint.MaxSize : (long?)null,
                                          true);
 }
        /// <summary>
        /// Encodes the content of the object by PER.
        /// </summary>
        /// <param name="buffer">A buffer to which the encoding result will be written.</param>
        /// <remarks>Length is included.</remarks>
        protected override void ValuePerEncode(IAsn1PerEncodingBuffer buffer)
        {
            if (Value[0] * 40 + Value[1] >= 128)
            {
                throw new NotImplementedException("Ojbect Identifier with first element greater than 127 is not implemented.");
                //Len will be minus 1 while encoding.
            }
            var res = EncodeIdentifier(Value);

            Asn1StandardProcedure.PerEncodeArray <byte>(buffer, res,
                                                        (encodingBuffer, b) =>
            {
                encodingBuffer.WriteByte(b);
            });
        }