C# Class Masonry.Core.Hosting.EmbeddedFileProvider

Used to provide embedded files (other than views).
Can be used to provide embedded content files such as images, scripts etc.
Inheritance: IVirtualFileProvider
Afficher le fichier Open project: DenisVuyka/Masonry Class Usage Examples

Méthodes publiques

Méthode Description
Add ( Assembly assembly ) : void
Add ( NamespaceMapping mapping ) : void

Add a namespace mapping for embedded resources.

EmbeddedFileProvider ( ) : System
EmbeddedFileProvider ( string siteRoot ) : System

Initializes a new instance of the EmbeddedFileProvider class.

FileExists ( string virtualPath ) : bool

Checks if a file exits

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

Creates a cache dependency based on the specified virtual paths

GetCacheKey ( string virtualPath ) : string

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

Get the view

GetFileHash ( string virtualPath, IEnumerable dependencies ) : string

Get file hash.

Méthodes protégées

Méthode Description
IsFileAllowed ( string resourceName ) : bool

Determines if the found embedded file might be mapped and provided.

Default implementation uses AllowedFileExtensions to determine which files to servce.

LoadStream ( string virtualPath, MappedResource resource ) : Stream

Resource to load

The default implementation uses resource.Assembly.GetManifestResourceStream(resource.FullResourceName)

Map ( NamespaceMapping mapping ) : void

Create mappings for all resources in a specific namespace (and all sub namespaces).

Private Methods

Méthode Description
GetResource ( string uri ) : MappedResource

Get resource name by scanning all mapped namespaces.

Method Details

Add() public méthode

public Add ( Assembly assembly ) : void
assembly System.Reflection.Assembly
Résultat void

Add() public méthode

Add a namespace mapping for embedded resources.
public Add ( NamespaceMapping mapping ) : void
mapping NamespaceMapping Mapping to add
Résultat void

EmbeddedFileProvider() public méthode

public EmbeddedFileProvider ( ) : System
Résultat System

EmbeddedFileProvider() public méthode

Initializes a new instance of the EmbeddedFileProvider class.
public EmbeddedFileProvider ( string siteRoot ) : System
siteRoot string Root directory of the web site
Résultat System

FileExists() public méthode

Checks if a file exits
public FileExists ( string virtualPath ) : bool
virtualPath string Virtual path like "~/Views/Home/Index.cshtml"
Résultat bool

GetCacheDependency() public méthode

Creates a cache dependency based on the specified virtual paths
public GetCacheDependency ( string virtualPath, IEnumerable dependencies, System.DateTime utcStart ) : System.Web.Caching.CacheDependency
virtualPath string Virtual path like "~/Views/Home/Index.cshtml"
dependencies IEnumerable The dependencies.
utcStart System.DateTime The UTC start.
Résultat System.Web.Caching.CacheDependency

GetCacheKey() public méthode

public GetCacheKey ( string virtualPath ) : string
virtualPath string Virtual path like "~/Views/Home/Index.cshtml"
Résultat string

GetFile() public méthode

Get the view
public GetFile ( string virtualPath ) : System.Web.Hosting.VirtualFile
virtualPath string Virtual path like "~/Views/Home/Index.cshtml"
Résultat System.Web.Hosting.VirtualFile

GetFileHash() public méthode

Get file hash.
public GetFileHash ( string virtualPath, IEnumerable dependencies ) : string
virtualPath string Virtual path like "~/Views/Home/Index.cshtml"
dependencies IEnumerable The dependencies.
Résultat string

IsFileAllowed() protected méthode

Determines if the found embedded file might be mapped and provided.
Default implementation uses AllowedFileExtensions to determine which files to servce.
protected IsFileAllowed ( string resourceName ) : bool
resourceName string
Résultat bool

LoadStream() protected méthode

Resource to load
The default implementation uses resource.Assembly.GetManifestResourceStream(resource.FullResourceName)
protected LoadStream ( string virtualPath, MappedResource resource ) : Stream
virtualPath string Requested virtual path
resource MappedResource Identified resource (i.e. the one to load)
Résultat Stream

Map() protected méthode

Create mappings for all resources in a specific namespace (and all sub namespaces).
protected Map ( NamespaceMapping mapping ) : void
mapping NamespaceMapping Mapping to load embedded resources in
Résultat void