C# Class Westwind.Globalization.DbRes

Helper class that handles access to the DbResourceManager more easily with single method access. The T() method provides an easy way to embed resources into applications using the resource key. Also allows for resource reading, writing (new and updates transparently), deleting and clearing of resources from memory. This class uses the DbResourceManager class to access resources and still uses the standard ResourceManager infrastructure of .NET to cache resources efficiently in memory. Data access occurs only on intial access of each resource set/locale.
Afficher le fichier Open project: RickStrahl/Westwind.Globalization Class Usage Examples

Méthodes publiques

Méthode Description
ClearResources ( ) : void

Clears resources from memory and forces reloading of all ResourceSets. Effectively unloads the ResourceManager and ResourceProvider.

DeleteResource ( string resourceId, string resourceSet = null, string lang = null ) : bool

Deletes a resource entry

GetResourceManager ( string resourceSet ) : ResourceManager

Returns an instance of a DbResourceManager

GetResourceSet ( string resourceSet, string lang = null ) : ResourceSet

Returns a resource set for a given resource

T ( string resId, string resourceSet = null, string lang = null ) : string

Localization helper function that Translates a resource Id to a resource value string. Easy access that allows full control over the resource to retrieve or default UiCulture locale retrieval.

TDefault ( string resId, string defaultText, string resourceSet, string lang = null ) : string

Localization helper function that Translates a resource Id to a resource value string. If id is not found default text is returned. Easy access that allows full control over the resource to retrieve or default UiCulture locale retrieval.

TFormat ( string format, string resId, string resourceSet ) : string

Creates a localized format string that is transformed using the specified resource id.

TFormat ( string format, string resId, string resourceSet, string lang ) : string

Creates a localized format string that is transformed using the specified resource id.

THtml ( string resId, string resourceSet = null, string lang = null ) : System.Web.HtmlString

Localization helper function that Translates a resource Id to a resource value to an HtmlStringg. Easy access that allows full control over the resource to retrieve or default UiCulture locale retrieval. Use this version for HTML content that needs to be embedded in Razor views or other server tools that can use pre-encoded HTML content.

TObject ( string resId, string resourceSet = null, string lang = null, bool autoAdd = false ) : object

Localization helper function that Translates a resource Id to a resource value object. Use this function if you're retrieving non-string values - for string values just use T.

WriteResource ( string resourceId, string value = null, string lang = null, string resourceSet = null ) : bool

Writes a resource either creating or updating an existing resource

Private Methods

Méthode Description
DbRes ( ) : System.Collections.Generic

Method Details

ClearResources() public static méthode

Clears resources from memory and forces reloading of all ResourceSets. Effectively unloads the ResourceManager and ResourceProvider.
public static ClearResources ( ) : void
Résultat void

DeleteResource() public static méthode

Deletes a resource entry
public static DeleteResource ( string resourceId, string resourceSet = null, string lang = null ) : bool
resourceId string The resource to delete
resourceSet string The resource set to apply
lang string The language Id - Be careful: If empty or null deletes matching keys for all languages
Résultat bool

GetResourceManager() public static méthode

Returns an instance of a DbResourceManager
public static GetResourceManager ( string resourceSet ) : ResourceManager
resourceSet string
Résultat System.Resources.ResourceManager

GetResourceSet() public static méthode

Returns a resource set for a given resource
public static GetResourceSet ( string resourceSet, string lang = null ) : ResourceSet
resourceSet string The name of the resource set to return.
lang string The language code (en-US,de-DE). Pass null to use the current ui culture
Résultat System.Resources.ResourceSet

T() public static méthode

Localization helper function that Translates a resource Id to a resource value string. Easy access that allows full control over the resource to retrieve or default UiCulture locale retrieval.
public static T ( string resId, string resourceSet = null, string lang = null ) : string
resId string The Resource Id to retrieve /// Note resource Ids can be *any* string and if no /// matching resource is found the id is returned. ///
resourceSet string Name of the ResourceSet that houses this resource. If null or empty resources are used.
lang string 5 letter or 2 letter language ieetf code: en-US, de-DE or en, de etc.
Résultat string

TDefault() public static méthode

Localization helper function that Translates a resource Id to a resource value string. If id is not found default text is returned. Easy access that allows full control over the resource to retrieve or default UiCulture locale retrieval.
public static TDefault ( string resId, string defaultText, string resourceSet, string lang = null ) : string
resId string The Resource Id to retrieve
defaultText string Default text that is returned when resource with given resId is not found
resourceSet string Name of the ResourceSet that houses this resource. If null or empty resources are used.
lang string 5 letter or 2 letter language ieetf code: en-US, de-DE or en, de etc.
Résultat string

TFormat() public static méthode

Creates a localized format string that is transformed using the specified resource id.
public static TFormat ( string format, string resId, string resourceSet ) : string
format string Format string that is to be localized
resId string Resource id to localize from
resourceSet string Resource set to localize from
Résultat string

TFormat() public static méthode

Creates a localized format string that is transformed using the specified resource id.
public static TFormat ( string format, string resId, string resourceSet, string lang ) : string
format string Format string that is to be localized
resId string Resource id to localize from
resourceSet string Resource set to localize from
lang string Language code
Résultat string

THtml() public static méthode

Localization helper function that Translates a resource Id to a resource value to an HtmlStringg. Easy access that allows full control over the resource to retrieve or default UiCulture locale retrieval. Use this version for HTML content that needs to be embedded in Razor views or other server tools that can use pre-encoded HTML content.
public static THtml ( string resId, string resourceSet = null, string lang = null ) : System.Web.HtmlString
resId string The Resource Id to retrieve /// Note resource Ids can be *any* string and if no /// matching resource is found the id is returned. ///
resourceSet string Name of the ResourceSet that houses this resource. If null or empty resources are used.
lang string 5 letter or 2 letter language ieetf code: en-US, de-DE or en, de etc.
Résultat System.Web.HtmlString

TObject() public static méthode

Localization helper function that Translates a resource Id to a resource value object. Use this function if you're retrieving non-string values - for string values just use T.
public static TObject ( string resId, string resourceSet = null, string lang = null, bool autoAdd = false ) : object
resId string The Resource Id to retrieve /// Note resource Ids can be *any* string and if no /// matching resource is found the id is returned. ///
resourceSet string Name of the ResourceSet that houses this resource. If null or empty resources are used.
lang string 5 letter or 2 letter language ieetf code: en-US, de-DE or en, de etc.
autoAdd bool If true if a resource cannot be found a new entry is added in the invariant locale
Résultat object

WriteResource() public static méthode

Writes a resource either creating or updating an existing resource
public static WriteResource ( string resourceId, string value = null, string lang = null, string resourceSet = null ) : bool
resourceId string Resource Id to write. Resource Ids can be any string up to 1024 bytes in length
value string Value to set the resource to
lang string Language as ieetf code: en-US, de-DE etc. /// Value can be left blank for Invariant/Default culture to set. ///
resourceSet string The resourceSet to store the resource on. /// If no resource set name is provided a default empty resource set is used.
Résultat bool