/// <summary> /// Determines if at least one object with the given <paramref name="objectId"/> exists /// in the container. /// </summary> /// <param name="objectId">The identifier to search for.</param> /// <returns><see langword="true"/> if the key exists in the container; <see langword="false"/> otherwise.</returns> /// <remarks> /// Container-managed objects are always singletons by id and type. Therefore, /// <paramref name="objectId"/> is not guaranteed to be unique in the container, /// only within that pair id/type. /// </remarks> public bool Contains(string objectId) { IReadableLocator results = locator.FindBy(delegate(KeyValuePair <object, object> entry) { string stringKey = entry.Key as string; if (stringKey != null && stringKey == objectId) { return(true); } DependencyResolutionLocatorKey key = entry.Key as DependencyResolutionLocatorKey; if (key != null && key.ID == objectId) { return(true); } return(false); }); return(results.Count > 0); }