public bool Contains(string nodeId, DvText name) { Check.Invariant(identifiedLocatables != null, "identifiedLocatables must not be null"); Check.Require(!string.IsNullOrEmpty(nodeId), "nodeId must not be null or empty"); Check.Require(name != null, "name must not be null"); LocatableBindingListView <T> namedLocatables = null; if (identifiedLocatables.ContainsKey(nodeId)) { namedLocatables = identifiedLocatables[nodeId]; } bool result = false; if (namedLocatables != null) { DvCodedText codedName = name as DvCodedText; if (codedName == null) { result = namedLocatables.Contains(name.Value); } else { CodePhrase definingCode = codedName.DefiningCode; result = namedLocatables.Contains(definingCode.TerminologyId.Value, definingCode.CodeString); } } return(result); }
public T this[string nodeId, DvText name] { get { Check.Invariant(identifiedLocatables != null, "identifiedLocatables must not be null"); Check.Require(!string.IsNullOrEmpty(nodeId), "nodeId must not be null or empty"); Check.Require(name != null, "name must not be null"); Check.Assert(Contains(nodeId, name), "Set must contain item with specified name"); // precondition, but more efficient in release LocatableBindingListView <T> namedLocatables = null; if (identifiedLocatables.ContainsKey(nodeId)) { namedLocatables = identifiedLocatables[nodeId]; } T result = null; if (namedLocatables != null) { DvCodedText codedName = name as DvCodedText; if (codedName == null) { string nameValue = name.Value; if (namedLocatables.Contains(nameValue)) { result = namedLocatables[nameValue]; } } else { string nameTerminologyId = codedName.DefiningCode.TerminologyId.Value; string nameCodeString = codedName.DefiningCode.CodeString; if (namedLocatables.Contains(nameTerminologyId, nameCodeString)) { result = namedLocatables[nameTerminologyId, nameCodeString]; } } } Check.Ensure(result != null, "result must not be null"); return(result); } }