/// <summary> If Xml properties are defined, they will override the definition of the existing ones.</summary> private void OverridePropertiesFromXml(List <XmlModelProperty> properties) { if (properties == null) { return; } try { foreach (XmlModelProperty property in properties) { if (string.IsNullOrEmpty(property.Name)) { throw new EtkException("A property name cannot be null or empty"); } IModelProperty existingProperty; // Override an existing model property definition if (PropertiesByName.TryGetValue(property.Name.ToUpper(), out existingProperty)) { existingProperty.Description = property.Description; if (!string.IsNullOrEmpty(property.NameToUse)) { PropertiesByName.Remove(existingProperty.Name.ToUpper()); existingProperty.Name = property.NameToUse; PropertiesByName[existingProperty.Name.ToUpper()] = existingProperty; } } } } catch (Exception ex) { throw new EtkException($"Cannot retrieve properties for UnderlyingType '{Name.EmptyIfNull()}': {ex.Message}"); } }
/// <summary> Implements <see cref="IModelType.GetProperty"/> </summary> public IModelProperty GetProperty(string name) { if (!dependenciesResolved) { ResolveDependencies(); } if (string.IsNullOrEmpty(name)) { return(null); } IModelProperty modelProperty; if (PropertiesByName.TryGetValue(name.ToUpper(), out modelProperty)) { return(modelProperty); } ModelLinkProperty modelLinkProperty; if (LinkPropertiesByName != null && LinkPropertiesByName.TryGetValue(name.ToUpper(), out modelLinkProperty)) { return(modelLinkProperty); } return(null); }
public PropertyInfo GetProperty(string name) { if (PropertiesByName.TryGetValue(name, out PropertyInfo property) || PropertiesByLogicalName.TryGetValue(name, out property)) { return(property); } throw new KeyNotFoundException($"The property \"{name}\" was not found in the entity type \"{EntityName}\"."); }