Exemple #1
0
        public int encodePreparedElement(object obj, Stream stream, ElementInfo elementInfo)
        {
            IASN1PreparedElement preparedInstance = (IASN1PreparedElement)obj;

            elementInfo.PreparedInstance = (preparedInstance);
            ASN1ElementMetadata elementDataSave = null;

            if (elementInfo.hasPreparedASN1ElementInfo())
            {
                elementDataSave = elementInfo.PreparedASN1ElementInfo;
            }
            elementInfo.PreparedInfo = (preparedInstance.PreparedData);
            if (elementDataSave != null)
            {
                elementInfo.PreparedASN1ElementInfo = (elementDataSave);
            }
            return(preparedInstance.PreparedData.TypeMetadata.encode(
                       this, obj, stream, elementInfo
                       ));
        }
Exemple #2
0
 public static bool isOptionalField(ICustomAttributeProvider field, ElementInfo elementInfo)
 {
     if (elementInfo.hasPreparedInfo())
     {
         if (elementInfo.hasPreparedASN1ElementInfo())
         {
             return(elementInfo.PreparedASN1ElementInfo.IsOptional ||
                    elementInfo.PreparedASN1ElementInfo.HasDefaultValue);
         }
         return(false);
     }
     else if (isAttributePresent <ASN1Element>(field))
     {
         ASN1Element info = getAttribute <ASN1Element>(field);
         if (info.IsOptional || info.HasDefaultValue)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #3
0
        public DecodedObject <object> decodePreparedElement(DecodedObject <object> decodedTag, Type objectClass, ElementInfo elementInfo, Stream stream)
        {
            IASN1PreparedElementData saveInfo         = elementInfo.PreparedInfo;
            IASN1PreparedElement     preparedInstance = (IASN1PreparedElement)createInstanceForElement(objectClass, elementInfo);

            elementInfo.PreparedInstance = preparedInstance;
            ASN1ElementMetadata elementDataSave = null;

            if (elementInfo.hasPreparedASN1ElementInfo())
            {
                elementDataSave = elementInfo.PreparedASN1ElementInfo;
            }
            elementInfo.PreparedInfo = preparedInstance.PreparedData;
            if (elementDataSave != null)
            {
                elementInfo.PreparedASN1ElementInfo = elementDataSave;
            }
            DecodedObject <object> result = preparedInstance.PreparedData.TypeMetadata.decode(
                this, decodedTag, objectClass, elementInfo, stream
                );

            elementInfo.PreparedInfo = saveInfo;
            return(result);
        }