Skip to content

Commit b64feac

Browse files
committed
comments: documentation in code
1 parent 912bc2c commit b64feac

14 files changed

+272
-93
lines changed

src/JsonApiDotNetCore/Hooks/Discovery/IncludeDatabaseValues.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
namespace JsonApiDotNetCore.Hooks.Discovery
2+
namespace JsonApiDotNetCore.Hooks
33
{
44
public class IncludeDatabaseValues : Attribute
55
{

src/JsonApiDotNetCore/Hooks/Execution/EntityDiff.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
using System;
1+

22
using System.Collections;
33
using System.Collections.Generic;
4-
using JsonApiDotNetCore.Internal;
54
using JsonApiDotNetCore.Models;
65

76
namespace JsonApiDotNetCore.Hooks
87
{
8+
/// <summary>
9+
/// A helper class that provides insight in what is to be updated. The
10+
/// <see cref="IEntityDiff{TEntity}.RequestEntities"/> property reflects what was parsed from the incoming request,
11+
/// where the <see cref="IEntityDiff{TEntity}.DatabaseEntities"/> reflects what is the current state in the database.
12+
///
13+
/// Any relationships that are updated can be retrieved via the methods implemented on
14+
/// <see cref="IUpdatedRelationshipHelper{TDependent}"/>.
15+
/// </summary>
916
public interface IEntityDiff<TEntity> : IUpdatedRelationshipHelper<TEntity> where TEntity : class, IIdentifiable
1017
{
1118
HashSet<TEntity> RequestEntities { get; }

src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
using Microsoft.EntityFrameworkCore;
1414
using JsonApiDotNetCore.Services;
1515

16-
namespace JsonApiDotNetCore.Internal
16+
namespace JsonApiDotNetCore.Hooks
1717
{
1818
/// <inheritdoc/>
1919
internal class HookExecutorHelper : IHookExecutorHelper

src/JsonApiDotNetCore/Hooks/Execution/IHookExecutorHelper.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using JsonApiDotNetCore.Models;
5-
using JsonApiDotNetCore.Hooks;
65

7-
namespace JsonApiDotNetCore.Internal
6+
namespace JsonApiDotNetCore.Hooks
87
{
98
/// <summary>
10-
/// A helper class that retrieves all metadata required for the hook
11-
/// executor to call resource hooks. It gets RelationshipAttributes,
12-
/// ResourceHookContainers and figures out wether hooks are actually implemented.
9+
/// A helper class for retrieving meta data about hooks,
10+
/// fetching database values and performing other recurring internal operations.
11+
///
12+
/// Used internalyl by <see cref="ResourceHookExecutor"/>
1313
/// </summary>
1414
internal interface IHookExecutorHelper
1515
{
@@ -21,10 +21,8 @@ internal interface IHookExecutorHelper
2121
/// Also caches the retrieves containers so we don't need to reflectively
2222
/// instantiate them multiple times.
2323
/// </summary>
24-
/// <returns>The resource definition.</returns>
25-
/// <param name="targetEntity">Target entity type</param>
26-
/// <param name="hook">The hook to get a ResourceDefinition for.</param>
2724
IResourceHookContainer GetResourceHookContainer(Type targetEntity, ResourceHook hook = ResourceHook.None);
25+
2826
/// <summary>
2927
/// For a particular ResourceHook and for a given model type, checks if
3028
/// the ResourceDefinition has an implementation for the hook
@@ -33,13 +31,17 @@ internal interface IHookExecutorHelper
3331
/// Also caches the retrieves containers so we don't need to reflectively
3432
/// instantiate them multiple times.
3533
/// </summary>
36-
/// <returns>The resource definition.</returns>
37-
/// <typeparam name="TEntity">Target entity type</typeparam>
38-
/// <param name="hook">The hook to get a ResourceDefinition for.</param>
3934
IResourceHookContainer<TEntity> GetResourceHookContainer<TEntity>(ResourceHook hook = ResourceHook.None) where TEntity : class, IIdentifiable;
4035

36+
/// <summary>
37+
/// Load the implicitly affected entities from the database for a given set of target target entities and involved relationships
38+
/// </summary>
39+
/// <returns>The implicitly affected entities by relationship</returns>
4140
Dictionary<RelationshipProxy, IEnumerable> LoadImplicitlyAffected(Dictionary<RelationshipProxy, IEnumerable> principalEntities, IEnumerable existingDependentEntities = null);
4241

42+
/// <summary>
43+
/// For a set of entities, loads current values from the database
44+
/// </summary>
4345
IEnumerable LoadDbValues(Type entityType, IEnumerable entities, ResourceHook hook, params RelationshipProxy[] relationships);
4446
HashSet<TEntity> LoadDbValues<TEntity>(IEnumerable<TEntity> entities, ResourceHook hook, params RelationshipProxy[] relationships) where TEntity : class, IIdentifiable;
4547
}

src/JsonApiDotNetCore/Hooks/Execution/UpdatedRelationshipHelper.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,28 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using JsonApiDotNetCore.Internal;
65
using JsonApiDotNetCore.Models;
76

87
namespace JsonApiDotNetCore.Hooks
98
{
109
public interface IUpdatedRelationshipHelper { }
1110

11+
/// <summary>
12+
/// A helper class that provides insights in which relationships have been updated for which entities.
13+
/// </summary>
1214
public interface IUpdatedRelationshipHelper<TDependent> : IUpdatedRelationshipHelper where TDependent : class, IIdentifiable
1315
{
16+
/// <summary>
17+
/// Gets a dictionary of all entities grouped by affected relationship.
18+
/// </summary>
1419
Dictionary<RelationshipAttribute, HashSet<TDependent>> AllEntitiesByRelation { get; }
20+
/// <summary>
21+
/// Gets a dictionary of all entities that have an affected relationship to type <typeparamref name="TPrincipal"/>
22+
/// </summary>
1523
Dictionary<RelationshipAttribute, HashSet<TDependent>> EntitiesRelatedTo<TPrincipal>() where TPrincipal : class, IIdentifiable;
24+
/// <summary>
25+
/// Gets a dictionary of all entities that have an affected relationship to type <paramref name="principalType"/>
26+
/// </summary>
1627
Dictionary<RelationshipAttribute, HashSet<TDependent>> EntitiesRelatedTo(Type principalType);
1728
}
1829

0 commit comments

Comments
 (0)