C# Класс Westwind.Globalization.DbResourceDataManager

Наследование: IDbResourceDataManager
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

AddResource() публичный Метод

Adds a resource to the Localization Table
public AddResource ( Westwind.Globalization.ResourceItem resource ) : int
resource Westwind.Globalization.ResourceItem Resource to update
Результат int

AddResource() публичный Метод

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
Результат int

CreateBackupTable() публичный Метод

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.
Результат bool

CreateDbResourceDataManager() публичный статический Метод

Create an instance of the provider based on the resource type
public static CreateDbResourceDataManager ( DbResourceProviderTypes type ) : DbResourceDataManager
type DbResourceProviderTypes
Результат DbResourceDataManager

CreateDbResourceDataManager() публичный статический Метод

Creates an instance of the DbResourceDataManager based on configuration settings
public static CreateDbResourceDataManager ( Type managerType = null ) : DbResourceDataManager
managerType System.Type
Результат DbResourceDataManager

CreateLocalizationTable() публичный Метод

Creates the Localization table on the current connection string for the provider.
public CreateLocalizationTable ( string tableName = null ) : bool
tableName string
Результат bool

DbResourceDataManager() защищенный Метод

protected DbResourceDataManager ( ) : System
Результат System

DeleteResource() публичный Метод

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
Результат bool

DeleteResourceSet() публичный Метод

Deletes an entire resource set from the database. Careful with this function!
public DeleteResourceSet ( string ResourceSet, string cultureName = null ) : bool
ResourceSet string
cultureName string
Результат bool

DeserializeValue() защищенный Метод

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
Результат object

GenerateResources() публичный Метод

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
Результат bool

GetAllLocaleIds() публичный Метод

Gets all the locales for a specific resource set. Returns a table named TLocaleIds (LocaleId field)
public GetAllLocaleIds ( string resourceSet ) : List
resourceSet string
Результат List

GetAllLocalesForResourceSet() публичный Метод

public GetAllLocalesForResourceSet ( string resourceSet ) : List
resourceSet string
Результат List

GetAllResourceIdListItems() публичный Метод

Returns a list with ResourceId and HasValues fields where the ResourceId is formatted for HTML display.
public GetAllResourceIdListItems ( string resourceSet ) : List
resourceSet string
Результат List

GetAllResourceIds() публичный Метод

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
Результат List

GetAllResourceSets() публичный Метод

Returns all available resource sets
public GetAllResourceSets ( ResourceListingTypes type ) : List
type ResourceListingTypes
Результат List

GetAllResources() публичный Метод

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
Результат List

GetAllResourcesForCulture() публичный Метод

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
Результат List

GetDb() публичный Метод

Creates an instance of the DataAccess Data provider
public GetDb ( string connectionString = null ) : DataAccessBase
connectionString string
Результат DataAccessBase

GetFileInfo() публичный статический Метод

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
Результат FileInfoFormat

GetResourceItem() публичный Метод

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
Результат Westwind.Globalization.ResourceItem

GetResourceItems() публичный Метод

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
Результат IEnumerable

GetResourceObject() публичный Метод

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
Результат object

GetResourceSet() публичный Метод

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
Результат IDictionary

GetResourceSetNormalizedForLocaleId() публичный Метод

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
Результат object>.Dictionary

GetResourceString() публичный Метод

Returns an individual Resource String from the database
public GetResourceString ( string resourceId, string resourceSet, string cultureName ) : string
resourceId string
resourceSet string
cultureName string
Результат string

GetResourceStrings() публичный Метод

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
Результат string>.Dictionary

GetResourcesAsJavascriptObject() публичный Метод

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
Результат string

IsLocalizationTable() публичный Метод

Checks to see if the LocalizationTable exists
public IsLocalizationTable ( string tableName = null ) : bool
tableName string Table name or the configuration.ResourceTableName if not passed
Результат bool

IsValidCulture() публичный Метод

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)
Результат bool

OnResourceSetValueConvert() защищенный Метод

protected OnResourceSetValueConvert ( object &resourceValue, string key, int valueType ) : void
resourceValue object
key string
valueType int
Результат void

RenameResource() публичный Метод

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
Результат bool

RenameResourceProperty() публичный Метод

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
Результат bool

RenameResourceSet() публичный Метод

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
Результат bool

ResourceExists() публичный Метод

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
Результат bool

RestoreBackupTable() публичный Метод

Restores the localization table from a backup table by first wiping out
public RestoreBackupTable ( string backupTableName ) : bool
backupTableName string
Результат bool

SerializeValue() защищенный Метод

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
Результат string

SetError() публичный Метод

public SetError ( ) : void
Результат void

SetError() публичный Метод

public SetError ( Exception ex ) : void
ex System.Exception
Результат void

SetError() публичный Метод

public SetError ( string message ) : void
message string
Результат void

SetFileDataOnResourceItem() публичный статический Метод

public static SetFileDataOnResourceItem ( Westwind.Globalization.ResourceItem item, byte data, string fileName ) : Westwind.Globalization.ResourceItem
item Westwind.Globalization.ResourceItem
data byte
fileName string
Результат Westwind.Globalization.ResourceItem

UpdateOrAddResource() публичный Метод

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
Результат int

UpdateOrAddResource() публичный Метод

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
Результат int

UpdateResource() публичный Метод

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
Результат int

UpdateResource() публичный Метод

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
Результат int