Click or drag to resize

EmbeddedResourceProvider Class

Represents a VirtualPathProvider that allows access to embedded resources.
Inheritance Hierarchy
SystemObject
  SystemMarshalByRefObject
    System.Web.HostingVirtualPathProvider
      GSF.Web.EmbeddedEmbeddedResourceProvider

Namespace: GSF.Web.Embedded
Assembly: GSF.Web (in GSF.Web.dll) Version: 2.4.218-beta
Syntax
public class EmbeddedResourceProvider : VirtualPathProvider
View Source

The EmbeddedResourceProvider type exposes the following members.

Constructors
 NameDescription
Public methodEmbeddedResourceProviderInitializes a new instance of the EmbeddedResourceProvider class
Top
Properties
 NameDescription
Protected propertyPreviousGets a reference to a previously registered VirtualPathProvider object in the compilation system.
(Inherited from VirtualPathProvider)
Top
Methods
 NameDescription
Public methodCombineVirtualPathsCombines a base path with a relative path to return a complete path to a virtual resource.
(Inherited from VirtualPathProvider)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject)
Public methodDirectoryExists Gets a value that indicates whether a directory exists in the virtual file system.
(Overrides VirtualPathProviderDirectoryExists(String))
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodFileExists Gets a value that indicates whether a file exists in the virtual file system.
(Overrides VirtualPathProviderFileExists(String))
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetCacheDependency Creates a cache dependency based on the specified virtual paths.
(Overrides VirtualPathProviderGetCacheDependency(String, IEnumerable, DateTime))
Public methodGetCacheKeyReturns a cache key to use for the specified virtual path.
(Inherited from VirtualPathProvider)
Public methodGetDirectory Gets a virtual directory from the virtual file system.
(Overrides VirtualPathProviderGetDirectory(String))
Public methodGetFile Gets a file from the virtual file system.
(Overrides VirtualPathProviderGetFile(String))
Public methodGetFileHashReturns a hash of the specified virtual paths.
(Inherited from VirtualPathProvider)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodInitializeInitializes the VirtualPathProvider instance.
(Inherited from VirtualPathProvider)
Public methodInitializeLifetimeServiceGives the VirtualPathProvider object an infinite lifetime by preventing a lease from being created.
(Inherited from VirtualPathProvider)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject)
Public methodStatic memberRegister Registers the EmbeddedResourceProvider within a HostingEnvironment.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Remarks

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:

C#
// 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:
C#
<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>

See Also