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)); }
public virtual int encodeSequenceField(object obj, int fieldIdx, PropertyInfo field, System.IO.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); }
public virtual int encodeEnum(object obj, System.IO.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 System.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); }
public virtual int encodeBoxedType(object obj, System.IO.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)); } }
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); } }
public virtual void encode <T>(T obj, System.IO.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 System.ArgumentException("Unable to find any supported annotation for class type: " + obj.GetType().ToString()); } ; }
public void invokeSelectMethodForField(PropertyInfo field, object obj, object param, ElementInfo info) { if (info.hasPreparedInfo()) { info.PreparedInfo.invokeDoSelectMethod(obj, param); } else { CoderUtils.findDoSelectMethodForField(field, obj.GetType()).Invoke(obj, new object[] { param }); } }
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)); } }
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)); } }
public virtual DecodedObject <object> decodeBoxedType(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.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); }
public virtual DecodedObject <object> decodeEnum(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream) { Type enumClass = null; foreach (MemberInfo member in objectClass.GetMembers()) { if (member is System.Type) { Type cls = (Type)member; if (cls.IsEnum) { enumClass = cls; break; } } } ; System.Reflection.PropertyInfo field = objectClass.GetProperty("Value"); DecodedObject <object> itemValue = decodeEnumItem(decodedTag, field.PropertyType, enumClass, elementInfo, stream); System.Reflection.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); } }
public void testDefStringToOctetString() { BitString result = CoderUtils.defStringToOctetString("'FFAABBEE'H"); ByteTools.checkBuffers(result.Value, new byte[] { (byte)0xFF, (byte)0xAA, (byte)0xBB, (byte)0xEE }); result = CoderUtils.defStringToOctetString("'FFAABBEEC'H"); ByteTools.checkBuffers(result.Value, new byte[] { (byte)0xFF, (byte)0xAA, (byte)0xBB, (byte)0xEE, (byte)0xC0 }); result = CoderUtils.defStringToOctetString("'111100001111000010011001'B"); ByteTools.checkBuffers(result.Value, new byte[] { (byte)0xF0, (byte)0xF0, (byte)0x99 }); result = CoderUtils.defStringToOctetString("'1111000011110000100110011'B"); ByteTools.checkBuffers(result.Value, new byte[] { (byte)0xF0, (byte)0xF0, (byte)0x99, (byte)0x80 }); }
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++; } } }
private void setupAccessors(Type objectClass, PropertyInfo field) { try { this.doSelectMethod = CoderUtils.findDoSelectMethodForField(field, objectClass); } catch (Exception) {} try { isSelectedMethod = CoderUtils.findIsSelectedMethodForField(field, objectClass); } catch (Exception) {} try { isPresentMethod = CoderUtils.findIsPresentMethodForField(field, objectClass); } catch (Exception) {} }
/// <param name="obj">The encoded sequence</param> /// <param name="fieldIdx">Index of the sequence field to be encoded</param> /// <param name="field">Field of the encoded sequence to be encoded</param> /// <param name="stream"></param> /// <param name="elementInfo">ElementInfo for the encoded sequence</param> public virtual int encodeSequenceField(object obj, int fieldIdx, PropertyInfo field, System.IO.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); } if (CoderUtils.isNullField(field, info)) { return(encodeNull(obj, stream, elementInfo)); } else { object invokeObjResult = invokeGetterMethodForField(field, obj, info); if (invokeObjResult == null) { CoderUtils.checkForOptionalField(field, info); return(0); } else if (CoderUtils.isDefaultField(field, info)) { // skip the field if the current value equals to the default value (this is optional for BER, but mandatory for DER) object newSequenceInstance = Activator.CreateInstance(obj.GetType()); CoderUtils.initDefaultValues(newSequenceInstance); object defaultFieldValue = invokeGetterMethodForField(field, newSequenceInstance, info); return(CoderUtils.AreEqual(defaultFieldValue, invokeObjResult) ? 0 : encodeClassType(invokeObjResult, stream, info)); } else { return(encodeClassType(invokeObjResult, stream, info)); } } }
public virtual DecodedObject <object> decodeChoice(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.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 System.ArgumentException("The choice '" + objectClass.ToString() + "' does not have a selected item!"); } else { return(new DecodedObject <object>(choice, val != null?val.Size: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 System.ArgumentException("The choice '" + obj.ToString() + "' does not have a selected item!"); } return(info); }
public static SortedList <int, PropertyInfo> getSetOrder(Type objClass) { SortedList <int, PropertyInfo> fieldOrder = new SortedList <int, PropertyInfo>(); int tagNA = -1; foreach (PropertyInfo field in objClass.GetProperties()) { ASN1Element element = CoderUtils.getAttribute <ASN1Element>(field); if (element != null) { try { if (element.HasTag) { fieldOrder.Add(element.Tag, field); } else { fieldOrder.Add(tagNA--, field); } } catch (ArgumentException ex) { if (element.HasTag) { throw new Exception("Duplicate tag [" + element.Tag + "] for set has been detected!"); } else { throw new Exception("Cannot be specified more field in SET without tag specified"); } } } } return(fieldOrder); }
public virtual DecodedObject <object> decodeSequenceField(DecodedObject <object> fieldTag, object sequenceObj, int fieldIdx, PropertyInfo field, System.IO.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); } }
public virtual DecodedObject <object> decodeClassType(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream) { if (CoderUtils.isImplements(objectClass, typeof(IASN1PreparedElement))) { return(decodePreparedElement(decodedTag, objectClass, elementInfo, stream)); } else if (elementInfo.hasPreparedInfo() && elementInfo.PreparedInfo.TypeMetadata != null) // Pavel { 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)); } }
public virtual DecodedObject <object> decodeSequence(DecodedObject <object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.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)); }
public T getAttribute <T>() { return(CoderUtils.getAttribute <T>(annotatedClass)); }
/*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 <ASN1_MMSDataArray>(annotated)) // Pavel { if (CoderUtils.isAttributePresent <ASN1SequenceOf>(annotated) && ASN1_MMSDataArray.Depth < 10) { ASN1_MMSDataArray.Depth++; typeMeta = new ASN1SequenceOfMetadata(CoderUtils.getAttribute <ASN1SequenceOf> (annotated), objectClass, annotated ); } } else if (CoderUtils.isAttributePresent <ASN1_MMSDataStructure>(annotated)) // Pavel { if (CoderUtils.isAttributePresent <ASN1SequenceOf>(annotated) && ASN1_MMSDataStructure.Depth < 10) { ASN1_MMSDataStructure.Depth++; typeMeta = new ASN1SequenceOfMetadata(CoderUtils.getAttribute <ASN1SequenceOf> (annotated), objectClass, annotated ); } } else 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)); } //ASN1CyclicDefinition.Depth = 0; // Pavel setupConstraint(annotated); }
public T getParentAttribute <T>() { return(CoderUtils.getAttribute <T>(parentAnnotatedClass)); }
public bool isParentAttributePresent <T>() { return(CoderUtils.isAttributePresent <T>(parentAnnotatedClass)); }