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.
ファイルを表示 Open project: igorfrance/sage

Public Methods

Method 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 method

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
return string

Expand() public method

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.
return string

GetAssetPath() public method

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
return string

GetClosestLocaleSuffix() public method

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.
return string

GetDictionaryPath() public method

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.
return string

GetModulePath() public method

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
return string

GetModulePath() public method

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.
return string

GetModulePath() public method

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
return string

GetPhysicalCategoryPath() public method

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
return string

GetPhysicalViewPath() public method

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
return string

GetPluginPath() public method

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
return string

GetRelativeWebPath() public method

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.
return string

GetViewPath() public method

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
return string

Localize() public method

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.
return string

Localize() public method

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.
return string

Localize() public method

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.
return string

PathResolver() public method

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 .
return System

Resolve() public method

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.
return string

Resolve() public method

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
return string

Resolve() public method

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.
return string

Resolve() public method

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.
return string

Resolve() public method

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.
return string

Substitute() public method

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.
return string

Substitute() public method

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
return string

Substitute() public method

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.
return string

Substitute() public method

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.
return string