C# Class Westwind.Globalization.DbResourceDataManager

Inheritance: IDbResourceDataManager
Afficher le fichier Open project: RickStrahl/Westwind.Globalization Class Usage Examples

Méthodes publiques

Méthode Description
AddResource ( Westwind.Globalization.ResourceItem resource ) : int

Adds a resource to the Localization Table

AddResource ( string resourceId, object value, string cultureName, string resourceSet, string comment = null, bool valueIsFileName = false, int valueType ) : int

Adds a resource to the Localization Table

CreateBackupTable ( string BackupTableName ) : bool

Create a backup of the localization database. Note the table used is the one specified in the Configuration.ResourceTableName

CreateDbResourceDataManager ( DbResourceProviderTypes type ) : DbResourceDataManager

Create an instance of the provider based on the resource type

CreateDbResourceDataManager ( Type managerType = null ) : DbResourceDataManager

Creates an instance of the DbResourceDataManager based on configuration settings

CreateLocalizationTable ( string tableName = null ) : bool

Creates the Localization table on the current connection string for the provider.

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

Deletes a specific resource ID based on ResourceId, ResourceSet and Culture. If an empty culture is passed the entire group is removed (ie. all locales).

DeleteResourceSet ( string ResourceSet, string cultureName = null ) : bool

Deletes an entire resource set from the database. Careful with this function!

GenerateResources ( IDictionary resourceList, string cultureName, string resourceSet, bool deleteAllResourceFirst ) : bool

Persists resources to the database - first wipes out all resources, then writes them back in from the ResourceSet

GetAllLocaleIds ( string resourceSet ) : List

Gets all the locales for a specific resource set. Returns a table named TLocaleIds (LocaleId field)

GetAllLocalesForResourceSet ( string resourceSet ) : List
GetAllResourceIdListItems ( string resourceSet ) : List

Returns a list with ResourceId and HasValues fields where the ResourceId is formatted for HTML display.

GetAllResourceIds ( string resourceSet ) : List

Returns all available resource ids for a given resource set in all languages. Returns a ResourceIdItem object with ResourecId and HasValue fields. HasValue returns whether there are any entries in any culture for this resourceId

GetAllResourceSets ( ResourceListingTypes type ) : List

Returns all available resource sets

GetAllResources ( bool localResources = false, bool applyValueConverters = false, string resourceSet = null ) : List

Returns a list of all the resources for all locales. The result is in a table called TResources that contains all fields of the table. The table is ordered by LocaleId. This version returns either local or global resources in a Web app Fields: ResourceId,Value,LocaleId,ResourceSet,Type

GetAllResourcesForCulture ( string resourceSet, string cultureName ) : List

Gets all the Resourecs and ResourceIds for a given resource set and Locale returns a table "TResource" ResourceId, Value fields

GetDb ( string connectionString = null ) : DataAccessBase

Creates an instance of the DataAccess Data provider

GetFileInfo ( string fileName, bool noPhysicalFile = false ) : FileInfoFormat

Internal routine that looks at a file and based on its extension determines how that file needs to be stored in the database. Returns FileInfoFormat structure

GetResourceItem ( string resourceId, string resourceSet, string cultureName ) : Westwind.Globalization.ResourceItem

Returns a resource item that returns both the Value and Comment to the fields to the client.

GetResourceItems ( string resourceId, string resourceSet, bool forAllResourceSetLocales = false ) : IEnumerable

Returns all resource items for a given resource ID in all locales. Returned as full ResourceItem objects

GetResourceObject ( string resourceId, string resourceSet, string cultureName ) : object

Returns an object from the Resources. Attempts to convert the object to its original type. Use this for any non-string types. Useful for binary resources like images, icons etc. While this method can be used with strings, GetResourceString() is much more efficient.

GetResourceSet ( string cultureName, string resourceSet ) : IDictionary

Returns a specific set of resources for a given culture and 'resource set' which in this case is just the virtual directory and culture.

GetResourceSetNormalizedForLocaleId ( string cultureName, string resourceSet ) : object>.Dictionary

Returns a fully normalized list of resources that contains the most specific locale version for the culture provided. This means that this routine walks the resource hierarchy and returns the most specific value in this order: de-ch, de, invariant.

GetResourceString ( string resourceId, string resourceSet, string cultureName ) : string

Returns an individual Resource String from the database

GetResourceStrings ( string resourceId, string resourceSet, bool forAllResourceSetLocales = false ) : string>.Dictionary

Returns all the resource strings for all cultures for a specific resource Id. Returned as a dictionary.

GetResourcesAsJavascriptObject ( string javaScriptVarName, string resourceSet, string localeId ) : string

Creates an global JavaScript object object that holds all non-control local string resources as property values. All resources are returned in normalized fashion from most specifc to more generic (de-ch,de,invariant depending on availability)

IsLocalizationTable ( string tableName = null ) : bool

Checks to see if the LocalizationTable exists

IsValidCulture ( string IetfTag ) : bool

Returns true or false depending on whether the two letter country code exists

RenameResource ( string ResourceId, string NewResourceId, string ResourceSet ) : bool

Renames a given resource in a resource set. Note all languages will be renamed

RenameResourceProperty ( string Property, string NewProperty, string ResourceSet ) : bool

Renames all property keys for a given property prefix. So this routine updates lblName.Text, lblName.ToolTip to lblName2.Text, lblName2.ToolTip if the property is changed from lblName to lblName2.

RenameResourceSet ( string OldResourceSet, string NewResourceSet ) : bool

Renames a resource set. Useful if you need to move a local page resource set to a new page. ResourceSet naming for local resources is application relative page path: test.aspx subdir/test.aspx Global resources have a simple name

ResourceExists ( string ResourceId, string CultureName, string ResourceSet ) : bool

Checks to see if a resource exists in the resource store

RestoreBackupTable ( string backupTableName ) : bool

Restores the localization table from a backup table by first wiping out

SetError ( ) : void
SetError ( Exception ex ) : void
SetError ( string message ) : void
SetFileDataOnResourceItem ( Westwind.Globalization.ResourceItem item, byte data, string fileName ) : Westwind.Globalization.ResourceItem
UpdateOrAddResource ( Westwind.Globalization.ResourceItem resource ) : int

Updates a resource if it exists, if it doesn't one is created

UpdateOrAddResource ( string resourceId, object value, string cultureName, string resourceSet, string comment = null, bool valueIsFileName = false, int valueType ) : int

Updates a resource if it exists, if it doesn't one is created

UpdateResource ( Westwind.Globalization.ResourceItem resource ) : int

Updates a resource if it exists, if it doesn't one is created

UpdateResource ( string resourceId, object value, string cultureName, string resourceSet, string comment = null, bool valueIsFileName = false, int valueType ) : int

Updates an existing resource in the Localization table

Méthodes protégées

Méthode Description
DbResourceDataManager ( ) : System
DeserializeValue ( string serializedValue, string resourceType ) : object

Deserializes serialized data in JSON format based on a type name provided in the resource type parameter.

OnResourceSetValueConvert ( object &resourceValue, string key, int valueType ) : void
SerializeValue ( object value ) : string

Serializes a value to string that can be stored in data storage. Used for serializing arbitrary objects to store in the application

Private Methods

Méthode Description
LoadFileResource ( IDataReader reader ) : object

Internal method used to parse the data in the database into a 'real' value. Value field hold filename and type string TextFile,BinFile hold the actual file content

Method Details

AddResource() public méthode

Adds a resource to the Localization Table
public AddResource ( Westwind.Globalization.ResourceItem resource ) : int
resource Westwind.Globalization.ResourceItem Resource to update
Résultat int

AddResource() public méthode

Adds a resource to the Localization Table
public AddResource ( string resourceId, object value, string cultureName, string resourceSet, string comment = null, bool valueIsFileName = false, int valueType ) : int
resourceId string The resource key name
value object Value to set it to. Can also be a file which is loaded as binary data when valueIsFileName is true
cultureName string name of the culture or null for invariant/default
resourceSet string The ResourceSet to which the resource id is added
comment string Optional comment for the key
valueIsFileName bool if true the Value property is a filename to import
valueType int
Résultat int

CreateBackupTable() public méthode

Create a backup of the localization database. Note the table used is the one specified in the Configuration.ResourceTableName
public CreateBackupTable ( string BackupTableName ) : bool
BackupTableName string Table of the backup table. Null creates a _Backup table.
Résultat bool

CreateDbResourceDataManager() public static méthode

Create an instance of the provider based on the resource type
public static CreateDbResourceDataManager ( DbResourceProviderTypes type ) : DbResourceDataManager
type DbResourceProviderTypes
Résultat DbResourceDataManager

CreateDbResourceDataManager() public static méthode

Creates an instance of the DbResourceDataManager based on configuration settings
public static CreateDbResourceDataManager ( Type managerType = null ) : DbResourceDataManager
managerType System.Type
Résultat DbResourceDataManager

CreateLocalizationTable() public méthode

Creates the Localization table on the current connection string for the provider.
public CreateLocalizationTable ( string tableName = null ) : bool
tableName string
Résultat bool

DbResourceDataManager() protected méthode

protected DbResourceDataManager ( ) : System
Résultat System

DeleteResource() public méthode

Deletes a specific resource ID based on ResourceId, ResourceSet and Culture. If an empty culture is passed the entire group is removed (ie. all locales).
public DeleteResource ( string resourceId, string resourceSet = null, string cultureName = null ) : bool
resourceId string Resource Id to delete
resourceSet string The resource set to remove
cultureName string language ID - if empty all languages are deleted
Résultat bool

DeleteResourceSet() public méthode

Deletes an entire resource set from the database. Careful with this function!
public DeleteResourceSet ( string ResourceSet, string cultureName = null ) : bool
ResourceSet string
cultureName string
Résultat bool

DeserializeValue() protected méthode

Deserializes serialized data in JSON format based on a type name provided in the resource type parameter.
protected DeserializeValue ( string serializedValue, string resourceType ) : object
serializedValue string JSON encoded string
resourceType string Type name to deserialize - type must be referenced by the app
Résultat object

GenerateResources() public méthode

Persists resources to the database - first wipes out all resources, then writes them back in from the ResourceSet
public GenerateResources ( IDictionary resourceList, string cultureName, string resourceSet, bool deleteAllResourceFirst ) : bool
resourceList IDictionary
cultureName string
resourceSet string
deleteAllResourceFirst bool
Résultat bool

GetAllLocaleIds() public méthode

Gets all the locales for a specific resource set. Returns a table named TLocaleIds (LocaleId field)
public GetAllLocaleIds ( string resourceSet ) : List
resourceSet string
Résultat List

GetAllLocalesForResourceSet() public méthode

public GetAllLocalesForResourceSet ( string resourceSet ) : List
resourceSet string
Résultat List

GetAllResourceIdListItems() public méthode

Returns a list with ResourceId and HasValues fields where the ResourceId is formatted for HTML display.
public GetAllResourceIdListItems ( string resourceSet ) : List
resourceSet string
Résultat List

GetAllResourceIds() public méthode

Returns all available resource ids for a given resource set in all languages. Returns a ResourceIdItem object with ResourecId and HasValue fields. HasValue returns whether there are any entries in any culture for this resourceId
public GetAllResourceIds ( string resourceSet ) : List
resourceSet string
Résultat List

GetAllResourceSets() public méthode

Returns all available resource sets
public GetAllResourceSets ( ResourceListingTypes type ) : List
type ResourceListingTypes
Résultat List

GetAllResources() public méthode

Returns a list of all the resources for all locales. The result is in a table called TResources that contains all fields of the table. The table is ordered by LocaleId. This version returns either local or global resources in a Web app Fields: ResourceId,Value,LocaleId,ResourceSet,Type
public GetAllResources ( bool localResources = false, bool applyValueConverters = false, string resourceSet = null ) : List
localResources bool return local resources if true
applyValueConverters bool
resourceSet string
Résultat List

GetAllResourcesForCulture() public méthode

Gets all the Resourecs and ResourceIds for a given resource set and Locale returns a table "TResource" ResourceId, Value fields
public GetAllResourcesForCulture ( string resourceSet, string cultureName ) : List
resourceSet string
cultureName string
Résultat List

GetDb() public méthode

Creates an instance of the DataAccess Data provider
public GetDb ( string connectionString = null ) : DataAccessBase
connectionString string
Résultat DataAccessBase

GetFileInfo() public static méthode

Internal routine that looks at a file and based on its extension determines how that file needs to be stored in the database. Returns FileInfoFormat structure
public static GetFileInfo ( string fileName, bool noPhysicalFile = false ) : FileInfoFormat
fileName string
noPhysicalFile bool
Résultat FileInfoFormat

GetResourceItem() public méthode

Returns a resource item that returns both the Value and Comment to the fields to the client.
public GetResourceItem ( string resourceId, string resourceSet, string cultureName ) : Westwind.Globalization.ResourceItem
resourceId string The ID of the resource to retrieve
resourceSet string Name of the ResourceSet to return
cultureName string required. Null or Empty returns invariant
Résultat Westwind.Globalization.ResourceItem

GetResourceItems() public méthode

Returns all resource items for a given resource ID in all locales. Returned as full ResourceItem objects
public GetResourceItems ( string resourceId, string resourceSet, bool forAllResourceSetLocales = false ) : IEnumerable
resourceId string The resource Id to return for
resourceSet string Resourceset to look in
forAllResourceSetLocales bool When true returns empty entries for missing resources of locales in this resource set
Résultat IEnumerable

GetResourceObject() public méthode

Returns an object from the Resources. Attempts to convert the object to its original type. Use this for any non-string types. Useful for binary resources like images, icons etc. While this method can be used with strings, GetResourceString() is much more efficient.
public GetResourceObject ( string resourceId, string resourceSet, string cultureName ) : object
resourceId string
resourceSet string
cultureName string required. Null or Empty culture returns invariant
Résultat object

GetResourceSet() public méthode

Returns a specific set of resources for a given culture and 'resource set' which in this case is just the virtual directory and culture.
public GetResourceSet ( string cultureName, string resourceSet ) : IDictionary
cultureName string name of the culture Id (de, de-de) to retrieve
resourceSet string Name of the resource set to retrieve
Résultat IDictionary

GetResourceSetNormalizedForLocaleId() public méthode

Returns a fully normalized list of resources that contains the most specific locale version for the culture provided. This means that this routine walks the resource hierarchy and returns the most specific value in this order: de-ch, de, invariant.
public GetResourceSetNormalizedForLocaleId ( string cultureName, string resourceSet ) : object>.Dictionary
cultureName string
resourceSet string
Résultat object>.Dictionary

GetResourceString() public méthode

Returns an individual Resource String from the database
public GetResourceString ( string resourceId, string resourceSet, string cultureName ) : string
resourceId string
resourceSet string
cultureName string
Résultat string

GetResourceStrings() public méthode

Returns all the resource strings for all cultures for a specific resource Id. Returned as a dictionary.
public GetResourceStrings ( string resourceId, string resourceSet, bool forAllResourceSetLocales = false ) : string>.Dictionary
resourceId string Resource Id to retrieve strings for
resourceSet string Resource Set on which to retrieve strings
forAllResourceSetLocales bool If true returns empty entries for each locale that exists but has no value in this resource set
Résultat string>.Dictionary

GetResourcesAsJavascriptObject() public méthode

Creates an global JavaScript object object that holds all non-control local string resources as property values. All resources are returned in normalized fashion from most specifc to more generic (de-ch,de,invariant depending on availability)
public GetResourcesAsJavascriptObject ( string javaScriptVarName, string resourceSet, string localeId ) : string
javaScriptVarName string Name of the JS object variable to createBackupTable
resourceSet string ResourceSet name. Pass NULL for locale Resources
localeId string
Résultat string

IsLocalizationTable() public méthode

Checks to see if the LocalizationTable exists
public IsLocalizationTable ( string tableName = null ) : bool
tableName string Table name or the configuration.ResourceTableName if not passed
Résultat bool

IsValidCulture() public méthode

Returns true or false depending on whether the two letter country code exists
public IsValidCulture ( string IetfTag ) : bool
IetfTag string two or four letter IETF tag (examples: de, de-DE,fr,fr-CA)
Résultat bool

OnResourceSetValueConvert() protected méthode

protected OnResourceSetValueConvert ( object &resourceValue, string key, int valueType ) : void
resourceValue object
key string
valueType int
Résultat void

RenameResource() public méthode

Renames a given resource in a resource set. Note all languages will be renamed
public RenameResource ( string ResourceId, string NewResourceId, string ResourceSet ) : bool
ResourceId string
NewResourceId string
ResourceSet string
Résultat bool

RenameResourceProperty() public méthode

Renames all property keys for a given property prefix. So this routine updates lblName.Text, lblName.ToolTip to lblName2.Text, lblName2.ToolTip if the property is changed from lblName to lblName2.
public RenameResourceProperty ( string Property, string NewProperty, string ResourceSet ) : bool
Property string
NewProperty string
ResourceSet string
Résultat bool

RenameResourceSet() public méthode

Renames a resource set. Useful if you need to move a local page resource set to a new page. ResourceSet naming for local resources is application relative page path: test.aspx subdir/test.aspx Global resources have a simple name
public RenameResourceSet ( string OldResourceSet, string NewResourceSet ) : bool
OldResourceSet string Name of the existing resource set
NewResourceSet string Name to set the resourceset name to
Résultat bool

ResourceExists() public méthode

Checks to see if a resource exists in the resource store
public ResourceExists ( string ResourceId, string CultureName, string ResourceSet ) : bool
ResourceId string
CultureName string
ResourceSet string
Résultat bool

RestoreBackupTable() public méthode

Restores the localization table from a backup table by first wiping out
public RestoreBackupTable ( string backupTableName ) : bool
backupTableName string
Résultat bool

SerializeValue() protected méthode

Serializes a value to string that can be stored in data storage. Used for serializing arbitrary objects to store in the application
protected SerializeValue ( object value ) : string
value object
Résultat string

SetError() public méthode

public SetError ( ) : void
Résultat void

SetError() public méthode

public SetError ( Exception ex ) : void
ex System.Exception
Résultat void

SetError() public méthode

public SetError ( string message ) : void
message string
Résultat void

SetFileDataOnResourceItem() public static méthode

public static SetFileDataOnResourceItem ( Westwind.Globalization.ResourceItem item, byte data, string fileName ) : Westwind.Globalization.ResourceItem
item Westwind.Globalization.ResourceItem
data byte
fileName string
Résultat Westwind.Globalization.ResourceItem

UpdateOrAddResource() public méthode

Updates a resource if it exists, if it doesn't one is created
public UpdateOrAddResource ( Westwind.Globalization.ResourceItem resource ) : int
resource Westwind.Globalization.ResourceItem Resource to update
Résultat int

UpdateOrAddResource() public méthode

Updates a resource if it exists, if it doesn't one is created
public UpdateOrAddResource ( string resourceId, object value, string cultureName, string resourceSet, string comment = null, bool valueIsFileName = false, int valueType ) : int
resourceId string
value object
cultureName string
resourceSet string
comment string
valueIsFileName bool
valueType int
Résultat int

UpdateResource() public méthode

Updates a resource if it exists, if it doesn't one is created
public UpdateResource ( Westwind.Globalization.ResourceItem resource ) : int
resource Westwind.Globalization.ResourceItem Resource to update
Résultat int

UpdateResource() public méthode

Updates an existing resource in the Localization table
public UpdateResource ( string resourceId, object value, string cultureName, string resourceSet, string comment = null, bool valueIsFileName = false, int valueType ) : int
resourceId string
value object
cultureName string
resourceSet string
comment string
valueIsFileName bool
valueType int
Résultat int