Skip to content

Commit 52c43a0

Browse files
Merge pull request #358 from mikhail-syvachenko-syzygy/feature/allow-decorator-update-delete
feat: add methods for deleting and removing registered decorators for commands and queries for greater flexibility when managing external dependencies
2 parents 5cc4156 + ef8c0c5 commit 52c43a0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

common/src/DbLocalizationProvider/SetHandlerExpression.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,21 @@ public void DecorateWith<TDecorator>()
6767
{
6868
_decoratorMappings.GetOrAdd(typeof(T), typeof(TDecorator));
6969
}
70+
71+
/// <summary>
72+
/// Adds or replaces the decorator with the specified type for command or query.
73+
/// </summary>
74+
/// <typeparam name="TDecorator">The type of the decorator.</typeparam>
75+
public void AddOrReplaceDecorator<TDecorator>()
76+
{
77+
_decoratorMappings.AddOrUpdate(typeof(T), typeof(TDecorator), (_, _) => typeof(TDecorator));
78+
}
79+
80+
/// <summary>
81+
/// Removes the decorator for the specified command or query.
82+
/// </summary>
83+
public void RemoveDecorator()
84+
{
85+
_decoratorMappings.TryRemove(typeof(T), out _);
86+
}
7087
}

0 commit comments

Comments
 (0)