@@ -12,106 +12,106 @@ namespace JsonApiDotNetCore.Hooks
1212 /// Contains the resources from the request and the corresponding database values.
1313 ///
1414 /// Also contains information about updated relationships through
15- /// implementation of IRelationshipsDictionary<typeparamref name="TResource "/>>
15+ /// implementation of IRelationshipsDictionary<typeparamref name="TEntity "/>>
1616 /// </summary>
17- public interface IResourceDiffs < TResource > : IRelationshipsDictionary < TResource > , IEnumerable < ResourceDiffPair < TResource > > where TResource : class , IIdentifiable
17+ public interface IEntityDiff < TEntity > : IRelationshipsDictionary < TEntity > , IEnumerable < EntityDiffPair < TEntity > > where TEntity : class , IIdentifiable
1818 {
1919 /// <summary>
2020 /// The database values of the resources affected by the request.
2121 /// </summary>
22- HashSet < TResource > DatabaseValues { get ; }
22+ HashSet < TEntity > DatabaseValues { get ; }
2323
2424 /// <summary>
2525 /// The resources that were affected by the request.
2626 /// </summary>
27- HashSet < TResource > Resources { get ; }
27+ HashSet < TEntity > Entities { get ; }
2828 }
2929
3030 /// <inheritdoc />
31- public class ResourceDiffs < TResource > : IResourceDiffs < TResource > where TResource : class , IIdentifiable
31+ public class EntityDiffs < TEntity > : IEntityDiff < TEntity > where TEntity : class , IIdentifiable
3232 {
3333 /// <inheritdoc />
34- public HashSet < TResource > DatabaseValues { get => _databaseValues ?? ThrowNoDbValuesError ( ) ; }
35- private readonly HashSet < TResource > _databaseValues ;
34+ public HashSet < TEntity > DatabaseValues { get => _databaseValues ?? ThrowNoDbValuesError ( ) ; }
35+ private readonly HashSet < TEntity > _databaseValues ;
3636 private readonly bool _databaseValuesLoaded ;
3737
3838 /// <inheritdoc />
39- public HashSet < TResource > Resources { get ; private set ; }
39+ public HashSet < TEntity > Entities { get ; private set ; }
4040 /// <inheritdoc />
41- public RelationshipsDictionary < TResource > AffectedRelationships { get ; private set ; }
41+ public RelationshipsDictionary < TEntity > AffectedRelationships { get ; private set ; }
4242
43- public ResourceDiffs ( HashSet < TResource > requestEntities ,
44- HashSet < TResource > databaseEntities ,
45- Dictionary < RelationshipAttribute , HashSet < TResource > > relationships )
43+ public EntityDiffs ( HashSet < TEntity > requestEntities ,
44+ HashSet < TEntity > databaseEntities ,
45+ Dictionary < RelationshipAttribute , HashSet < TEntity > > relationships )
4646 {
47- Resources = requestEntities ;
48- AffectedRelationships = new RelationshipsDictionary < TResource > ( relationships ) ;
47+ Entities = requestEntities ;
48+ AffectedRelationships = new RelationshipsDictionary < TEntity > ( relationships ) ;
4949 _databaseValues = databaseEntities ;
5050 _databaseValuesLoaded |= _databaseValues != null ;
5151 }
5252
5353 /// <summary>
5454 /// Used internally by the ResourceHookExecutor to make live a bit easier with generics
5555 /// </summary>
56- internal ResourceDiffs ( IEnumerable requestEntities ,
56+ internal EntityDiffs ( IEnumerable requestEntities ,
5757 IEnumerable databaseEntities ,
5858 Dictionary < RelationshipAttribute , IEnumerable > relationships )
59- : this ( ( HashSet < TResource > ) requestEntities , ( HashSet < TResource > ) databaseEntities , TypeHelper . ConvertRelationshipDictionary < TResource > ( relationships ) ) { }
59+ : this ( ( HashSet < TEntity > ) requestEntities , ( HashSet < TEntity > ) databaseEntities , TypeHelper . ConvertRelationshipDictionary < TEntity > ( relationships ) ) { }
6060
6161
6262 /// <inheritdoc />
63- public Dictionary < RelationshipAttribute , HashSet < TResource > > GetByRelationship < TPrincipalResource > ( ) where TPrincipalResource : class , IIdentifiable
63+ public Dictionary < RelationshipAttribute , HashSet < TEntity > > GetByRelationship < TPrincipalResource > ( ) where TPrincipalResource : class , IIdentifiable
6464 {
6565 return GetByRelationship ( typeof ( TPrincipalResource ) ) ;
6666 }
6767
6868 /// <inheritdoc />
69- public Dictionary < RelationshipAttribute , HashSet < TResource > > GetByRelationship ( Type principalType )
69+ public Dictionary < RelationshipAttribute , HashSet < TEntity > > GetByRelationship ( Type principalType )
7070 {
7171 return AffectedRelationships . GetByRelationship ( principalType ) ;
7272 }
7373
7474 /// <inheritdoc />
75- public IEnumerator < ResourceDiffPair < TResource > > GetEnumerator ( )
75+ public IEnumerator < EntityDiffPair < TEntity > > GetEnumerator ( )
7676 {
7777 if ( ! _databaseValuesLoaded ) ThrowNoDbValuesError ( ) ;
7878
79- foreach ( var entity in Resources )
79+ foreach ( var entity in Entities )
8080 {
81- TResource currentValueInDatabase = null ;
81+ TEntity currentValueInDatabase = null ;
8282 currentValueInDatabase = _databaseValues . Single ( e => entity . StringId == e . StringId ) ;
83- yield return new ResourceDiffPair < TResource > ( entity , currentValueInDatabase ) ;
83+ yield return new EntityDiffPair < TEntity > ( entity , currentValueInDatabase ) ;
8484 }
8585 }
8686
8787 /// <inheritdoc />
8888 IEnumerator IEnumerable . GetEnumerator ( ) => GetEnumerator ( ) ;
8989
90- private HashSet < TResource > ThrowNoDbValuesError ( )
90+ private HashSet < TEntity > ThrowNoDbValuesError ( )
9191 {
9292 throw new MemberAccessException ( "Cannot access database entities if the LoadDatabaseValues option is set to false" ) ;
9393 }
9494 }
9595
9696 /// <summary>
97- /// A wrapper that contains an resource that is affected by the request,
97+ /// A wrapper that contains an entity that is affected by the request,
9898 /// matched to its current database value
9999 /// </summary>
100- public class ResourceDiffPair < TResource > where TResource : class , IIdentifiable
100+ public class EntityDiffPair < TEntity > where TEntity : class , IIdentifiable
101101 {
102- public ResourceDiffPair ( TResource resource , TResource databaseValue )
102+ public EntityDiffPair ( TEntity entity , TEntity databaseValue )
103103 {
104- Resource = resource ;
104+ Entity = entity ;
105105 DatabaseValue = databaseValue ;
106106 }
107107
108108 /// <summary>
109109 /// The resource from the request matching the resource from the database.
110110 /// </summary>
111- public TResource Resource { get ; private set ; }
111+ public TEntity Entity { get ; private set ; }
112112 /// <summary>
113113 /// The resource from the database matching the resource from the request.
114114 /// </summary>
115- public TResource DatabaseValue { get ; private set ; }
115+ public TEntity DatabaseValue { get ; private set ; }
116116 }
117117}
0 commit comments