void AssertLocateResult(IResourceLocator locator, object key, Type type, params string[] expectedInternalIds) { Assert.IsTrue(locator.Locate(key, type, out var locations)); Assert.IsNotNull(locations); if (type != null) { foreach (var l in locations) Assert.AreEqual(l.ResourceType, type); } Assert.AreEqual(expectedInternalIds.Length, locations.Count); foreach (var e in expectedInternalIds) Assert.NotNull(locations.FirstOrDefault(s => s.InternalId == e), $"Locations do not contain entry with internal id of {e}"); }
private static IResourceLocation Locate <TObject>(string requestID) where TObject : class { IResourceLocation location; for (int i = 0; i < m_Locators.Count; i++) { IResourceLocator locator = m_Locators[i]; location = locator.Locate <TObject>(requestID); if (location != null) { return(location); } } throw new CanNotLocateExcption(requestID); }
bool TryGetKeyLocationID(IResourceLocator locator, object key, out string internalID) { internalID = string.Empty; var hasLocation = locator.Locate(key, typeof(Object), out var keyLocations); if (!hasLocation) { return(false); } if (keyLocations.Count == 0) { return(false); } if (keyLocations.Count > 1) { return(false); } internalID = keyLocations[0].InternalId; return(true); }