private ClassMapping determineElementPropertyType(PropertyMapping mappedProperty, string memberName) { ClassMapping result = null; var typeName = mappedProperty.GetChoiceSuffixFromName(memberName); if (String.IsNullOrEmpty(typeName)) { throw Error.Format("Encountered polymorph member {0}, but is does not specify the type used".FormatWith(memberName), _current); } // Exception: valueResource actually means the element is of type ResourceReference if (typeName == "Resource") { typeName = "Reference"; } // NB: this will return the latest type registered for that name, so supports type mapping/overriding // Maybe we should Import the types present on the choice, to make sure they are available. For now // assume the caller has Imported all types in the right (overriding) order. result = _inspector.FindClassMappingForFhirDataType(typeName); if (result == null) { throw Error.Format("Encountered polymorph member {0}, which uses unknown datatype {1}".FormatWith(memberName, typeName), _current); } return(result); }