Exemplo n.º 1
0
        public virtual string DetermineActualDataTypeFromXsiType(string modelType, string newTypeFromXsiType, bool isCda, bool isR1
                                                                 , ErrorLogger errorLogger)
        {
            StandardDataType newTypeEnum = EnumPattern.ValueOf <StandardDataType>(newTypeFromXsiType);

            return(DetermineActualDataType(modelType, newTypeEnum, isCda, isR1, errorLogger));
        }
Exemplo n.º 2
0
 /// <summary>Get the annotation Type</summary>
 /// <returns>annotation Type</returns>
 public virtual Ca.Infoway.Messagebuilder.Xml.AnnotationType GetAnnotationTypeAsEnum()
 {
     if (this.annotationType != null)
     {
         return(EnumPattern.ValueOf <Ca.Infoway.Messagebuilder.Xml.AnnotationType>(this.annotationType));
     }
     return(null);
 }
Exemplo n.º 3
0
 private void CheckPartTypeForOn(NamePartType type, FormatContext context)
 {
     // valid types are null, delimiter, prefix, suffix
     if (type != null)
     {
         string typeValue = type.Value == null ? null : type.Value.ToUpper();
         //.NET conversion
         OrganizationNamePartType onType = EnumPattern.ValueOf <OrganizationNamePartType>(typeValue);
         if (onType == null)
         {
             RecordError(context, System.String.Format("Name parts of type {0} are not valid for ON data types. Only delimiter, prefix, suffix, and free-format text are allowed."
                                                       , type.Value));
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Wrapper for Convert.ChangeType, to get around the issue of the said method not supporting
        /// Nullable types. This method simple extracts the unerlying type if it's Nullable based and
        /// then pass through to Convert.ChangeType.
        /// </summary>
        /// <param name="value">Value to be converted</param>
        /// <param name="conversionType">Type to convert to</param>
        /// <returns></returns>
        public static object ChangeType(object o, Type conversionType)
        {
            if (conversionType == null)
            {
                throw new ArgumentNullException("conversionType");
            }

            if (o == null)
            {
                return(null);
            }
            else if (conversionType.IsEnum)
            {
                string s = (string)o;
                return(System.Enum.Parse(conversionType, s));
            }
            else if (conversionType.Equals(typeof(Cardinality)))
            {
                string s = (string)o;
                return(Cardinality.Create(s));
            }
            else if (conversionType.IsSubclassOf(typeof(EnumPattern)))
            {
                return(EnumPattern.ValueOf <EnumPattern>(conversionType, (string)o));
            }
            else
            //
            // If it's not a nullable type, just pass through the parameters to Convert.ChangeType.
            //
            if (conversionType.IsGenericType &&
                conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable <>)))
            {
                if (o == null)
                {
                    return(null);
                }

                conversionType = Nullable.GetUnderlyingType(conversionType);
            }

            return(Convert.ChangeType(o, conversionType));
        }
Exemplo n.º 5
0
 private void HandleRepresentation(EncapsulatedData ed, XmlElement element, ParseContext context, XmlToModelResult result)
 {
     if (element.HasAttribute("representation"))
     {
         string representationString = element.GetAttribute("representation");
         try
         {
             EdRepresentation representation = EnumPattern.ValueOf <EdRepresentation>(representationString);
             if (!StringUtils.IsBlank(representationString) && representation == null)
             {
                 //Invalid enum value
                 throw new ArgumentException();
             }
             ed.Representation = representation;
         }
         catch (Exception)
         {
             RecordError("Unknown value for representation: " + representationString, element, result);
         }
     }
 }
Exemplo n.º 6
0
 private void HandleIntegrityCheckAlgorithm(EncapsulatedData ed, XmlElement element, ParseContext context, XmlToModelResult
                                            result)
 {
     if (element.HasAttribute("integrityCheckAlgorithm"))
     {
         string icaString = element.GetAttribute("integrityCheckAlgorithm");
         try
         {
             IntegrityCheckAlgorithm ica = EnumPattern.ValueOf <IntegrityCheckAlgorithm>(icaString);
             if (!StringUtils.IsBlank(icaString) && ica == null)
             {
                 //Invalid enum value
                 throw new ArgumentException();
             }
             ed.IntegrityCheckAlgorithm = ica;
         }
         catch (Exception)
         {
             RecordError("Unknown value for integrityCheckAlgorithm: " + icaString, element, result);
         }
     }
 }