Class InfoProviderDecorator<TInfo>
- Namespace
- CMS.DataEngine
- Assembly
- CMS.DataEngine.dll
Base class for decoration of info providers with no generated provider class. The decorator implements allows for customizing the IInfoProvider<TInfo> and IBulkInfoProvider<TInfo> members while implementing other interfaces required for compatibility with the system.
The default member implementations directly call the decorated provider members.
public abstract class InfoProviderDecorator<TInfo> : IInfoProvider<TInfo>, IInfoByIdProvider<TInfo>, IInfoByGuidProvider<TInfo>, IInfoByNameProvider<TInfo>, IBulkInfoProvider<TInfo>, IInfoValidator<TInfo>, IInfoProvider, ICustomizableProvider, IBulkOperationProvider, IWebFarmProvider where TInfo : AbstractInfoBase<TInfo>, new()
Type Parameters
TInfoType of info object managed by the provider.
- Inheritance
-
objectInfoProviderDecorator<TInfo>
- Implements
-
IInfoProvider<TInfo>IInfoByIdProvider<TInfo>IInfoByGuidProvider<TInfo>IInfoByNameProvider<TInfo>IBulkInfoProvider<TInfo>IInfoValidator<TInfo>
- Extension Methods
Remarks
Inherit this class to customize info providers with no generated provider class and register them using the RegisterCustomProviderAttribute attribute.
Constructors
InfoProviderDecorator(IInfoProvider<TInfo>)
Initializes a new instance of the InfoProviderDecorator<TInfo> class.
protected InfoProviderDecorator(IInfoProvider<TInfo> decoratedProvider)
Parameters
decoratedProviderIInfoProvider<TInfo>Provider instance being decorated.
Exceptions
- ArgumentNullException
Thrown when
decoratedProvideris null.
Properties
DecoratedProvider
Gets the provider being decorated.
protected IInfoProvider<TInfo> DecoratedProvider { get; }
Property Value
- IInfoProvider<TInfo>
Methods
BulkDelete(IWhereCondition, BulkDeleteSettings)
Bulk deletes info objects based on the given condition by invoking BulkDelete(IWhereCondition, BulkDeleteSettings) on the decorated provider instance.
public virtual void BulkDelete(IWhereCondition where, BulkDeleteSettings settings = null)
Parameters
whereIWhereConditionWhere condition filtering the objects to be deleted, or null.
settingsBulkDeleteSettingsConfiguration for the bulk delete. If null, default configuration is used.
BulkInsert(IEnumerable<TInfo>, BulkInsertSettings)
Bulk inserts an enumerable of TInfo by invoking BulkInsert(IEnumerable<TInfo>, BulkInsertSettings) on the decorated provider instance.
Throws a System.NotSupportedException if the decorated provider does not support bulk operations.
public virtual void BulkInsert(IEnumerable<TInfo> objects, BulkInsertSettings settings = null)
Parameters
objectsIEnumerable<TInfo>Enumerable of
TInfoto be inserted.settingsBulkInsertSettingsConfiguration for the bulk insert, e.g. timeout. If null, default configuration is used.
Remarks
Info object ID is not set during the bulk insert operation.
Exceptions
- NotSupportedException
Thrown when the decorated provider does not implement IBulkInfoProvider<TInfo>.
- ArgumentNullException
Thrown when
objectsis null.
BulkUpdate(IEnumerable<KeyValuePair<string, object>>, IWhereCondition, bool)
Bulk updates info objects based on the given condition using the values provided by invoking BulkUpdate(IEnumerable<KeyValuePair<string, object>>, IWhereCondition, bool) on the decorated provider instance.
public virtual void BulkUpdate(IEnumerable<KeyValuePair<string, object>> values, IWhereCondition where, bool useApi = false)
Parameters
valuesIEnumerable<KeyValuePair<string, object>>New values for the data as an enumeration of column names and their corresponding values.
whereIWhereConditionWhere condition filtering the objects to be updated, or null.
useApiboolSpecifies whether to perform the update using the API, or using a DB query.
Exceptions
- ArgumentNullException
Thrown when
valuesis null.
BulkUpdate(string, QueryDataParameters, IWhereCondition)
Bulk updates info objects based on the given condition using the updateExpression provided by invoking BulkUpdate(string, QueryDataParameters, IWhereCondition) on the decorated provider instance.
public virtual void BulkUpdate(string updateExpression, QueryDataParameters updateParameters, IWhereCondition where)
Parameters
updateExpressionstringUpdate expression (e.g.
[Column] = [Column] * 2or[Column] = @ParameterValue).updateParametersQueryDataParametersParameters for the update expression, or null.
whereIWhereConditionWhere condition filtering the objects to be updated, or null.
Remarks
It is strongly recommended to use query data parameters for specifying values for the update expression to prevent possible vulnerabilities.
Exceptions
- ArgumentException
Thrown when
updateExpressionis null or empty.
Delete(TInfo)
Deletes the info object from the underlying data store by invoking Delete(TInfo) on the decorated provider instance.
public virtual void Delete(TInfo info)
Parameters
infoTInfoInfo object to be deleted.
Remarks
When decorating the delete operation, make sure to add corresponding code to the asynchronous DeleteAsync(TInfo, CancellationToken?).
Exceptions
- ArgumentNullException
Thrown when
infois null.
DeleteAsync(TInfo, CancellationToken?)
Asynchronously deletes the info object from the underlying data store by invoking DeleteAsync(TInfo, CancellationToken?) on the decorated provider instance.
public virtual Task DeleteAsync(TInfo info, CancellationToken? cancellationToken = null)
Parameters
infoTInfoInfo object to be deleted.
cancellationTokenCancellationToken?The cancellation instruction.
Returns
- Task
Remarks
When decorating the delete operation, make sure to add corresponding code to the synchronous Delete(TInfo).
Exceptions
- ArgumentNullException
Thrown when
infois null.
Get()
Gets the object query for TInfo retrieval by invoking Get() on the decorated provider instance.
public virtual ObjectQuery<TInfo> Get()
Returns
- ObjectQuery<TInfo>
Returns ObjectQuery<TObject> for
TInforetrieval.
Set(TInfo)
Inserts or updates the info object in the underlying data store by invoking Set(TInfo) on the decorated provider instance.
public virtual void Set(TInfo info)
Parameters
infoTInfoInfo object to be inserted or updated.
Remarks
When decorating the set operation, make sure to add corresponding code to the asynchronous SetAsync(TInfo, CancellationToken?).
Exceptions
- ArgumentNullException
Thrown when
infois null.
SetAsync(TInfo, CancellationToken?)
Asynchronously inserts or updates the info object in the underlying data store by invoking SetAsync(TInfo, CancellationToken?) on the decorated provider instance.
public virtual Task SetAsync(TInfo info, CancellationToken? cancellationToken = null)
Parameters
infoTInfoInfo object to be inserted or updated.
cancellationTokenCancellationToken?The cancellation instruction.
Returns
- Task
Remarks
When decorating the set operation, make sure to add corresponding code to the synchronous Set(TInfo).
Exceptions
- ArgumentNullException
Thrown when
infois null.