C# Class GSF.Web.Embedded.EmbeddedResourceProvider

Represents a VirtualPathProvider that allows access to embedded resources.

This provider responds to requests for embedded resources when the virtual path begins with an "@", e.g., http://localhost/@GSF.Web.Model.Scripts.gsf.web.client.js

To use, add the following to the Global.asax.cs Application_Start function: // Add additional virtual path provider to allow access to embedded resources EmbeddedResourceProvider.Register(); Then add the namespace paths to the embedded resources for which you need access to the Web.config <system.webServer> section: <system.webServer> <handlers> <!-- Add embedded resource handler for GSF script resources using slash delimiters --> <add name="EmbeddedResourceHandler-GSFScripts" path="@GSF/Web/Model/Scripts/*" verb="*" type="System.Web.StaticFileHandler" allowPathInfo="true" /> <!-- Add embedded resource handler for GSF view resources using slash delimiters --> <add name="EmbeddedResourceHandler-GSFViews" path="@GSF/Web/Model/Views/*" verb="*" type="System.Web.StaticFileHandler" allowPathInfo="true" /> <!-- Add embedded resource handler for GSF handler resources using slash delimiters --> <add name="EmbeddedResourceHandler-GSFHandlers" path="@GSF/Web/Model/Handlers/*" verb="*" type="System.Web.UI.SimpleHandlerFactory" allowPathInfo="true" /> <!-- Add embedded resource handler for fully qualified type names using dot delimiters (this should be defined last) --> <add name="EmbeddedResourceHandler-FQName" path="@*" verb="*" type="System.Web.StaticFileHandler" allowPathInfo="true" /> </handlers> </system.webServer>

Inheritance: System.Web.Hosting.VirtualPathProvider
Datei anzeigen Open project: GridProtectionAlliance/gsf

Public Methods

Method Description
DirectoryExists ( string virtualDir ) : bool

Gets a value that indicates whether a directory exists in the virtual file system.

FileExists ( string virtualPath ) : bool

Gets a value that indicates whether a file exists in the virtual file system.

Any virtual path that begins with an @ symbol is assumed to be an embedded resource where the path represents the namespace hierarchy in either slash or dot notation.

GetCacheDependency ( string virtualPath, IEnumerable virtualPathDependencies, System.DateTime utcStart ) : System.Web.Caching.CacheDependency

Creates a cache dependency based on the specified virtual paths.

GetDirectory ( string virtualDir ) : System.Web.Hosting.VirtualDirectory

Gets a virtual directory from the virtual file system.

GetFile ( string virtualPath ) : System.Web.Hosting.VirtualFile

Gets a file from the virtual file system.

Register ( ) : void

Registers the EmbeddedResourceProvider within a HostingEnvironment.

This function will properly register the EmbeddedResourceProvider even when being run from within a pre-compiled web application.

Private Methods

Method Description
IsEmbeddedResource ( string virtualPath ) : bool
ParseResourceNameFromVirtualPath ( string virtualPath ) : string

Method Details

DirectoryExists() public method

Gets a value that indicates whether a directory exists in the virtual file system.
public DirectoryExists ( string virtualDir ) : bool
virtualDir string The path to the virtual directory.
return bool

FileExists() public method

Gets a value that indicates whether a file exists in the virtual file system.
Any virtual path that begins with an @ symbol is assumed to be an embedded resource where the path represents the namespace hierarchy in either slash or dot notation.
public FileExists ( string virtualPath ) : bool
virtualPath string The path to the virtual file.
return bool

GetCacheDependency() public method

Creates a cache dependency based on the specified virtual paths.
public GetCacheDependency ( string virtualPath, IEnumerable virtualPathDependencies, System.DateTime utcStart ) : System.Web.Caching.CacheDependency
virtualPath string The path to the primary virtual resource.
virtualPathDependencies IEnumerable An array of paths to other resources required by the primary virtual resource.
utcStart System.DateTime The UTC time at which the virtual resources were read.
return System.Web.Caching.CacheDependency

GetDirectory() public method

Gets a virtual directory from the virtual file system.
public GetDirectory ( string virtualDir ) : System.Web.Hosting.VirtualDirectory
virtualDir string The path to the virtual directory.
return System.Web.Hosting.VirtualDirectory

GetFile() public method

Gets a file from the virtual file system.
public GetFile ( string virtualPath ) : System.Web.Hosting.VirtualFile
virtualPath string The path to the virtual file.
return System.Web.Hosting.VirtualFile

Register() public static method

Registers the EmbeddedResourceProvider within a HostingEnvironment.
This function will properly register the EmbeddedResourceProvider even when being run from within a pre-compiled web application.
public static Register ( ) : void
return void