Esempio n. 1
0
        public virtual void encode <T>(T obj, Stream stream)
        {
            object      ob       = (object)obj;
            ElementInfo elemInfo = new ElementInfo();

            elemInfo.AnnotatedClass = obj.GetType();
            int sizeOfEncodedBytes = 0;

            if (obj is IASN1PreparedElement)
            {
                sizeOfEncodedBytes = encodePreparedElement(obj, stream, elemInfo);
            }
            else
            {
                elemInfo.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(obj.GetType());
                sizeOfEncodedBytes       = encodeClassType(obj, stream, elemInfo);
            }


            if (sizeOfEncodedBytes == 0)
            {
                throw new ArgumentException("Unable to find any supported annotation for class type: " + obj.GetType());
            }
            ;
        }
Esempio n. 2
0
        public virtual T decode <T>(Stream stream)
        {
            Type objectClass = typeof(T);

            ElementInfo elemInfo = new ElementInfo();

            elemInfo.AnnotatedClass = objectClass;
            object objectInstance = null;

            if (CoderUtils.isImplements(objectClass, (typeof(IASN1PreparedElement))))
            {
                objectInstance = createInstanceForElement(objectClass, elemInfo);
            }

            if (objectInstance != null && objectInstance is IASN1PreparedElement)
            {
                elemInfo.PreparedInstance = objectInstance;
                return((T)decodePreparedElement(decodeTag(stream), objectClass, elemInfo, stream).Value);
            }
            else
            {
                elemInfo.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(objectClass);
                return((T)decodeClassType(decodeTag(stream), objectClass, elemInfo, stream).Value);
            }
        }
Esempio n. 3
0
        public virtual int encodeEnum(object obj, Stream stream, ElementInfo elementInfo)
        {
            int          resultSize = 0;
            PropertyInfo field      =
                obj.GetType().GetProperty("Value");
            object result    = invokeGetterMethodForField(field, obj, null);
            Type   enumClass = null;

            foreach (MemberInfo member in obj.GetType().GetMembers())
            {
                if (member is Type)
                {
                    Type cls = (Type)member;
                    if (cls.IsEnum)
                    {
                        enumClass = cls;
                        foreach (FieldInfo enumItem in cls.GetFields())
                        {
                            if (CoderUtils.isAttributePresent <ASN1EnumItem>(enumItem))
                            {
                                if (enumItem.Name.Equals(result.ToString(), StringComparison.CurrentCultureIgnoreCase))
                                {
                                    elementInfo.AnnotatedClass = enumItem;
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }
            resultSize += encodeEnumItem(result, enumClass, stream, elementInfo);
            return(resultSize);
        }
Esempio n. 4
0
        public virtual int encodeBoxedType(object obj, Stream stream, ElementInfo elementInfo)
        {
            PropertyInfo field = obj.GetType().GetProperty("Value");

            elementInfo.AnnotatedClass = field;

            if (elementInfo.ASN1ElementInfo == null)
            {
                elementInfo.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(field);
            }
            else
            {
                if (!elementInfo.ASN1ElementInfo.HasTag)
                {
                    ASN1Element fieldInfo = CoderUtils.getAttribute <ASN1Element>(field);
                    if (fieldInfo != null && fieldInfo.HasTag)
                    {
                        elementInfo.ASN1ElementInfo.HasTag        = true;
                        elementInfo.ASN1ElementInfo.TagClass      = fieldInfo.TagClass;
                        elementInfo.ASN1ElementInfo.IsImplicitTag = fieldInfo.IsImplicitTag;
                        elementInfo.ASN1ElementInfo.Tag           = fieldInfo.Tag;
                    }
                }
            }
            if (CoderUtils.isAttributePresent <ASN1Null>(field))
            {
                return(encodeNull(obj, stream, elementInfo));
            }
            else
            {
                return(encodeClassType(invokeGetterMethodForField(field, obj, elementInfo), stream, elementInfo));
            }
        }
Esempio n. 5
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. 6
0
        private void setupAccessors(Type objectClass, PropertyInfo field)
        {
            try
            {
                doSelectMethod = CoderUtils.findDoSelectMethodForField(field, objectClass);
            }
            catch (Exception)
            {
            }

            try
            {
                isSelectedMethod = CoderUtils.findIsSelectedMethodForField(field, objectClass);
            }
            catch (Exception)
            {
            }

            try
            {
                isPresentMethod = CoderUtils.findIsPresentMethodForField(field, objectClass);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 7
0
        public virtual object invokeGetterMethodForField(PropertyInfo field, object obj, ElementInfo info)
        {
            MethodInfo method = null;

            if (info != null && info.hasPreparedInfo())
            {
                method = info.PreparedInfo.IsPresentMethod;
            }
            else
            {
                method = CoderUtils.findIsPresentMethodForField(field, obj.GetType());
            }
            if (method != null)
            {
                if ((bool)method.Invoke(obj, null))
                {
                    return(field.GetValue(obj, null));
                }
                else
                {
                    return(null);
                }
            }
            return(field.GetValue(obj, null));
        }
Esempio n. 8
0
 private void setupConstraint(ICustomAttributeProvider annotated)
 {
     if (CoderUtils.isAttributePresent <ASN1SizeConstraint>(annotated))
     {
         constraint = new ASN1SizeConstraintMetadata(CoderUtils.getAttribute <ASN1SizeConstraint>(annotated));
     }
     else if (CoderUtils.isAttributePresent <ASN1ValueRangeConstraint>(annotated))
     {
         constraint = new ASN1ValueRangeConstraintMetadata(CoderUtils.getAttribute <ASN1ValueRangeConstraint>(annotated));
     }
 }
Esempio n. 9
0
 public virtual bool invokeSelectedMethodForField(PropertyInfo field, object obj, ElementInfo info)
 {
     if (info != null && info.hasPreparedInfo())
     {
         return((bool)info.PreparedInfo.invokeIsSelectedMethod(obj, null));
     }
     else
     {
         MethodInfo method = CoderUtils.findIsSelectedMethodForField(field, obj.GetType());
         return((bool)method.Invoke(obj, null));
     }
 }
Esempio n. 10
0
 public void invokeSelectMethodForField(PropertyInfo field, object obj, object param, ElementInfo info)
 {
     if (info.hasPreparedInfo())
     {
         info.PreparedInfo.invokeDoSelectMethod(obj, param);
     }
     else
     {
         MethodInfo method = CoderUtils.findDoSelectMethodForField(field, obj.GetType());
         method.Invoke(obj, new[] { param });
     }
 }
Esempio n. 11
0
        public virtual DecodedObject <object> decodeEnum(DecodedObject <object> decodedTag, Type objectClass, ElementInfo elementInfo, Stream stream)
        {
            Type enumClass = null;

            foreach (MemberInfo member in objectClass.GetMembers())
            {
                if (member is Type)
                {
                    Type cls = (Type)member;
                    if (cls.IsEnum)
                    {
                        enumClass = cls;
                        break;
                    }
                }
            }
            ;

            PropertyInfo field = objectClass.GetProperty("Value");


            DecodedObject <object> itemValue = decodeEnumItem(decodedTag, field.PropertyType, enumClass, elementInfo, stream);

            FieldInfo param = null;

            if (itemValue != null)
            {
                object result = createInstanceForElement(objectClass, elementInfo);

                foreach (FieldInfo enumItem in enumClass.GetFields())
                {
                    if (CoderUtils.isAttributePresent <ASN1EnumItem>(enumItem))
                    {
                        ASN1EnumItem meta =
                            CoderUtils.getAttribute <ASN1EnumItem>(enumItem);
                        if (meta.Tag.Equals(itemValue.Value))
                        {
                            param = enumItem;
                            break;
                        }
                    }
                }
                invokeSetterMethodForField(field, result, param.GetValue(null), null);
                return(new DecodedObject <object>(result, itemValue.Size));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 12
0
        public virtual DecodedObject <object> decodeBoxedType(DecodedObject <object> decodedTag, Type objectClass, ElementInfo elementInfo, Stream stream)
        {
            object resultObj = createInstanceForElement(objectClass, elementInfo);

            DecodedObject <object> result = new DecodedObject <object>(resultObj);

            PropertyInfo field = objectClass.GetProperty("Value");

            if (elementInfo.ASN1ElementInfo == null)
            {
                elementInfo.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(field);
            }
            else
            {
                if (!elementInfo.ASN1ElementInfo.HasTag)
                {
                    ASN1Element fieldInfo = CoderUtils.getAttribute <ASN1Element>(field);
                    if (fieldInfo != null && fieldInfo.HasTag)
                    {
                        elementInfo.ASN1ElementInfo.HasTag        = true;
                        elementInfo.ASN1ElementInfo.TagClass      = fieldInfo.TagClass;
                        elementInfo.ASN1ElementInfo.IsImplicitTag = fieldInfo.IsImplicitTag;
                        elementInfo.ASN1ElementInfo.Tag           = fieldInfo.Tag;
                    }
                }
            }
            elementInfo.AnnotatedClass = field;
            //elementInfo.setGenericInfo(field.getGenericType());

            DecodedObject <object> val = null;

            if (CoderUtils.isAttributePresent <ASN1Null>(field))
            {
                val = decodeNull(decodedTag, field.PropertyType, elementInfo, stream);
            }
            else
            {
                val = decodeClassType(decodedTag, field.PropertyType, elementInfo, stream);
                if (val != null)
                {
                    result.Size = val.Size;
                    invokeSetterMethodForField(field, resultObj, val.Value, elementInfo);
                }
                else
                {
                    result = null;
                }
            }
            return(result);
        }
Esempio n. 13
0
        private void setupConstructed(Type objectClass)
        {
            int count = 0;

            PropertyInfo[] srcFields = null;
            if (typeMeta != null && typeMeta is ASN1SequenceMetadata && ((ASN1SequenceMetadata)typeMeta).IsSet)
            {
                SortedList <int, PropertyInfo> fieldOrder = CoderUtils.getSetOrder(objectClass);
                srcFields = new PropertyInfo[fieldOrder.Count];
                fieldOrder.Values.CopyTo(srcFields, 0);
                count = srcFields.Length;
            }
            else
            {
                srcFields = objectClass.GetProperties(); //objectClass.getDeclaredFields();
                foreach (PropertyInfo field in srcFields)
                {
                    if (!field.PropertyType.Equals(typeof(IASN1PreparedElementData)))
                    {
                        count++;
                    }
                }
            }

            properties         = new PropertyInfo[count];
            propertiesMetadata = new ASN1PreparedElementData[count];
            int idx = 0;

            foreach (PropertyInfo field in srcFields)
            {
                if (!field.PropertyType.Equals(typeof(IASN1PreparedElementData)))
                {
                    properties[idx]         = field;
                    propertiesMetadata[idx] = new ASN1PreparedElementData(objectClass, field);

                    if (properties[idx].Name.Equals("Value"))
                    {
                        setValueField(field, propertiesMetadata[idx]);
                    }
                    idx++;
                }
            }
        }
Esempio n. 14
0
        public virtual DecodedObject <object> decodeChoice(DecodedObject <object> decodedTag, Type objectClass, ElementInfo elementInfo, Stream stream)
        {
            object choice = createInstanceForElement(objectClass, elementInfo);
            DecodedObject <object> val = null;

            PropertyInfo[] fields   = elementInfo.getProperties(objectClass);
            int            fieldIdx = 0;

            foreach (PropertyInfo field in fields)
            {
                ElementInfo info = new ElementInfo();
                info.AnnotatedClass = field;
                if (elementInfo.hasPreparedInfo())
                {
                    info.PreparedInfo = elementInfo.PreparedInfo.getPropertyMetadata(fieldIdx);
                }
                else
                {
                    info.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(field);
                }

                val = decodeClassType(decodedTag, field.PropertyType, info, stream);
                fieldIdx++;
                if (val != null)
                {
                    invokeSelectMethodForField(field, choice, val.Value, info);
                    break;
                }
                ;
            }
            if (val == null && !CoderUtils.isOptional(elementInfo))
            {
                throw new ArgumentException("The choice '" + objectClass + "' does not have a selected item!");
            }
            else
            {
                return(new DecodedObject <object>(choice, val != null ? val.Size : 0));
            }
        }
Esempio n. 15
0
        protected ElementInfo getChoiceSelectedElement(Object obj, ElementInfo elementInfo)
        {
            ElementInfo info = null;

            PropertyInfo[] fields = elementInfo.getProperties(obj.GetType());

            int fieldIdx = 0;

            foreach (PropertyInfo field in fields)
            {
                info = new ElementInfo();
                info.AnnotatedClass = field;
                if (elementInfo.hasPreparedInfo())
                {
                    info.PreparedInfo = (elementInfo.PreparedInfo.getPropertyMetadata(fieldIdx));
                }
                else
                {
                    info.ASN1ElementInfo = CoderUtils.getAttribute <ASN1Element>(field);
                }

                if (invokeSelectedMethodForField(field, obj, info))
                {
                    break;
                }
                else
                {
                    info = null;
                }
                fieldIdx++;
            }

            if (info == null)
            {
                throw new ArgumentException("The choice '" + obj + "' does not have a selected item!");
            }
            return(info);
        }
Esempio n. 16
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);
            }
        }
Esempio n. 17
0
        /*public ASN1PreparedElementData(Type parentClass, String propertyName)
         * {
         *  try
         *  {
         *      PropertyInfo field = parentClass.GetProperty(propertyName);
         *      setupMetadata(field, field.PropertyType);
         *      setupAccessors(parentClass, field);
         *  }
         *  catch (Exception ex)
         *  {
         *      ex = null;
         *  }
         * }*/


        private void setupMetadata(ICustomAttributeProvider annotated, Type objectClass)
        {
            if (CoderUtils.isAttributePresent <ASN1SequenceOf>(annotated))
            {
                typeMeta = new ASN1SequenceOfMetadata(CoderUtils.getAttribute <ASN1SequenceOf>(annotated),
                                                      objectClass,
                                                      annotated
                                                      );
            }
            else if (CoderUtils.isAttributePresent <ASN1Sequence>(annotated))
            {
                typeMeta = new ASN1SequenceMetadata(CoderUtils.getAttribute <ASN1Sequence>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Choice>(annotated))
            {
                typeMeta = new ASN1ChoiceMetadata(CoderUtils.getAttribute <ASN1Choice>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Enum>(annotated))
            {
                typeMeta = new ASN1EnumMetadata(CoderUtils.getAttribute <ASN1Enum>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Boolean>(annotated))
            {
                typeMeta = new ASN1BooleanMetadata(CoderUtils.getAttribute <ASN1Boolean>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Any>(annotated))
            {
                typeMeta = new ASN1AnyMetadata(CoderUtils.getAttribute <ASN1Any>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Integer>(annotated))
            {
                typeMeta = new ASN1IntegerMetadata(CoderUtils.getAttribute <ASN1Integer>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Real>(annotated))
            {
                typeMeta = new ASN1RealMetadata(CoderUtils.getAttribute <ASN1Real>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1OctetString>(annotated))
            {
                typeMeta = new ASN1OctetStringMetadata(CoderUtils.getAttribute <ASN1OctetString>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1BitString>(annotated) || objectClass.Equals(typeof(BitString)))
            {
                typeMeta = new ASN1BitStringMetadata(CoderUtils.getAttribute <ASN1BitString>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1ObjectIdentifier>(annotated) || objectClass.Equals(typeof(ObjectIdentifier)))
            {
                typeMeta = new ASN1ObjectIdentifierMetadata(CoderUtils.getAttribute <ASN1ObjectIdentifier>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1String>(annotated))
            {
                typeMeta = new ASN1StringMetadata(CoderUtils.getAttribute <ASN1String>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Null>(annotated))
            {
                typeMeta = new ASN1NullMetadata(CoderUtils.getAttribute <ASN1Null>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1BoxedType>(annotated))
            {
                typeMeta = new ASN1BoxedTypeMetadata(objectClass, CoderUtils.getAttribute <ASN1BoxedType>(annotated));
            }
            else if (CoderUtils.isAttributePresent <ASN1Element>(annotated))
            {
                typeMeta = new ASN1ElementMetadata(CoderUtils.getAttribute <ASN1Element>(annotated));
            }
            else if (objectClass.Equals(typeof(String)))
            {
                typeMeta = new ASN1StringMetadata();
            }
            else if (objectClass.Equals(typeof(int)))
            {
                typeMeta = new ASN1IntegerMetadata();
            }
            else if (objectClass.Equals(typeof(long)))
            {
                typeMeta = new ASN1IntegerMetadata();
            }
            else if (objectClass.Equals(typeof(double)))
            {
                typeMeta = new ASN1RealMetadata();
            }
            else if (objectClass.Equals(typeof(bool)))
            {
                typeMeta = new ASN1BooleanMetadata();
            }
            else if (objectClass.Equals(typeof(byte[])))
            {
                typeMeta = new ASN1OctetStringMetadata();
            }

            if (CoderUtils.isAttributePresent <ASN1Element>(annotated))
            {
                asn1ElementInfo = new ASN1ElementMetadata(CoderUtils.getAttribute <ASN1Element>(annotated));
            }

            setupConstraint(annotated);
        }
Esempio n. 18
0
 public T getAttribute <T>()
 {
     return(CoderUtils.getAttribute <T>(annotatedClass));
 }
Esempio n. 19
0
 public bool isParentAttributePresent <T>()
 {
     return(CoderUtils.isAttributePresent <T>(parentAnnotatedClass));
 }
Esempio n. 20
0
 public T getParentAttribute <T>()
 {
     return(CoderUtils.getAttribute <T>(parentAnnotatedClass));
 }
Esempio n. 21
0
        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));
        }
Esempio n. 22
0
 public virtual DecodedObject <object> decodeClassType(DecodedObject <object> decodedTag, Type objectClass, ElementInfo elementInfo, Stream stream)
 {
     if (CoderUtils.isImplements(objectClass, typeof(IASN1PreparedElement)))
     {
         return(decodePreparedElement(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.hasPreparedInfo())
     {
         return(elementInfo.PreparedInfo.TypeMetadata.decode(
                    this, decodedTag, objectClass, elementInfo, stream
                    ));
     }
     else if (elementInfo.isAttributePresent <ASN1SequenceOf>())
     {
         return(decodeSequenceOf(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Sequence>())
     {
         return(decodeSequence(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Choice>())
     {
         return(decodeChoice(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1BoxedType>())
     {
         return(decodeBoxedType(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Enum>())
     {
         return(decodeEnum(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Boolean>())
     {
         return(decodeBoolean(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Any>())
     {
         return(decodeAny(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Integer>())
     {
         return(decodeInteger(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Real>())
     {
         return(decodeReal(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1OctetString>())
     {
         return(decodeOctetString(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1BitString>() || elementInfo.AnnotatedClass.Equals(typeof(BitString)))
     {
         return(decodeBitString(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1ObjectIdentifier>() || elementInfo.AnnotatedClass.Equals(typeof(ObjectIdentifier)))
     {
         return(decodeObjectIdentifier(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1String>())
     {
         return(decodeString(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Null>())
     {
         return(decodeNull(decodedTag, objectClass, elementInfo, stream));
     }
     else if (elementInfo.isAttributePresent <ASN1Element>())
     {
         return(decodeElement(decodedTag, objectClass, elementInfo, stream));
     }
     else
     {
         return(decodeCSElement(decodedTag, objectClass, elementInfo, stream));
     }
 }