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
TInfo
Type 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
decoratedProvider
IInfoProvider<TInfo>Provider instance being decorated.
Exceptions
- ArgumentNullException
Thrown when
decoratedProvider
is 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
where
IWhereConditionWhere condition filtering the objects to be deleted, or null.
settings
BulkDeleteSettingsConfiguration 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
objects
IEnumerable<TInfo>Enumerable of
TInfo
to be inserted.settings
BulkInsertSettingsConfiguration 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
objects
is 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
values
IEnumerable<KeyValuePair<string, object>>New values for the data as an enumeration of column names and their corresponding values.
where
IWhereConditionWhere condition filtering the objects to be updated, or null.
useApi
boolSpecifies whether to perform the update using the API, or using a DB query.
Exceptions
- ArgumentNullException
Thrown when
values
is 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
updateExpression
stringUpdate expression (e.g.
[Column] = [Column] * 2
or[Column] = @ParameterValue
).updateParameters
QueryDataParametersParameters for the update expression, or null.
where
IWhereConditionWhere 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
updateExpression
is 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
info
TInfoInfo 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
info
is 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
info
TInfoInfo object to be deleted.
cancellationToken
CancellationToken?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
info
is 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
TInfo
retrieval.
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
info
TInfoInfo 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
info
is 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
info
TInfoInfo object to be inserted or updated.
cancellationToken
CancellationToken?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
info
is null.