public PropertyDefinition FindProperty(PropertyTreeDefinition definition, Type componentType, QualifiedName qn, IEnumerable <PropertyTreeDefinition> ancestors) { // Allow any namespace contained in the definition base classes var result = definition .EnumerateProperties() .FirstOrDefault(t => Compare(t, qn, definition)); if (result != null) { return(result); } int dot = qn.LocalName.IndexOf('.'); if (dot > 0) { // TODO Index whether the PTD has extenders so we can skip some ancestors (perf) string prefix = qn.LocalName.Substring(0, dot); foreach (var currentDef in ancestors) { if (currentDef.Name == prefix) { // TODO Local name could be different var prop = currentDef.GetProperty(qn); if (prop != null) { return(prop); } } } } else { foreach (var curDefinition in ancestors) { var prop = curDefinition.GetProperty(qn); if (IsValidExtender(prop, componentType)) { return(prop); } var qn2 = qn.ChangeLocalName(curDefinition.Name + "." + qn.LocalName); prop = curDefinition.GetProperty(qn2); if (IsValidExtender(prop, componentType)) { return(prop); } } } return(null); }
public PropertyDefinition FindProperty(PropertyTreeDefinition definition, Type componentType, QualifiedName qn, IEnumerable<PropertyTreeDefinition> ancestors) { // Allow any namespace contained in the definition base classes var result = definition .EnumerateProperties() .FirstOrDefault(t => Compare(t, qn, definition)); if (result != null) return result; int dot = qn.LocalName.IndexOf('.'); if (dot > 0) { // TODO Index whether the PTD has extenders so we can skip some ancestors (perf) string prefix = qn.LocalName.Substring(0, dot); foreach (var currentDef in ancestors) { if (currentDef.Name == prefix) { // TODO Local name could be different var prop = currentDef.GetProperty(qn); if (prop != null) { return prop; } } } } else { foreach (var curDefinition in ancestors) { var prop = curDefinition.GetProperty(qn); if (IsValidExtender(prop, componentType)) return prop; var qn2 = qn.ChangeLocalName(curDefinition.Name + "." + qn.LocalName); prop = curDefinition.GetProperty(qn2); if (IsValidExtender(prop, componentType)) return prop; } } return null; }