コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        /// <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));
        }