Exemplo n.º 1
0
        /// <summary>
        /// Creates a datatype object given a type name.
        /// </summary>
        ///
        /// <param name="typeName">the type</param>
        /// <returns>the created datatype</returns>
        /* @SuppressWarnings("unchecked")*/
        public static object /*ANY*/ CreateDataType(String typeName, bool isCDAR2)
        {
            Type implementation = DataTypeImplementationFactory.GetImplementation(typeName, isCDAR2);

            try {
                if (implementation != null)
                {
                    if (isCDAR2)
                    {
                        if (implementation.IsGenericType)
                        {
                            implementation = implementation.MakeGenericType(typeof(Code));
                        }
                    }
                    return(Activator.CreateInstance(implementation));
                }
                else
                {
                    throw new Exception("Unable to create data type: " + typeName);
                }
            } catch (TargetException e) {
                throw new Exception("Unable to create data type: " + typeName, e);
            } catch (MemberAccessException e_0) {
                throw new Exception("Unable to create data type: " + typeName, e_0);
            }
        }
Exemplo n.º 2
0
 public virtual void MakeSureDataTypeHasAnImplemenation()
 {
     foreach (StandardDataType type in DATA_TYPES)
     {
         if (type != StandardDataType.COLLECTION && type != StandardDataType.BAG)
         {
             if (type.Coded && CDA_R2_TYPES.Contains(type))
             {
                 Assert.IsNotNull(DataTypeImplementationFactory.GetImplementation(type.Type, true), System.String.Format("no implementation for: {0}"
                                                                                                                         , type.Type));
             }
             Assert.IsNotNull(DataTypeImplementationFactory.GetImplementation(type.Type, false), System.String.Format("no implementation for: {0}"
                                                                                                                      , type.Type));
         }
     }
 }