Skip to content

Commit 9ab7b35

Browse files
committed
chore: renamed type parameters for consistency
1 parent e665173 commit 9ab7b35

17 files changed

+127
-140
lines changed

JsonApiDotnetCore.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{7A2B7ADD-ECB
1010
EndProject
1111
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{24B15015-62E5-42E1-9BA0-ECE6BE7AA15F}"
1212
EndProject
13-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCoreExampleTests", "test\JsonApiDotNetCoreExampleTests\JsonApiDotNetCoreExampleTests.csproj", "{0B959765-40D2-43B5-87EE-FE2FEF9DBED5}"
13+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonApiDotNetCoreExampleTests", "test\JsonApiDotNetCoreExampleTests\JsonApiDotNetCoreExampleTests.csproj", "{0B959765-40D2-43B5-87EE-FE2FEF9DBED5}"
1414
EndProject
1515
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C5B4D998-CECB-454D-9F32-085A897577BE}"
1616
ProjectSection(SolutionItems) = preProject

src/Examples/JsonApiDotNetCoreExample/Resources/TagResource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public TagResource(IResourceGraph graph) : base(graph)
1313
{
1414
}
1515

16-
public override IEnumerable<Tag> BeforeCreate(IResourceHashSet<Tag> affected, ResourcePipeline pipeline)
16+
public override IEnumerable<Tag> BeforeCreate(IEntityHashSet<Tag> affected, ResourcePipeline pipeline)
1717
{
1818
return base.BeforeCreate(affected, pipeline);
1919
}

src/JsonApiDotNetCore/Hooks/Execution/ResourceDiffs.cs renamed to src/JsonApiDotNetCore/Hooks/Execution/EntityDiffs.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/JsonApiDotNetCore/Hooks/Execution/ResourceHashSet.cs renamed to src/JsonApiDotNetCore/Hooks/Execution/EntityHashSet.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System.Collections.Generic;
22
using JsonApiDotNetCore.Models;
3-
using System.Linq;
43
using System.Collections;
54
using JsonApiDotNetCore.Internal;
65
using System;
@@ -13,10 +12,7 @@ namespace JsonApiDotNetCore.Hooks
1312
/// Also contains information about updated relationships through
1413
/// implementation of IAffectedRelationshipsDictionary<typeparamref name="TResource"/>>
1514
/// </summary>
16-
public interface IResourceHashSet<TResource> : IRelationshipsDictionary<TResource>, IEnumerable<TResource> where TResource : class, IIdentifiable
17-
{
18-
19-
}
15+
public interface IEntityHashSet<TResource> : IRelationshipsDictionary<TResource>, IEnumerable<TResource> where TResource : class, IIdentifiable { }
2016

2117
/// <summary>
2218
/// Implementation of IResourceHashSet{TResource}.
@@ -26,12 +22,12 @@ public interface IResourceHashSet<TResource> : IRelationshipsDictionary<TResourc
2622
/// Also contains information about updated relationships through
2723
/// implementation of IRelationshipsDictionary<typeparamref name="TResource"/>>
2824
/// </summary>
29-
public class ResourceHashSet<TResource> : HashSet<TResource>, IResourceHashSet<TResource> where TResource : class, IIdentifiable
25+
public class EntityHashSet<TResource> : HashSet<TResource>, IEntityHashSet<TResource> where TResource : class, IIdentifiable
3026
{
3127
/// <inheritdoc />
3228
public RelationshipsDictionary<TResource> AffectedRelationships { get; private set; }
3329

34-
public ResourceHashSet(HashSet<TResource> entities,
30+
public EntityHashSet(HashSet<TResource> entities,
3531
Dictionary<RelationshipAttribute, HashSet<TResource>> relationships) : base(entities)
3632
{
3733
AffectedRelationships = new RelationshipsDictionary<TResource>(relationships);
@@ -40,7 +36,7 @@ public ResourceHashSet(HashSet<TResource> entities,
4036
/// <summary>
4137
/// Used internally by the ResourceHookExecutor to make live a bit easier with generics
4238
/// </summary>
43-
internal ResourceHashSet(IEnumerable entities,
39+
internal EntityHashSet(IEnumerable entities,
4440
Dictionary<RelationshipAttribute, IEnumerable> relationships)
4541
: this((HashSet<TResource>)entities, TypeHelper.ConvertRelationshipDictionary<TResource>(relationships)) { }
4642

0 commit comments

Comments
 (0)