/// <summary> /// Enumerate this class' properties using reflection, create PropertyMappings /// for them and add them to the PropertyMappings. /// </summary> private static PropertyMappingCollection inspectProperties(Type nativeType, FhirRelease fhirVersion) { var byName = new Dictionary <string, PropertyMapping>(); foreach (var property in ReflectionHelper.FindPublicProperties(nativeType)) { if (!PropertyMapping.TryCreate(property, out var propMapping, fhirVersion)) { continue; } var propKey = propMapping.Name.ToUpperInvariant(); if (byName.ContainsKey(propKey)) { throw Error.InvalidOperation($"Class has multiple properties that are named '{propKey}'. The property name must be unique"); } byName.Add(propKey, propMapping); } var ordered = byName.Values.OrderBy(pm => pm.Order).ToList(); return(new PropertyMappingCollection(byName, ordered)); }
/// <summary> /// Enumerate this class' properties using reflection, create PropertyMappings /// for them and add them to the PropertyMappings. /// </summary> private void inspectProperties(string fhirVersion) { foreach (var property in ReflectionHelper.FindPublicProperties(NativeType)) { if (!PropertyMapping.TryCreate(property, out var propMapping, fhirVersion)) { continue; } var propKey = propMapping.Name.ToUpperInvariant(); if (_propMappings.ContainsKey(propKey)) { throw Error.InvalidOperation($"Class has multiple properties that are named '{propKey}'. The property name must be unique"); } _propMappings.Add(propKey, propMapping); // Keep a pointer to this property if this is a primitive value element ("Value" in primitive types) if (propMapping.RepresentsValueElement) { PrimitiveValueProperty = propMapping; } } PropertyMappings = _propMappings.Values.OrderBy(prop => prop.Order).ToList(); }