1
1
using JsonApiDotNetCore . Builders ;
2
+ using JsonApiDotNetCore . Configuration ;
2
3
using JsonApiDotNetCore . Data ;
3
4
using JsonApiDotNetCore . Internal ;
4
5
using JsonApiDotNetCore . Models ;
@@ -55,23 +56,20 @@ public ServiceDiscoveryFacade(
55
56
/// <summary>
56
57
/// Add resources, services and repository implementations to the container.
57
58
/// </summary>
58
- /// <param name="resourceNameFormatter">The type name formatter used to get the string representation of resource names.</param>
59
- public ServiceDiscoveryFacade AddCurrentAssembly ( IResourceNameFormatter resourceNameFormatter = null )
60
- => AddAssembly ( Assembly . GetCallingAssembly ( ) , resourceNameFormatter ) ;
59
+ public ServiceDiscoveryFacade AddCurrentAssembly ( ) => AddAssembly ( Assembly . GetCallingAssembly ( ) ) ;
61
60
62
61
/// <summary>
63
62
/// Add resources, services and repository implementations to the container.
64
63
/// </summary>
65
64
/// <param name="assembly">The assembly to search for resources in.</param>
66
- /// <param name="resourceNameFormatter">The type name formatter used to get the string representation of resource names.</param>
67
- public ServiceDiscoveryFacade AddAssembly ( Assembly assembly , IResourceNameFormatter resourceNameFormatter = null )
65
+ public ServiceDiscoveryFacade AddAssembly ( Assembly assembly )
68
66
{
69
67
AddDbContextResolvers ( assembly ) ;
70
68
71
69
var resourceDescriptors = TypeLocator . GetIdentifableTypes ( assembly ) ;
72
70
foreach ( var resourceDescriptor in resourceDescriptors )
73
71
{
74
- AddResource ( assembly , resourceDescriptor , resourceNameFormatter ) ;
72
+ AddResource ( assembly , resourceDescriptor ) ;
75
73
AddServices ( assembly , resourceDescriptor ) ;
76
74
AddRepositories ( assembly , resourceDescriptor ) ;
77
75
}
@@ -93,20 +91,19 @@ private void AddDbContextResolvers(Assembly assembly)
93
91
/// Adds resources to the graph and registers <see cref="ResourceDefinition{T}"/> types on the container.
94
92
/// </summary>
95
93
/// <param name="assembly">The assembly to search for resources in.</param>
96
- /// <param name="resourceNameFormatter">The type name formatter used to get the string representation of resource names.</param>
97
- public ServiceDiscoveryFacade AddResources ( Assembly assembly , IResourceNameFormatter resourceNameFormatter = null )
94
+ public ServiceDiscoveryFacade AddResources ( Assembly assembly )
98
95
{
99
96
var identifiables = TypeLocator . GetIdentifableTypes ( assembly ) ;
100
97
foreach ( var identifiable in identifiables )
101
- AddResource ( assembly , identifiable , resourceNameFormatter ) ;
98
+ AddResource ( assembly , identifiable ) ;
102
99
103
100
return this ;
104
101
}
105
102
106
- private void AddResource ( Assembly assembly , ResourceDescriptor resourceDescriptor , IResourceNameFormatter resourceNameFormatter = null )
103
+ private void AddResource ( Assembly assembly , ResourceDescriptor resourceDescriptor )
107
104
{
108
105
RegisterResourceDefinition ( assembly , resourceDescriptor ) ;
109
- AddResourceToGraph ( resourceDescriptor , resourceNameFormatter ) ;
106
+ AddResourceToGraph ( resourceDescriptor ) ;
110
107
}
111
108
112
109
private void RegisterResourceDefinition ( Assembly assembly , ResourceDescriptor identifiable )
@@ -125,17 +122,14 @@ private void RegisterResourceDefinition(Assembly assembly, ResourceDescriptor id
125
122
}
126
123
}
127
124
128
- private void AddResourceToGraph ( ResourceDescriptor identifiable , IResourceNameFormatter resourceNameFormatter = null )
125
+ private void AddResourceToGraph ( ResourceDescriptor identifiable )
129
126
{
130
- var resourceName = FormatResourceName ( identifiable . ResourceType , resourceNameFormatter ) ;
127
+ var resourceName = FormatResourceName ( identifiable . ResourceType ) ;
131
128
_graphBuilder . AddResource ( identifiable . ResourceType , identifiable . IdType , resourceName ) ;
132
129
}
133
130
134
- private string FormatResourceName ( Type resourceType , IResourceNameFormatter resourceNameFormatter )
135
- {
136
- resourceNameFormatter = resourceNameFormatter ?? new DefaultResourceNameFormatter ( ) ;
137
- return resourceNameFormatter . FormatResourceName ( resourceType ) ;
138
- }
131
+ private string FormatResourceName ( Type resourceType )
132
+ => JsonApiOptions . ResourceNameFormatter . FormatResourceName ( resourceType ) ;
139
133
140
134
/// <summary>
141
135
/// Add <see cref="IResourceService{T, TId}"/> implementations to container.
0 commit comments