protected virtual DecodedObject <object> decodeSet(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, int len, System.IO.Stream stream) { object sequence = createInstanceForElement(objectClass, elementInfo); initDefaultValues(sequence); DecodedObject <object> fieldTag = null; int sizeOfSequence = 0; int maxSeqLen = elementInfo.MaxAvailableLen; if (maxSeqLen == -1 || maxSeqLen > 0) { fieldTag = decodeTag(stream); if (fieldTag != null) { sizeOfSequence += fieldTag.Size; } } PropertyInfo[] fields = elementInfo.getProperties(objectClass); bool fieldEncoded = false; do { for (int i = 0; i < fields.Length; i++) { PropertyInfo field = fields[i]; DecodedObject <object> obj = decodeSequenceField( fieldTag, sequence, i, field, stream, elementInfo, false ); if (obj != null) { fieldEncoded = true; 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; } } else { break; } } } ; } }while (sizeOfSequence < len && fieldEncoded); return(new DecodedObject <object>(sequence, sizeOfSequence)); }