/// <summary> /// Adds the required resource with specified name. /// </summary> public void AddRequiredResource(string name) { var resource = repository.FindResource(name); if (resource == null) { ThrowResourceNotFound(name); } AddRequiredResourceCore(name, resource); }
public ILocalResourceLocation FindResource(string url, IDotvvmRequestContext context, out string mimeType) { mimeType = null; if (DotvvmRoutingMiddleware.FindMatchingRoute(new[] { resourceRoute }, context, out var parameters) == null) { return(null); } var name = DecodeResourceName((string)parameters[NameParameterName]); var hash = (string)parameters[HashParameterName]; if (resources.FindResource(name) is IResource resource) { var location = FindLocation(resource, out mimeType); if (GetVersionHash(location, context, name) == hash) // check if the resource matches so that nobody can guess the url by chance { if (alternateDirectories != null) { alternateDirectories.GetOrAdd(hash, _ => (location as IDebugFileLocalLocation)?.GetFilePath(context)); } return(location); } } return(TryLoadAlternativeFile(name, hash, context)); }
public static void SetEmbeddedResourceDebugFile(this DotvvmResourceRepository repo, string resourceName, string filePath) { var location = repo.FindResource(resourceName).As <ILinkResource>()?.GetLocations()?.OfType <EmbeddedResourceLocation>()?.FirstOrDefault(); if (location != null) { location.DebugFilePath = filePath; } }