public override object Get(object key) { if (key == null) { throw new ArgumentNullException("key"); } if (references.ContainsKey(key)) { return(references[key]); } if (ParentLocator != null) { return(ParentLocator.Get(key)); } return(null); }
/// <summary> /// Gets an object from the locator, registered with the given key. /// </summary> /// <param name="key">The key that the object is registered with.</param> /// <returns>The object, if found; null otherwise.</returns> /// <exception cref="ArgumentNullException">Key is null.</exception> public override object Get(object key) { if (key == null) { throw new ArgumentNullException("key"); } object value; if (references.TryGet(key, out value)) { return(value); } if (ParentLocator != null) { return(ParentLocator.Get(key)); } return(null); }
/// <summary> /// See <see cref="IReadableLocator.Get(object, SearchMode)"/> for more information. /// </summary> public override object Get(object key, SearchMode options) { if (key == null) { throw new ArgumentNullException("key"); } if (!Enum.IsDefined(typeof(SearchMode), options)) { throw new ArgumentException(Properties.Resources.InvalidEnumerationValue, "options"); } if (references.ContainsKey(key)) { return(references[key]); } if (options == SearchMode.Up && ParentLocator != null) { return(ParentLocator.Get(key, options)); } return(null); }