@@ -12,12 +12,39 @@ public interface IResourceHookContainer { }
12
12
/// <summary>
13
13
/// Implement this interface to implement business logic hooks on <see cref="ResourceDefinition{T}"/>.
14
14
/// </summary>
15
- public interface IResourceHookContainer < TResource > : IBeforeHooks < TResource > , IAfterHooks < TResource > , IOnHooks < TResource > , IResourceHookContainer where TResource : class , IIdentifiable { }
15
+ public interface IResourceHookContainer < TResource >
16
+ : IReadHookContainer < TResource > , IDeleteHookContainer < TResource > , ICreateHookContainer < TResource > ,
17
+ IUpdateHookContainer < TResource > , IOnReturnHookContainer < TResource > , IResourceHookContainer
18
+ where TResource : class , IIdentifiable { }
16
19
17
20
/// <summary>
18
- /// Wrapper interface for all Before hooks.
21
+ /// Read hooks container
19
22
/// </summary>
20
- public interface IBeforeHooks < TResource > where TResource : class , IIdentifiable
23
+ public interface IReadHookContainer < TResource > where TResource : class , IIdentifiable
24
+ {
25
+ /// <summary>
26
+ /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
27
+ /// layer just before reading entities of type <typeparamref name="TResource"/>.
28
+ /// </summary>
29
+ /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
30
+ /// <param name="isIncluded">Indicates whether the to be queried entities are the main request entities or if they were included</param>
31
+ /// <param name="stringId">The string id of the requested entity, in the case of <see cref="ResourcePipeline.GetSingle"/></param>
32
+ void BeforeRead ( ResourcePipeline pipeline , bool isIncluded = false , string stringId = null ) ;
33
+ /// <summary>
34
+ /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
35
+ /// layer just after reading entities of type <typeparamref name="TResource"/>.
36
+ /// </summary>
37
+ /// <param name="entities">The unique set of affected entities.</param>
38
+ /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
39
+ /// <param name="isIncluded">A boolean to indicate whether the entities in this hook execution are the main entities of the request,
40
+ /// or if they were included as a relationship</param>
41
+ void AfterRead ( HashSet < TResource > entities , ResourcePipeline pipeline , bool isIncluded = false ) ;
42
+ }
43
+
44
+ /// <summary>
45
+ /// Create hooks container
46
+ /// </summary>
47
+ public interface ICreateHookContainer < TResource > where TResource : class , IIdentifiable
21
48
{
22
49
/// <summary>
23
50
/// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
@@ -40,14 +67,27 @@ public interface IBeforeHooks<TResource> where TResource : class, IIdentifiable
40
67
/// <param name="entities">The unique set of affected entities.</param>
41
68
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
42
69
IEnumerable < TResource > BeforeCreate ( IEntityHashSet < TResource > entities , ResourcePipeline pipeline ) ;
70
+
43
71
/// <summary>
44
72
/// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
45
- /// layer just before reading entities of type <typeparamref name="TResource"/>.
73
+ /// layer just after creation of entities of type <typeparamref name="TResource"/>.
74
+ /// <para />
75
+ /// If relationships were created with the created entities, this will
76
+ /// be reflected by the corresponding NavigationProperty being set.
77
+ /// For each of these relationships, the <see cref="ResourceDefinition{T}.AfterUpdateRelationship(IRelationshipsDictionary{T}, ResourcePipeline)"/>
78
+ /// hook is fired after the execution of this hook.
46
79
/// </summary>
80
+ /// <returns>The transformed entity set</returns>
81
+ /// <param name="entities">The unique set of affected entities.</param>
47
82
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
48
- /// <param name="isIncluded">Indicates whether the to be queried entities are the main request entities or if they were included</param>
49
- /// <param name="stringId">The string id of the requested entity, in the case of <see cref="ResourcePipeline.GetSingle"/></param>
50
- void BeforeRead ( ResourcePipeline pipeline , bool isIncluded = false , string stringId = null ) ;
83
+ void AfterCreate ( HashSet < TResource > entities , ResourcePipeline pipeline ) ;
84
+ }
85
+
86
+ /// <summary>
87
+ /// update hooks container
88
+ /// </summary>
89
+ public interface IUpdateHookContainer < TResource > where TResource : class , IIdentifiable
90
+ {
51
91
/// <summary>
52
92
/// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
53
93
/// layer just before updating entities of type <typeparamref name="TResource"/>.
@@ -76,26 +116,6 @@ public interface IBeforeHooks<TResource> where TResource : class, IIdentifiable
76
116
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
77
117
IEnumerable < TResource > BeforeUpdate ( IDiffableEntityHashSet < TResource > entities , ResourcePipeline pipeline ) ;
78
118
79
- /// <summary>
80
- /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
81
- /// layer just before deleting entities of type <typeparamref name="TResource"/>.
82
- /// <para />
83
- /// For the <see cref="ResourcePipeline.Delete"/> pipeline,
84
- /// <paramref name="entities" /> will typically contain one entity.
85
- /// <para />
86
- /// The returned <see cref="IEnumerable{TResource}"/> may be a subset
87
- /// of <paramref name="entities"/>, in which case the operation of the
88
- /// pipeline will not be executed for the omitted entities.
89
- /// <para />
90
- /// If by the deletion of these entities any other entities are affected
91
- /// implicitly by the removal of their relationships (eg
92
- /// in the case of an one-to-one relationship), the <see cref="ResourceDefinition{T}.BeforeImplicitUpdateRelationship"/>
93
- /// hook is fired for these entities.
94
- /// </summary>
95
- /// <returns>The transformed entity set</returns>
96
- /// <param name="entities">The unique set of affected entities.</param>
97
- /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
98
- IEnumerable < TResource > BeforeDelete ( IEntityHashSet < TResource > entities , ResourcePipeline pipeline ) ;
99
119
/// <summary>
100
120
/// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
101
121
/// layer just before updating relationships to entities of type <typeparamref name="TResource"/>.
@@ -116,6 +136,28 @@ public interface IBeforeHooks<TResource> where TResource : class, IIdentifiable
116
136
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
117
137
/// <param name="entitiesByRelationship">A helper that groups the entities by the affected relationship</param>
118
138
IEnumerable < string > BeforeUpdateRelationship ( HashSet < string > ids , IRelationshipsDictionary < TResource > entitiesByRelationship , ResourcePipeline pipeline ) ;
139
+
140
+ /// <summary>
141
+ /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
142
+ /// layer just after updating entities of type <typeparamref name="TResource"/>.
143
+ /// <para />
144
+ /// If relationships were updated with the updated entities, this will
145
+ /// be reflected by the corresponding NavigationProperty being set.
146
+ /// For each of these relationships, the <see cref="ResourceDefinition{T}.AfterUpdateRelationship(IRelationshipsDictionary{T}, ResourcePipeline"/>
147
+ /// hook is fired after the execution of this hook.
148
+ /// </summary>
149
+ /// <param name="entities">The unique set of affected entities.</param>
150
+ /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
151
+ void AfterUpdate ( HashSet < TResource > entities , ResourcePipeline pipeline ) ;
152
+
153
+ /// <summary>
154
+ /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/> layer
155
+ /// just after a relationship was updated.
156
+ /// </summary>
157
+ /// <param name="entitiesByRelationship">Relationship helper.</param>
158
+ /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
159
+ void AfterUpdateRelationship ( IRelationshipsDictionary < TResource > entitiesByRelationship , ResourcePipeline pipeline ) ;
160
+
119
161
/// <summary>
120
162
/// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
121
163
/// layer just before implicitly updating relationships to entities of type <typeparamref name="TResource"/>.
@@ -138,44 +180,31 @@ public interface IBeforeHooks<TResource> where TResource : class, IIdentifiable
138
180
}
139
181
140
182
/// <summary>
141
- /// Wrapper interface for all After hooks.
183
+ /// Delete hooks container
142
184
/// </summary>
143
- public interface IAfterHooks < TResource > where TResource : class , IIdentifiable
185
+ public interface IDeleteHookContainer < TResource > where TResource : class , IIdentifiable
144
186
{
145
187
/// <summary>
146
188
/// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
147
- /// layer just after creation of entities of type <typeparamref name="TResource"/>.
189
+ /// layer just before deleting entities of type <typeparamref name="TResource"/>.
148
190
/// <para />
149
- /// If relationships were created with the created entities, this will
150
- /// be reflected by the corresponding NavigationProperty being set.
151
- /// For each of these relationships, the <see cref="ResourceDefinition{T}.AfterUpdateRelationship(IRelationshipsDictionary{T}, ResourcePipeline)"/>
152
- /// hook is fired after the execution of this hook.
153
- /// </summary>
154
- /// <returns>The transformed entity set</returns>
155
- /// <param name="entities">The unique set of affected entities.</param>
156
- /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
157
- void AfterCreate ( HashSet < TResource > entities , ResourcePipeline pipeline ) ;
158
- /// <summary>
159
- /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
160
- /// layer just after reading entities of type <typeparamref name="TResource"/>.
161
- /// </summary>
162
- /// <param name="entities">The unique set of affected entities.</param>
163
- /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
164
- /// <param name="isIncluded">A boolean to indicate whether the entities in this hook execution are the main entities of the request,
165
- /// or if they were included as a relationship</param>
166
- void AfterRead ( HashSet < TResource > entities , ResourcePipeline pipeline , bool isIncluded = false ) ;
167
- /// <summary>
168
- /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
169
- /// layer just after updating entities of type <typeparamref name="TResource"/>.
191
+ /// For the <see cref="ResourcePipeline.Delete"/> pipeline,
192
+ /// <paramref name="entities" /> will typically contain one entity.
170
193
/// <para />
171
- /// If relationships were updated with the updated entities, this will
172
- /// be reflected by the corresponding NavigationProperty being set.
173
- /// For each of these relationships, the <see cref="ResourceDefinition{T}.AfterUpdateRelationship(IRelationshipsDictionary{T}, ResourcePipeline"/>
174
- /// hook is fired after the execution of this hook.
194
+ /// The returned <see cref="IEnumerable{TResource}"/> may be a subset
195
+ /// of <paramref name="entities"/>, in which case the operation of the
196
+ /// pipeline will not be executed for the omitted entities.
197
+ /// <para />
198
+ /// If by the deletion of these entities any other entities are affected
199
+ /// implicitly by the removal of their relationships (eg
200
+ /// in the case of an one-to-one relationship), the <see cref="ResourceDefinition{T}.BeforeImplicitUpdateRelationship"/>
201
+ /// hook is fired for these entities.
175
202
/// </summary>
203
+ /// <returns>The transformed entity set</returns>
176
204
/// <param name="entities">The unique set of affected entities.</param>
177
205
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
178
- void AfterUpdate ( HashSet < TResource > entities , ResourcePipeline pipeline ) ;
206
+ IEnumerable < TResource > BeforeDelete ( IEntityHashSet < TResource > entities , ResourcePipeline pipeline ) ;
207
+
179
208
/// <summary>
180
209
/// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/>
181
210
/// layer just after deletion of entities of type <typeparamref name="TResource"/>.
@@ -184,19 +213,12 @@ public interface IAfterHooks<TResource> where TResource : class, IIdentifiable
184
213
/// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
185
214
/// <param name="succeeded">If set to <c>true</c> if the deletion was succeeded in the repository layer.</param>
186
215
void AfterDelete ( HashSet < TResource > entities , ResourcePipeline pipeline , bool succeeded ) ;
187
- /// <summary>
188
- /// Implement this hook to run custom logic in the <see cref=" DefaultResourceService{T}"/> layer
189
- /// just after a relationship was updated.
190
- /// </summary>
191
- /// <param name="entitiesByRelationship">Relationship helper.</param>
192
- /// <param name="pipeline">An enum indicating from where the hook was triggered.</param>
193
- void AfterUpdateRelationship ( IRelationshipsDictionary < TResource > entitiesByRelationship , ResourcePipeline pipeline ) ;
194
216
}
195
217
196
218
/// <summary>
197
- /// Wrapper interface for all on hooks.
219
+ /// On return hook container
198
220
/// </summary>
199
- public interface IOnHooks < TResource > where TResource : class , IIdentifiable
221
+ public interface IOnReturnHookContainer < TResource > where TResource : class , IIdentifiable
200
222
{
201
223
/// <summary>
202
224
/// Implement this hook to transform the result data just before returning
0 commit comments