/// <summary> /// Get the info about the resource that in the assembly /// </summary> /// <param name="assembly"></param> /// <param name="resourceName"></param> /// <returns></returns> private static Quadruplet<bool, bool, string, bool> GetResourceInfo(Assembly assembly, string resourceName) { // Create a unique cache key int cacheKey = Util.CombineHashCodes(assembly.GetHashCode(), resourceName.GetHashCode()); Quadruplet<bool, bool, string, bool> resourceInfo = _webResourceCache[cacheKey] as Quadruplet<bool, bool, string, bool>; // Assembly info was not in the cache if (resourceInfo == null) { bool first = false; bool second = false; string third = string.Empty; bool forth = false; object[] customAttributes = assembly.GetCustomAttributes(false); for (int j = 0; j < customAttributes.Length; j++) { WebResourceAttribute attribute = customAttributes[j] as WebResourceAttribute; if ((attribute != null) && string.Equals(attribute.WebResource, resourceName, StringComparison.Ordinal)) { first = true; second = attribute.PerformSubstitution; third = attribute.ContentType; forth = Util.IsContentTypeCompressible(attribute.ContentType); break; } } resourceInfo = new Quadruplet<bool, bool, string, bool>(first, second, third, forth); _webResourceCache[cacheKey] = resourceInfo; } return resourceInfo; }
/// <summary> /// Get the info about the resource that in the assembly /// </summary> /// <param name="assembly"></param> /// <param name="resourceName"></param> /// <returns></returns> protected static Quadruplet<bool, bool, string, bool> GetResourceInfo(Assembly assembly, string resourceName) { // Create a unique cache key var cacheKey = CombineHashCodes(assembly.GetHashCode(), resourceName.GetHashCode()); var resourceInfo = WebResourceCache[cacheKey] as Quadruplet<bool, bool, string, bool>; // Assembly info was not in the cache if (resourceInfo == null) { var first = false; var second = false; var third = string.Empty; var forth = false; var customAttributes = assembly.GetCustomAttributes(false); for (var j = 0; j < customAttributes.Length; j++) { var attribute = customAttributes[j] as WebResourceAttribute; if ((attribute == null) || !string.Equals(attribute.WebResource, resourceName, StringComparison.Ordinal)) continue; first = true; second = attribute.PerformSubstitution; third = attribute.ContentType; forth = CompressionModuleHelper.IsContentTypeCompressible(attribute.ContentType); break; } resourceInfo = new Quadruplet<bool, bool, string, bool>(first, second, third, forth); WebResourceCache[cacheKey] = resourceInfo; } return resourceInfo; }