@@ -26,7 +26,7 @@ public ResourceRepositoryAccessor(IServiceProvider serviceProvider, IResourceCon
2626 public async Task < IReadOnlyCollection < TResource > > GetAsync < TResource > ( QueryLayer layer , CancellationToken cancellationToken )
2727 where TResource : class , IIdentifiable
2828 {
29- dynamic repository = GetReadRepository ( typeof ( TResource ) ) ;
29+ dynamic repository = ResolveReadRepository ( typeof ( TResource ) ) ;
3030 return ( IReadOnlyCollection < TResource > ) await repository . GetAsync ( layer , cancellationToken ) ;
3131 }
3232
@@ -35,83 +35,83 @@ public async Task<IReadOnlyCollection<IIdentifiable>> GetAsync(Type resourceType
3535 {
3636 if ( resourceType == null ) throw new ArgumentNullException ( nameof ( resourceType ) ) ;
3737
38- dynamic repository = GetReadRepository ( resourceType ) ;
38+ dynamic repository = ResolveReadRepository ( resourceType ) ;
3939 return ( IReadOnlyCollection < IIdentifiable > ) await repository . GetAsync ( layer , cancellationToken ) ;
4040 }
4141
4242 /// <inheritdoc />
4343 public async Task < int > CountAsync < TResource > ( FilterExpression topFilter , CancellationToken cancellationToken )
4444 where TResource : class , IIdentifiable
4545 {
46- dynamic repository = GetReadRepository ( typeof ( TResource ) ) ;
46+ dynamic repository = ResolveReadRepository ( typeof ( TResource ) ) ;
4747 return ( int ) await repository . CountAsync ( topFilter , cancellationToken ) ;
4848 }
4949
5050 /// <inheritdoc />
5151 public async Task < TResource > GetForCreateAsync < TResource , TId > ( TId id , CancellationToken cancellationToken )
5252 where TResource : class , IIdentifiable < TId >
5353 {
54- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
54+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
5555 return await repository . GetForCreateAsync ( id , cancellationToken ) ;
5656 }
5757
5858 /// <inheritdoc />
5959 public async Task CreateAsync < TResource > ( TResource resourceFromRequest , TResource resourceForDatabase , CancellationToken cancellationToken )
6060 where TResource : class , IIdentifiable
6161 {
62- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
62+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
6363 await repository . CreateAsync ( resourceFromRequest , resourceForDatabase , cancellationToken ) ;
6464 }
6565
6666 /// <inheritdoc />
6767 public async Task < TResource > GetForUpdateAsync < TResource > ( QueryLayer queryLayer , CancellationToken cancellationToken )
6868 where TResource : class , IIdentifiable
6969 {
70- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
70+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
7171 return await repository . GetForUpdateAsync ( queryLayer , cancellationToken ) ;
7272 }
7373
7474 /// <inheritdoc />
7575 public async Task UpdateAsync < TResource > ( TResource resourceFromRequest , TResource resourceFromDatabase , CancellationToken cancellationToken )
7676 where TResource : class , IIdentifiable
7777 {
78- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
78+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
7979 await repository . UpdateAsync ( resourceFromRequest , resourceFromDatabase , cancellationToken ) ;
8080 }
8181
8282 /// <inheritdoc />
8383 public async Task DeleteAsync < TResource , TId > ( TId id , CancellationToken cancellationToken )
8484 where TResource : class , IIdentifiable < TId >
8585 {
86- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
86+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
8787 await repository . DeleteAsync ( id , cancellationToken ) ;
8888 }
8989
9090 /// <inheritdoc />
9191 public async Task SetRelationshipAsync < TResource > ( TResource primaryResource , object secondaryResourceIds , CancellationToken cancellationToken )
9292 where TResource : class , IIdentifiable
9393 {
94- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
94+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
9595 await repository . SetRelationshipAsync ( primaryResource , secondaryResourceIds , cancellationToken ) ;
9696 }
9797
9898 /// <inheritdoc />
9999 public async Task AddToToManyRelationshipAsync < TResource , TId > ( TId primaryId , ISet < IIdentifiable > secondaryResourceIds , CancellationToken cancellationToken )
100100 where TResource : class , IIdentifiable < TId >
101101 {
102- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
102+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
103103 await repository . AddToToManyRelationshipAsync ( primaryId , secondaryResourceIds , cancellationToken ) ;
104104 }
105105
106106 /// <inheritdoc />
107107 public async Task RemoveFromToManyRelationshipAsync < TResource > ( TResource primaryResource , ISet < IIdentifiable > secondaryResourceIds , CancellationToken cancellationToken )
108108 where TResource : class , IIdentifiable
109109 {
110- dynamic repository = GetWriteRepository ( typeof ( TResource ) ) ;
110+ dynamic repository = ResolveWriteRepository ( typeof ( TResource ) ) ;
111111 await repository . RemoveFromToManyRelationshipAsync ( primaryResource , secondaryResourceIds , cancellationToken ) ;
112112 }
113113
114- protected object GetReadRepository ( Type resourceType )
114+ protected virtual object ResolveReadRepository ( Type resourceType )
115115 {
116116 var resourceContext = _resourceContextProvider . GetResourceContext ( resourceType ) ;
117117
@@ -130,7 +130,7 @@ protected object GetReadRepository(Type resourceType)
130130 return _serviceProvider . GetRequiredService ( resourceDefinitionType ) ;
131131 }
132132
133- protected object GetWriteRepository ( Type resourceType )
133+ protected virtual object ResolveWriteRepository ( Type resourceType )
134134 {
135135 var resourceContext = _resourceContextProvider . GetResourceContext ( resourceType ) ;
136136
0 commit comments