Example #1
0
        public override int encodeString(object obj, Stream stream, ElementInfo elementInfo)
        {
            int resultSize = 0;

            byte[] val = CoderUtils.ASN1StringToBuffer(obj, elementInfo);
            resultSize = encodeLength(val.Length, elementInfo, stream);
            doAlign(stream);
            resultSize += val.Length;
            if (val.Length > 0)
            {
                stream.Write(val, 0, val.Length);
            }
            return(resultSize);
        }
Example #2
0
        public override int encodeString(object obj, Stream stream, ElementInfo elementInfo)
        {
            int resultSize = 0, sizeOfString = 0;

            byte[] buffer = CoderUtils.ASN1StringToBuffer(obj, elementInfo);
            sizeOfString = buffer.Length;
            CoderUtils.checkConstraints(sizeOfString, elementInfo);

            stream.Write(buffer, 0, buffer.Length);

            resultSize += sizeOfString;
            resultSize += encodeLength(sizeOfString, stream);
            resultSize += encodeTag(BERCoderUtils.getTagValueForElement(elementInfo, TagClasses.Universal, ElementType.Primitive, CoderUtils.getStringTagForElement(elementInfo)), stream);
            return(resultSize);
        }