/// <summary> /// Constructor /// </summary> /// <param name="clrType">The Clr Type</param> /// <param name="edmTypeName">The Edm Type Name</param> /// <param name="primitiveKind">The Edm Primitive Type Kind</param> /// <param name="typeConverter">A PrimitiveXmlConverter that provides convertion between instances of this type to its Xml representation and back</param> /// <param name="hasReverseMapping">Whether this primitive type can be mapped from the Edm type name</param> private PrimitiveType(Type clrType, string edmTypeName, EdmPrimitiveTypeKind primitiveKind, PrimitiveTypeConverter typeConverter, bool hasReverseMapping) { Debug.Assert(clrType != null, "clrType != null"); Debug.Assert(primitiveKind != EdmPrimitiveTypeKind.None, "primitiveKind != EdmPrimitiveTypeKind.None"); Debug.Assert(typeConverter != null, "typeConverter != null"); this.ClrType = clrType; this.EdmTypeName = edmTypeName; this.PrimitiveKind = primitiveKind; this.TypeConverter = typeConverter; this.HasReverseMapping = hasReverseMapping; }
/// <summary> /// Register a known type as primitive type /// </summary> /// <param name="clrType">The Clr Type</param> /// <param name="edmTypeName">The Edm Type Name</param> /// <param name="primitiveKind">The Edm Primitive Type Kind</param> /// <param name="converter">The Type Converter</param> /// <param name="twoWay">Whether this mapping should have a reverse mapping from Edm</param> /// <remarks> /// This method is internal only for testing purposes. /// IN PRODUCT MUST BE CALLED ONLY FROM THE STATIC CTOR OF THE PrimitiveType CLASS. /// </remarks> internal static void RegisterKnownType(Type clrType, string edmTypeName, EdmPrimitiveTypeKind primitiveKind, PrimitiveTypeConverter converter, bool twoWay) { Debug.Assert(!clrMapping.ContainsKey(clrType), "Clr type already registered"); Debug.Assert(clrType != null, "clrType != null"); Debug.Assert(primitiveKind != EdmPrimitiveTypeKind.None, "primitiveKind != EdmPrimitiveTypeKind.None"); Debug.Assert(converter != null, "converter != null"); PrimitiveType pt = new PrimitiveType(clrType, edmTypeName, primitiveKind, converter, twoWay); clrMapping.Add(clrType, pt); if (twoWay) { Debug.Assert(!edmMapping.ContainsKey(edmTypeName), "Edm type name already registered"); edmMapping.Add(edmTypeName, pt); } }