Esempio n. 1
0
        public virtual int encodeSequenceField(object obj, int fieldIdx, PropertyInfo field, Stream stream, ElementInfo elementInfo)
        {
            ElementInfo info = new ElementInfo();

            info.AnnotatedClass = field;

            if (elementInfo.hasPreparedInfo())
            {
                info.PreparedInfo = elementInfo.PreparedInfo.getPropertyMetadata(fieldIdx);
            }
            else
            {
                info.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(field);
            }

            int resultSize = 0;

            if (CoderUtils.isNullField(field, info))
            {
                return(encodeNull(obj, stream, elementInfo));
            }
            else
            {
                object invokeObjResult = invokeGetterMethodForField(field, obj, info);
                if (invokeObjResult != null)
                {
                    resultSize += encodeClassType(invokeObjResult, stream, info);
                }
                else
                {
                    CoderUtils.checkForOptionalField(field, info);
                }
            }
            return(resultSize);
        }
Esempio n. 2
0
        public virtual DecodedObject <object> decodeSequenceField(DecodedObject <object> fieldTag, object sequenceObj, int fieldIdx, PropertyInfo field, Stream stream, ElementInfo elementInfo, bool checkOptional)
        {
            ElementInfo info = new ElementInfo();

            info.AnnotatedClass  = field;
            info.MaxAvailableLen = elementInfo.MaxAvailableLen;
            if (elementInfo.hasPreparedInfo())
            {
                info.PreparedInfo = elementInfo.PreparedInfo.getPropertyMetadata(fieldIdx);
            }
            else
            {
                info.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(field);
            }

            if (CoderUtils.isNullField(field, info))
            {
                return(decodeNull(fieldTag, field.PropertyType, info, stream));
            }
            else
            {
                DecodedObject <object> val = decodeClassType(fieldTag, field.PropertyType, info, stream);
                if (val != null)
                {
                    invokeSetterMethodForField(field, sequenceObj, val.Value, info);
                }
                else
                {
                    if (checkOptional)
                    {
                        CoderUtils.checkForOptionalField(field, info);
                    }
                }
                return(val);
            }
        }