File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
src/JsonApiDotNetCore/Hooks/Discovery
test/UnitTests/ResourceHooks Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ public HooksDiscovery()
36
36
/// <returns>The implemented hooks for model.</returns>
37
37
void DiscoverImplementedHooksForModel ( )
38
38
{
39
- var derivedTypes = TypeLocator . GetDerivedTypes ( typeof ( TEntity ) . Assembly , typeof ( ResourceDefinition < TEntity > ) ) . ToList ( ) ;
39
+ Type parameterizedResourceDefinition = typeof ( ResourceDefinition < TEntity > ) ;
40
+ var derivedTypes = TypeLocator . GetDerivedTypes ( typeof ( TEntity ) . Assembly , parameterizedResourceDefinition ) . ToList ( ) ;
40
41
try
41
42
{
42
43
var implementedHooks = new List < ResourceHook > ( ) ;
@@ -48,7 +49,7 @@ void DiscoverImplementedHooksForModel()
48
49
foreach ( var hook in _allHooks )
49
50
{
50
51
var method = targetType . GetMethod ( hook . ToString ( "G" ) ) ;
51
- if ( method . DeclaringType == targetType )
52
+ if ( method . DeclaringType != parameterizedResourceDefinition )
52
53
{
53
54
implementedHooks . Add ( hook ) ;
54
55
if ( hook == ResourceHook . BeforeImplicitUpdateRelationship )
Original file line number Diff line number Diff line change @@ -34,14 +34,14 @@ public class AnotherDummy : Identifiable { }
34
34
public abstract class ResourceDefintionBase < T > : ResourceDefinition < T > where T : class , IIdentifiable
35
35
{
36
36
protected ResourceDefintionBase ( IResourceGraph graph ) : base ( graph ) { }
37
+
38
+ public override IEnumerable < T > BeforeDelete ( HashSet < T > entities , ResourcePipeline pipeline ) { return entities ; }
39
+ public override void AfterDelete ( HashSet < T > entities , ResourcePipeline pipeline , bool succeeded ) { }
37
40
}
38
41
39
42
public class AnotherDummyResourceDefinition : ResourceDefintionBase < AnotherDummy >
40
43
{
41
44
public AnotherDummyResourceDefinition ( ) : base ( new ResourceGraphBuilder ( ) . AddResource < Dummy > ( ) . Build ( ) ) { }
42
-
43
- public override IEnumerable < AnotherDummy > BeforeDelete ( HashSet < AnotherDummy > entities , ResourcePipeline pipeline ) { return entities ; }
44
- public override void AfterDelete ( HashSet < AnotherDummy > entities , ResourcePipeline pipeline , bool succeeded ) { }
45
45
}
46
46
[ Fact ]
47
47
public void Hook_Discovery_With_Inheritance ( )
You can’t perform that action at this time.
0 commit comments