@@ -23,24 +23,36 @@ public interface IContextGraphBuilder
23
23
/// Add a json:api resource
24
24
/// </summary>
25
25
/// <typeparam name="TResource">The resource model type</typeparam>
26
- /// <param name="pluralizedTypeName">The pluralized name that should be exposed by the API</param>
27
- IContextGraphBuilder AddResource < TResource > ( string pluralizedTypeName ) where TResource : class , IIdentifiable < int > ;
26
+ /// <param name="pluralizedTypeName">
27
+ /// The pluralized name that should be exposed by the API.
28
+ /// If nothing is specified, the configured name formatter will be used.
29
+ /// See <see cref="JsonApiOptions.ResourceNameFormatter" />.
30
+ /// </param>
31
+ IContextGraphBuilder AddResource < TResource > ( string pluralizedTypeName = null ) where TResource : class , IIdentifiable < int > ;
28
32
29
33
/// <summary>
30
34
/// Add a json:api resource
31
35
/// </summary>
32
36
/// <typeparam name="TResource">The resource model type</typeparam>
33
37
/// <typeparam name="TId">The resource model identifier type</typeparam>
34
- /// <param name="pluralizedTypeName">The pluralized name that should be exposed by the API</param>
35
- IContextGraphBuilder AddResource < TResource , TId > ( string pluralizedTypeName ) where TResource : class , IIdentifiable < TId > ;
38
+ /// <param name="pluralizedTypeName">
39
+ /// The pluralized name that should be exposed by the API.
40
+ /// If nothing is specified, the configured name formatter will be used.
41
+ /// See <see cref="JsonApiOptions.ResourceNameFormatter" />.
42
+ /// </param>
43
+ IContextGraphBuilder AddResource < TResource , TId > ( string pluralizedTypeName = null ) where TResource : class , IIdentifiable < TId > ;
36
44
37
45
/// <summary>
38
46
/// Add a json:api resource
39
47
/// </summary>
40
48
/// <param name="entityType">The resource model type</param>
41
49
/// <param name="idType">The resource model identifier type</param>
42
- /// <param name="pluralizedTypeName">The pluralized name that should be exposed by the API</param>
43
- IContextGraphBuilder AddResource ( Type entityType , Type idType , string pluralizedTypeName ) ;
50
+ /// <param name="pluralizedTypeName">
51
+ /// The pluralized name that should be exposed by the API.
52
+ /// If nothing is specified, the configured name formatter will be used.
53
+ /// See <see cref="JsonApiOptions.ResourceNameFormatter" />.
54
+ /// </param>
55
+ IContextGraphBuilder AddResource ( Type entityType , Type idType , string pluralizedTypeName = null ) ;
44
56
45
57
/// <summary>
46
58
/// Add all the models that are part of the provided <see cref="DbContext" />
@@ -80,18 +92,20 @@ public IContextGraph Build()
80
92
}
81
93
82
94
/// <inheritdoc />
83
- public IContextGraphBuilder AddResource < TResource > ( string pluralizedTypeName ) where TResource : class , IIdentifiable < int >
95
+ public IContextGraphBuilder AddResource < TResource > ( string pluralizedTypeName = null ) where TResource : class , IIdentifiable < int >
84
96
=> AddResource < TResource , int > ( pluralizedTypeName ) ;
85
97
86
98
/// <inheritdoc />
87
- public IContextGraphBuilder AddResource < TResource , TId > ( string pluralizedTypeName ) where TResource : class , IIdentifiable < TId >
99
+ public IContextGraphBuilder AddResource < TResource , TId > ( string pluralizedTypeName = null ) where TResource : class , IIdentifiable < TId >
88
100
=> AddResource ( typeof ( TResource ) , typeof ( TId ) , pluralizedTypeName ) ;
89
101
90
102
/// <inheritdoc />
91
- public IContextGraphBuilder AddResource ( Type entityType , Type idType , string pluralizedTypeName )
103
+ public IContextGraphBuilder AddResource ( Type entityType , Type idType , string pluralizedTypeName = null )
92
104
{
93
105
AssertEntityIsNotAlreadyDefined ( entityType ) ;
94
106
107
+ pluralizedTypeName = pluralizedTypeName ?? _resourceNameFormatter . FormatResourceName ( entityType ) ;
108
+
95
109
_entities . Add ( GetEntity ( pluralizedTypeName , entityType , idType ) ) ;
96
110
97
111
return this ;
0 commit comments