Skip to content

Commit 2cbf4b8

Browse files
committed
doc(ContextGraph): add API documentation
1 parent f3272b0 commit 2cbf4b8

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/JsonApiDotNetCore/Internal/ContextGraph.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,45 @@ namespace JsonApiDotNetCore.Internal
66
{
77
public interface IContextGraph
88
{
9-
object GetRelationship<TParent>(TParent entity, string relationshipName);
9+
/// <summary>
10+
/// Gets the value of the navigation property, defined by the relationshipName,
11+
/// on the provided instance.
12+
/// </summary>
13+
/// <param name="resource">The resource instance</param>
14+
/// <param name="propertyName">The navigation property name.</param>
15+
/// <example>
16+
/// <code>
17+
/// _graph.GetRelationship(todoItem, nameof(TodoItem.Owner));
18+
/// </code>
19+
/// </example>
20+
object GetRelationship<TParent>(TParent resource, string propertyName);
21+
22+
/// <summary>
23+
/// Get the internal navigation property name for the specified public
24+
/// relationship name.
25+
/// </summary>
26+
/// <param name="relationshipName">The public relationship name specified by a <see cref="HasOneAttribute" /> or <see cref="HasManyAttribute" /></param>
27+
/// <example>
28+
/// <code>
29+
/// _graph.GetRelationshipName&lt;TodoItem&gt;("achieved-date");
30+
/// // returns "AchievedDate"
31+
/// </code>
32+
/// </example>
1033
string GetRelationshipName<TParent>(string relationshipName);
34+
35+
/// <summary>
36+
/// Get the resource metadata by the DbSet property name
37+
/// </summary>
1138
ContextEntity GetContextEntity(string dbSetName);
39+
40+
/// <summary>
41+
/// Get the resource metadata by the resource type
42+
/// </summary>
1243
ContextEntity GetContextEntity(Type entityType);
44+
45+
/// <summary>
46+
/// Was built against an EntityFrameworkCore DbContext ?
47+
/// </summary>
1348
bool UsesDbContext { get; }
1449
}
1550

@@ -40,14 +75,18 @@ internal ContextGraph(List<ContextEntity> entities, bool usesDbContext, List<Val
4075
Instance = this;
4176
}
4277

78+
/// </ inheritdoc>
4379
public bool UsesDbContext { get; }
4480

81+
/// </ inheritdoc>
4582
public ContextEntity GetContextEntity(string entityName)
4683
=> Entities.SingleOrDefault(e => string.Equals(e.EntityName, entityName, StringComparison.OrdinalIgnoreCase));
4784

85+
/// </ inheritdoc>
4886
public ContextEntity GetContextEntity(Type entityType)
4987
=> Entities.SingleOrDefault(e => e.EntityType == entityType);
5088

89+
/// </ inheritdoc>
5190
public object GetRelationship<TParent>(TParent entity, string relationshipName)
5291
{
5392
var parentEntityType = entity.GetType();
@@ -62,6 +101,7 @@ public object GetRelationship<TParent>(TParent entity, string relationshipName)
62101
return navigationProperty.GetValue(entity);
63102
}
64103

104+
/// </ inheritdoc>
65105
public string GetRelationshipName<TParent>(string relationshipName)
66106
{
67107
var entityType = typeof(TParent);

0 commit comments

Comments
 (0)