/// <summary>
        /// Add a new API resource location
        /// </summary>
        /// <param name="location">API resource location to add</param>
        public void AddResourceLocation(ApiResourceLocation location)
        {
            ApiResourceLocation existingLocation;

            if (m_locationsById.TryGetValue(location.Id, out existingLocation))
            {
                if (!location.Equals(existingLocation))  // unit tests will register same resources multiple times, so only throw if the ApiResourceLocation doesn't match what is already cached.
                {
                    throw new VssApiResourceDuplicateIdException(location.Id);
                }
            }

            m_locationsById[location.Id] = location;

            List <ApiResourceLocation> locationsByKey;
            String locationCacheKey = GetLocationCacheKey(location.Area, location.ResourceName);

            if (!m_locationsByKey.TryGetValue(locationCacheKey, out locationsByKey))
            {
                locationsByKey = new List <ApiResourceLocation>();
                m_locationsByKey.Add(locationCacheKey, locationsByKey);
            }

            if (!locationsByKey.Any(x => x.Id.Equals(location.Id)))
            {
                locationsByKey.Add(location);
            }
        }
        /// <summary>
        /// Get an API resource location by location id. Throws if not found.
        /// </summary>
        /// <param name="locationId">Id of the registered resource location</param>
        /// <returns>ApiResourceLocation or null if not found</returns>
        public ApiResourceLocation GetLocationById(Guid locationId)
        {
            ApiResourceLocation location = TryGetLocationById(locationId);

            if (location == null)
            {
                throw new VssResourceNotFoundException(locationId);
            }
            return(location);
        }
コード例 #3
0
 public VssVersionNotSupportedException(ApiResourceLocation location, Version requestedVersion, Version minSupportedVersion, Uri serverBaseUri)
     : base(WebApiResources.ClientResourceVersionNotSupported(location.Area + ":" + location.ResourceName + " " + location.Id, requestedVersion, serverBaseUri, minSupportedVersion))
 {
 }