public virtual DecodedObject <object> decodeSequence(DecodedObject <object> decodedTag, Type objectClass, ElementInfo elementInfo, Stream stream) { object sequence = createInstanceForElement(objectClass, elementInfo); initDefaultValues(sequence); DecodedObject <object> fieldTag = null; int maxSeqLen = elementInfo.MaxAvailableLen; int sizeOfSequence = 0; if (maxSeqLen == -1 || maxSeqLen > 0) { fieldTag = decodeTag(stream); if (fieldTag != null) { sizeOfSequence += fieldTag.Size; } } PropertyInfo[] fields = elementInfo.getProperties(objectClass); for (int i = 0; i < fields.Length; i++) { PropertyInfo field = fields[i]; DecodedObject <object> obj = decodeSequenceField( fieldTag, sequence, i, field, stream, elementInfo, true ); if (obj != null) { sizeOfSequence += obj.Size; bool isAny = false; if (i + 1 == fields.Length - 1) { ElementInfo info = new ElementInfo(); info.AnnotatedClass = (fields[i + 1]); info.MaxAvailableLen = (elementInfo.MaxAvailableLen); if (elementInfo.hasPreparedInfo()) { info.PreparedInfo = (elementInfo.PreparedInfo.getPropertyMetadata(i + 1)); } else { info.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(fields[i + 1]); } isAny = CoderUtils.isAnyField(fields[i + 1], info); } if (maxSeqLen != -1) { elementInfo.MaxAvailableLen = (maxSeqLen - sizeOfSequence); } if (!isAny) { if (i < fields.Length - 1) { if (maxSeqLen == -1 || elementInfo.MaxAvailableLen > 0) { fieldTag = decodeTag(stream); if (fieldTag != null) { sizeOfSequence += fieldTag.Size; } else { break; } } else { fieldTag = null; } } } } ; } return(new DecodedObject <object>(sequence, sizeOfSequence)); }