public void ProcessRequest(HttpContext context) { var appRelativeCurrentExecutionFilePath = context.Request.AppRelativeCurrentExecutionFilePath; var fileName = Path.GetFileName(appRelativeCurrentExecutionFilePath); var directoryName = Path.GetDirectoryName(appRelativeCurrentExecutionFilePath); if (directoryName != null) { var pos = directoryName.LastIndexOf("\\", StringComparison.Ordinal); var folder = directoryName.Substring(pos + 1); string resourceName; var resourceStream = EmbeddedResourceHelper.GetResource("nuPickers.Shared." + folder + "." + fileName, out resourceName); if (resourceStream != null) { context.Response.ContentType = MimeMapping.GetMimeMapping(resourceName); resourceStream.CopyTo(context.Response.OutputStream); } else { context.Response.StatusCode = 404; } } }
/// <summary> /// The file exists. /// </summary> /// <param name="virtualPath"> /// The virtual path. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public bool FileExists(string virtualPath) { if (!virtualPath.EndsWith(".nu", StringComparison.InvariantCultureIgnoreCase)) { return(false); } return(EmbeddedResourceHelper.ResourceExists(virtualPath)); }
public ActionResult GetSharedResource(string folder, string file) { string resourceName; var resourceStream = EmbeddedResourceHelper.GetResource("nuPickers.Shared." + folder + "." + file, out resourceName); if (resourceStream != null) { return(new FileStreamResult(resourceStream, GetMimeType(resourceName)));; } return(this.HttpNotFound()); }
/// <summary> /// When overridden in a derived class, returns a read-only stream to the virtual resource. /// </summary> /// <returns> /// A read-only stream to the virtual file. /// </returns> public Stream Open() { string resourceName; return(EmbeddedResourceHelper.GetResource(_virtualPath, out resourceName)); }