/// <summary> /// Returns a collection with items matching the specified identifier. /// </summary> /// <param name="identifier">The identifier.</param> /// <returns>A collection containing the items that match the specified identifier.</returns> /// <exception cref="System.ArgumentNullException">The identifier is null.</exception> public IEnumerable <ReferenceType> WithIdentifier(String identifier) { if (identifier == null) { throw new ArgumentNullException(nameof(identifier)); } this.EnsureAliases(); this.EnsureReferences(); // match exact code String authority = IdentifiedObject.GetAuthority(identifier); Int32 code = IdentifiedObject.GetCode(identifier); if (authority == Authority && this.referenceDictionary.ContainsKey(code)) { yield return(this.referenceDictionary[code]); } // match contained code foreach (ReferenceType reference in this.referenceDictionary.Values.Where(reference => reference.Identifier.IndexOf(identifier, StringComparison.OrdinalIgnoreCase) >= 0)) { yield return(reference); } }
/// <summary> /// Gets the item with the specified identifier. /// </summary> /// <param name="identifier">The identifier.</param> /// <returns>The item with the specified identifier.</returns> public ReferenceType this[String identifier] { get { if (identifier == null) { return(null); } String authority = IdentifiedObject.GetAuthority(identifier); Int32 code = IdentifiedObject.GetCode(identifier); if (!String.IsNullOrEmpty(authority) && authority != Authority) { return(null); } return(this.GetReference(code)); } }