Class ResourceStore
Azure Cosmos DB resource store implementation. Manages persistence and retrieval of localization resources from the database.
Implements
Inherited Members
Namespace: DataWeb.Localization.AzureCosmosDB
Assembly: DataWeb.Data.AzureCosmosDB.dll
Syntax
public class ResourceStore : IResourceStore
Constructors
ResourceStore(ICosmosHelper, IConfigurationService, TimeProvider)
Azure Cosmos DB resource store implementation. Manages persistence and retrieval of localization resources from the database.
Declaration
public ResourceStore(ICosmosHelper cosmosHelper, IConfigurationService configurationService, TimeProvider timeProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| ICosmosHelper | cosmosHelper | |
| IConfigurationService | configurationService | |
| TimeProvider | timeProvider |
Properties
Name
Gets the name of the store implementation.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
ConvertStatusToString(ResourceStatus)
Converts a resource state to its string representation.
Declaration
public static string ConvertStatusToString(ResourceStatus status)
Parameters
| Type | Name | Description |
|---|---|---|
| ResourceStatus | status | Resource state. |
Returns
| Type | Description |
|---|---|
| string | String representation of the state. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | If status is not a valid value. |
ConvertStringToStatus(string)
Converts a string to the corresponding resource state.
Declaration
public ResourceStatus ConvertStringToStatus(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | String representing the state. Cannot be null. |
Returns
| Type | Description |
|---|---|
| ResourceStatus | Corresponding ResourceStatus. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If value is null. |
| ArgumentOutOfRangeException | If value does not correspond to any valid state. |
GetDictionariesAsync(ResourceFilter, CancellationToken)
Retrieves a list of resources in dictionary format.
Declaration
public Task<IEnumerable<Dictionary<string, object>>> GetDictionariesAsync(ResourceFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ResourceFilter | filter | Search filters. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<Dictionary<string, object>>> | List of dictionaries representing the resources. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
GetDictionaryAsync(ResourceFilter, CancellationToken)
Retrieves a single resource dictionary based on the specified filters.
Declaration
public Task<Dictionary<string, object>> GetDictionaryAsync(ResourceFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ResourceFilter | filter | Search filters. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<Dictionary<string, object>> | The resource dictionary, or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
GetResourceAsync(ResourceFilter, CancellationToken)
Retrieves a single resource based on the specified filters.
Declaration
public Task<Resource> GetResourceAsync(ResourceFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ResourceFilter | filter | Search filters. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<Resource> | The resource found, or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
GetResourceContextsAsync(CancellationToken)
Retrieves the list of all available resource contexts.
Declaration
public Task<IEnumerable<string>> GetResourceContextsAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<string>> | List of resource contexts. |
GetResourceCountAsync(ResourceFilter, CancellationToken)
Retrieves the total count of resources based on the specified filters.
Declaration
public Task<long> GetResourceCountAsync(ResourceFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ResourceFilter | filter | Search filters. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<long> | Number of resources found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
GetResourcesAsync(ResourceFilter, CancellationToken)
Retrieves a list of localization resources based on the specified filters.
Declaration
public Task<IEnumerable<Resource>> GetResourcesAsync(ResourceFilter filter, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| ResourceFilter | filter | Search filters. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<Resource>> | List of resources found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If filter is null. |
RemoveAsync(string, CancellationToken)
Marks a resource as deleted (soft delete).
Declaration
public Task RemoveAsync(string resourceId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | resourceId | ID of the resource to delete. Cannot be null or empty. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If resourceId is null or empty. |
SetAsync(Resource, CancellationToken)
Saves a resource (inserts if new, updates if existing).
Declaration
public Task SetAsync(Resource resource, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| Resource | resource | Resource to save. Cannot be null. |
| CancellationToken | cancellationToken | Token to cancel the asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | If resource is null. |