C# Class Sage.ResourceManagement.PathResolver

Provides a class that resolves physical file paths based on current category, locale and any fallback scenario currently in place.
Afficher le fichier Open project: igorfrance/sage

Méthodes publiques

Méthode Description
Expand ( string relativePath ) : string

Expands the specified relativePath to a physical path in the the current context category.

Expand ( string relativePath, string category ) : string

Expands the specified relativePath to a physical path in the specified category.

GetAssetPath ( string category ) : string

Returns the path to the assets folder of the specified category.

GetClosestLocaleSuffix ( string path, string locale ) : string

Gets the suffix of an existing file most closely matching the specified locale.

If the resource name suffix fallback hierarchy is configured to be: ch,de,default, while the specified locale is ch, given the path g:\projects\p1\resources\image.png, the method looks for files in this order: g:\projects\p1\resources\image-ch.png g:\projects\p1\resources\image-de.png g:\projects\p1\resources\image-default.png g:\projects\p1\resources\image.png As soon as a match is found, the search is over and the found file's suffix (e.g. 'de') is returned.

GetDictionaryPath ( string locale = null, string category = null ) : string

Gets the path to the dictionary, either using the current context's locale and category, or if specified, using the locale and category arguments.

GetModulePath ( Type moduleType, string childPath ) : string

Expands the specified childPath to its full path within the module specified with moduleType.

GetModulePath ( string moduleName ) : string

Gets the expanded and resolved path to the module with the specified moduleName.

GetModulePath ( string moduleKey, string childPath ) : string

Expands the specified childPath to its full path within the module with the specified moduleKey.

GetPhysicalCategoryPath ( string category = null ) : string

Returns the physical path to the assets folder of the specified category.

GetPhysicalViewPath ( string category = null ) : string

Returns the physical path to the views folder of the specified category.

GetPluginPath ( string pluginName, string childPath ) : string

Expands the specified childPath to its full path within the module with the specified pluginName.

GetRelativeWebPath ( string path, bool prependApplicationPath = false ) : string

Converts, if possible, an absolute path to it's equivalent web accessible location (relative to the application path).

GetViewPath ( string category = null ) : string

Returns the path to the views folder of the specified category.

Localize ( string path ) : string

Returns a localized version of the path, if such a file exists, searching for the name that most closely matches the current locale.

Localize ( string path, bool mapPath ) : string

Returns a localized version of the path, if such a file exists, searching for the name that most closely matches the current locale.

Localize ( string path, string locale, bool mapPath = false ) : string

Returns a localized version of the path, if such a file exists, searching for the name that most closely matches the current locale.

If the resource name suffix fallback hierarchy is configured to be: ch,de,default, while the specified locale is ch, given the path g:\projects\p1\resources\image.png, the method looks for files in this order: g:\projects\p1\resources\image-ch.png g:\projects\p1\resources\image-de.png g:\projects\p1\resources\image-default.png g:\projects\p1\resources\image.png As soon as a match is found, the search is over and the found file's path is returned.

The resulting path will not be mapped from a web to a physical path, it will be localized as-is.

PathResolver ( SageContext context ) : System

Initializes a new instance of the PathResolver class using the specified SageContext to retrieve current category and locale information.

Resolve ( string templatePath ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the current SageContext and returns an absolute path.

Resolve ( string templatePath, System.Web.QueryString values ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified values and returns an absolute path.

Resolve ( string templatePath, SageContext context ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified context and returns an absolute path.

Resolve ( string templatePath, string category ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration, the current SageContext and the specified category, and returns an absolute path.

Resolve ( string templatePath, string category, string locale ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration, the current SageContext and the specified category and locale, and returns an absolute path.

Substitute ( string templatePath ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the current SageContext.

Substitute ( string templatePath, System.Web.QueryString values ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified values.

Substitute ( string templatePath, SageContext context ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified context.

Substitute ( string templatePath, string category ) : string

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration, the current SageContext and the specified category.

Method Details

Expand() public méthode

Expands the specified relativePath to a physical path in the the current context category.
public Expand ( string relativePath ) : string
relativePath string The path to expand
Résultat string

Expand() public méthode

Expands the specified relativePath to a physical path in the specified category.
public Expand ( string relativePath, string category ) : string
relativePath string The path to expand
category string The category under which to expand the path.
Résultat string

GetAssetPath() public méthode

Returns the path to the assets folder of the specified category.
public GetAssetPath ( string category ) : string
category string The category for which to return the path
Résultat string

GetClosestLocaleSuffix() public méthode

Gets the suffix of an existing file most closely matching the specified locale.
If the resource name suffix fallback hierarchy is configured to be: ch,de,default, while the specified locale is ch, given the path g:\projects\p1\resources\image.png, the method looks for files in this order: g:\projects\p1\resources\image-ch.png g:\projects\p1\resources\image-de.png g:\projects\p1\resources\image-default.png g:\projects\p1\resources\image.png As soon as a match is found, the search is over and the found file's suffix (e.g. 'de') is returned.
public GetClosestLocaleSuffix ( string path, string locale ) : string
path string The path to the file, without any suffix.
locale string The locale for which to search.
Résultat string

GetDictionaryPath() public méthode

Gets the path to the dictionary, either using the current context's locale and category, or if specified, using the locale and category arguments.
public GetDictionaryPath ( string locale = null, string category = null ) : string
locale string Optional locale of the dictionary path to get.
category string Optional category of the dictionary path to get.
Résultat string

GetModulePath() public méthode

Expands the specified childPath to its full path within the module specified with moduleType.
public GetModulePath ( Type moduleType, string childPath ) : string
moduleType System.Type The type of the module for which the path is being expanded.
childPath string The path to expand
Résultat string

GetModulePath() public méthode

Gets the expanded and resolved path to the module with the specified moduleName.
public GetModulePath ( string moduleName ) : string
moduleName string Name of the module whose path to get.
Résultat string

GetModulePath() public méthode

Expands the specified childPath to its full path within the module with the specified moduleKey.
public GetModulePath ( string moduleKey, string childPath ) : string
moduleKey string The name (or combination of category/name) of the module for which the path is being expanded.
childPath string The path to expand
Résultat string

GetPhysicalCategoryPath() public méthode

Returns the physical path to the assets folder of the specified category.
public GetPhysicalCategoryPath ( string category = null ) : string
category string The category for which to return the path
Résultat string

GetPhysicalViewPath() public méthode

Returns the physical path to the views folder of the specified category.
public GetPhysicalViewPath ( string category = null ) : string
category string The category for which to return the path
Résultat string

GetPluginPath() public méthode

Expands the specified childPath to its full path within the module with the specified pluginName.
public GetPluginPath ( string pluginName, string childPath ) : string
pluginName string The name of the plugin for which the path is being expanded.
childPath string The path to expand
Résultat string

GetRelativeWebPath() public méthode

Converts, if possible, an absolute path to it's equivalent web accessible location (relative to the application path).
public GetRelativeWebPath ( string path, bool prependApplicationPath = false ) : string
path string The path to convert, for instance c:\Inetpub\wwwroot\mysite\static\resource.xml
prependApplicationPath bool if set to true, the path returned will be prefixed with the /// application path, if the path doesn't start with it already.
Résultat string

GetViewPath() public méthode

Returns the path to the views folder of the specified category.
public GetViewPath ( string category = null ) : string
category string The category for which to return the path
Résultat string

Localize() public méthode

Returns a localized version of the path, if such a file exists, searching for the name that most closely matches the current locale.
public Localize ( string path ) : string
path string The path, without any localization.
Résultat string

Localize() public méthode

Returns a localized version of the path, if such a file exists, searching for the name that most closely matches the current locale.
public Localize ( string path, bool mapPath ) : string
path string The path, without any localization.
mapPath bool If true, the resulting path will be converted to a physical path.
Résultat string

Localize() public méthode

Returns a localized version of the path, if such a file exists, searching for the name that most closely matches the current locale.
If the resource name suffix fallback hierarchy is configured to be: ch,de,default, while the specified locale is ch, given the path g:\projects\p1\resources\image.png, the method looks for files in this order: g:\projects\p1\resources\image-ch.png g:\projects\p1\resources\image-de.png g:\projects\p1\resources\image-default.png g:\projects\p1\resources\image.png As soon as a match is found, the search is over and the found file's path is returned.

The resulting path will not be mapped from a web to a physical path, it will be localized as-is.

public Localize ( string path, string locale, bool mapPath = false ) : string
path string The path, without any localization.
locale string The locale for which to search.
mapPath bool If true, the resulting path will be converted to a physical path.
Résultat string

PathResolver() public méthode

Initializes a new instance of the PathResolver class using the specified SageContext to retrieve current category and locale information.
public PathResolver ( SageContext context ) : System
context SageContext The current .
Résultat System

Resolve() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the current SageContext and returns an absolute path.
public Resolve ( string templatePath ) : string
templatePath string The path to resolve.
Résultat string

Resolve() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified values and returns an absolute path.
public Resolve ( string templatePath, System.Web.QueryString values ) : string
templatePath string The template path to resolve.
values System.Web.QueryString The name/value collection of values to use
Résultat string

Resolve() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified context and returns an absolute path.
public Resolve ( string templatePath, SageContext context ) : string
templatePath string The template path to resolve.
context SageContext The context to use to get the category.
Résultat string

Resolve() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration, the current SageContext and the specified category, and returns an absolute path.
public Resolve ( string templatePath, string category ) : string
templatePath string The path to resolve.
category string The category to use instead of the current context's category when resolving.
Résultat string

Resolve() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration, the current SageContext and the specified category and locale, and returns an absolute path.
public Resolve ( string templatePath, string category, string locale ) : string
templatePath string The path to resolve.
category string The category to use instead of the current context's category when resolving.
locale string The locale to use instead of the current context's locale when resolving.
Résultat string

Substitute() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the current SageContext.
public Substitute ( string templatePath ) : string
templatePath string The path to resolve.
Résultat string

Substitute() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified values.
public Substitute ( string templatePath, System.Web.QueryString values ) : string
templatePath string The template path to resolve.
values System.Web.QueryString The name/value collection of values to use
Résultat string

Substitute() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration and the specified context.
public Substitute ( string templatePath, SageContext context ) : string
templatePath string The template path to resolve.
context SageContext The context to use to get the category.
Résultat string

Substitute() public méthode

Substitutes any placeholders in the specified templatePath with values from the current ProjectConfiguration, the current SageContext and the specified category.
public Substitute ( string templatePath, string category ) : string
templatePath string The path to resolve.
category string The category to use instead of the current context's category when resolving.
Résultat string