Skip to content

Commit dd0cae4

Browse files
committed
revert rename of entity resource service
1 parent 5b18304 commit dd0cae4

File tree

5 files changed

+27
-30
lines changed

5 files changed

+27
-30
lines changed

src/Examples/ResourceEntitySeparationExample/Startup.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using JsonApiDotNetCore.Models;
66
using JsonApiDotNetCore.Services;
77
using JsonApiDotNetCoreExample.Data;
8-
using JsonApiDotNetCoreExample.Models;
98
using JsonApiDotNetCoreExample.Models.Entities;
109
using JsonApiDotNetCoreExample.Models.Resources;
1110
using Microsoft.AspNetCore.Builder;
@@ -15,7 +14,6 @@
1514
using Microsoft.Extensions.DependencyInjection;
1615
using Microsoft.Extensions.Logging;
1716
using ResourceEntitySeparationExample.Models;
18-
using ResourceEntitySeparationExample.Profiles;
1917

2018
namespace ResourceEntitySeparationExample
2119
{
@@ -61,9 +59,9 @@ public virtual IServiceProvider ConfigureServices(IServiceCollection services)
6159
services.AddAutoMapper();
6260
services.AddScoped<IResourceMapper, AutoMapperAdapter>();
6361

64-
services.AddScoped<IResourceService<CourseResource, int>, DefaultResourceService<CourseResource, CourseEntity, int>>();
65-
services.AddScoped<IResourceService<DepartmentResource, int>, DefaultResourceService<DepartmentResource, DepartmentEntity, int>>();
66-
services.AddScoped<IResourceService<StudentResource, int>, DefaultResourceService<StudentResource, StudentEntity, int>>();
62+
services.AddScoped<IResourceService<CourseResource, int>, EntityResourceService<CourseResource, CourseEntity, int>>();
63+
services.AddScoped<IResourceService<DepartmentResource, int>, EntityResourceService<DepartmentResource, DepartmentEntity, int>>();
64+
services.AddScoped<IResourceService<StudentResource, int>, EntityResourceService<StudentResource, StudentEntity, int>>();
6765

6866
var provider = services.BuildServiceProvider();
6967
var appContext = provider.GetRequiredService<AppDbContext>();

src/JsonApiDotNetCore/Builders/ContextGraphBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected virtual List<RelationshipAttribute> GetRelationships(Type entityType)
125125
{
126126
var attribute = (RelationshipAttribute)prop.GetCustomAttribute(typeof(RelationshipAttribute));
127127
if (attribute == null) continue;
128-
if (attribute.InternalRelationshipName == null) attribute.InternalRelationshipName = prop.Name;
128+
attribute.InternalRelationshipName = prop.Name;
129129
attribute.Type = GetRelationshipType(attribute, prop);
130130
attributes.Add(attribute);
131131
}

src/JsonApiDotNetCore/Data/DefaultEntityRepository.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Reflection;
54
using System.Threading.Tasks;
65
using JsonApiDotNetCore.Extensions;
76
using JsonApiDotNetCore.Internal;

src/JsonApiDotNetCore/Extensions/IServiceCollectionExtensions.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,26 @@ public static void AddJsonApiInternals(
102102
services.AddScoped(typeof(IEntityRepository<>), typeof(DefaultEntityRepository<>));
103103
services.AddScoped(typeof(IEntityRepository<,>), typeof(DefaultEntityRepository<,>));
104104

105-
services.AddScoped(typeof(ICreateService<>), typeof(DefaultResourceService<>));
106-
services.AddScoped(typeof(ICreateService<,>), typeof(DefaultResourceService<,>));
105+
services.AddScoped(typeof(ICreateService<>), typeof(EntityResourceService<>));
106+
services.AddScoped(typeof(ICreateService<,>), typeof(EntityResourceService<,>));
107107

108-
services.AddScoped(typeof(IGetAllService<>), typeof(DefaultResourceService<>));
109-
services.AddScoped(typeof(IGetAllService<,>), typeof(DefaultResourceService<,>));
108+
services.AddScoped(typeof(IGetAllService<>), typeof(EntityResourceService<>));
109+
services.AddScoped(typeof(IGetAllService<,>), typeof(EntityResourceService<,>));
110110

111-
services.AddScoped(typeof(IGetByIdService<>), typeof(DefaultResourceService<>));
112-
services.AddScoped(typeof(IGetByIdService<,>), typeof(DefaultResourceService<,>));
111+
services.AddScoped(typeof(IGetByIdService<>), typeof(EntityResourceService<>));
112+
services.AddScoped(typeof(IGetByIdService<,>), typeof(EntityResourceService<,>));
113113

114-
services.AddScoped(typeof(IGetRelationshipService<,>), typeof(DefaultResourceService<>));
115-
services.AddScoped(typeof(IGetRelationshipService<,>), typeof(DefaultResourceService<,>));
114+
services.AddScoped(typeof(IGetRelationshipService<,>), typeof(EntityResourceService<>));
115+
services.AddScoped(typeof(IGetRelationshipService<,>), typeof(EntityResourceService<,>));
116116

117-
services.AddScoped(typeof(IUpdateService<>), typeof(DefaultResourceService<>));
118-
services.AddScoped(typeof(IUpdateService<,>), typeof(DefaultResourceService<,>));
117+
services.AddScoped(typeof(IUpdateService<>), typeof(EntityResourceService<>));
118+
services.AddScoped(typeof(IUpdateService<,>), typeof(EntityResourceService<,>));
119119

120-
services.AddScoped(typeof(IDeleteService<>), typeof(DefaultResourceService<>));
121-
services.AddScoped(typeof(IDeleteService<,>), typeof(DefaultResourceService<,>));
120+
services.AddScoped(typeof(IDeleteService<>), typeof(EntityResourceService<>));
121+
services.AddScoped(typeof(IDeleteService<,>), typeof(EntityResourceService<,>));
122122

123-
services.AddScoped(typeof(IResourceService<>), typeof(DefaultResourceService<>));
124-
services.AddScoped(typeof(IResourceService<,>), typeof(DefaultResourceService<,>));
123+
services.AddScoped(typeof(IResourceService<>), typeof(EntityResourceService<>));
124+
services.AddScoped(typeof(IResourceService<,>), typeof(EntityResourceService<,>));
125125

126126
services.AddSingleton(jsonApiOptions);
127127
services.AddSingleton(jsonApiOptions.ContextGraph);

src/JsonApiDotNetCore/Services/DefaultResourceService.cs renamed to src/JsonApiDotNetCore/Services/EntityResourceService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@
99

1010
namespace JsonApiDotNetCore.Services
1111
{
12-
public class DefaultResourceService<TResource> : DefaultResourceService<TResource, int>,
12+
public class EntityResourceService<TResource> : EntityResourceService<TResource, int>,
1313
IResourceService<TResource>
1414
where TResource : class, IIdentifiable<int>
1515
{
16-
public DefaultResourceService(
16+
public EntityResourceService(
1717
IJsonApiContext jsonApiContext,
1818
IEntityRepository<TResource> entityRepository,
1919
ILoggerFactory loggerFactory) :
2020
base(jsonApiContext, entityRepository, loggerFactory)
2121
{ }
2222
}
2323

24-
public class DefaultResourceService<TResource, TId> : DefaultResourceService<TResource, TResource, TId>,
24+
public class EntityResourceService<TResource, TId> : EntityResourceService<TResource, TResource, TId>,
2525
IResourceService<TResource, TId>
2626
where TResource : class, IIdentifiable<TId>
2727
{
28-
public DefaultResourceService(
28+
public EntityResourceService(
2929
IJsonApiContext jsonApiContext,
3030
IEntityRepository<TResource, TId> entityRepository,
3131
ILoggerFactory loggerFactory) :
3232
base(jsonApiContext, entityRepository, loggerFactory)
3333
{ }
3434
}
3535

36-
public class DefaultResourceService<TResource, TEntity, TId> :
36+
public class EntityResourceService<TResource, TEntity, TId> :
3737
IResourceService<TResource, TId>
3838
where TResource : class, IIdentifiable<TId>
3939
where TEntity : class, IIdentifiable<TId>
@@ -43,7 +43,7 @@ public class DefaultResourceService<TResource, TEntity, TId> :
4343
private readonly ILogger _logger;
4444
private readonly IResourceMapper _mapper;
4545

46-
public DefaultResourceService(
46+
public EntityResourceService(
4747
IJsonApiContext jsonApiContext,
4848
IEntityRepository<TEntity, TId> entityRepository,
4949
ILoggerFactory loggerFactory)
@@ -57,18 +57,18 @@ public DefaultResourceService(
5757

5858
_jsonApiContext = jsonApiContext;
5959
_entities = entityRepository;
60-
_logger = loggerFactory.CreateLogger<DefaultResourceService<TResource, TEntity, TId>>();
60+
_logger = loggerFactory.CreateLogger<EntityResourceService<TResource, TEntity, TId>>();
6161
}
6262

63-
public DefaultResourceService(
63+
public EntityResourceService(
6464
IJsonApiContext jsonApiContext,
6565
IEntityRepository<TEntity, TId> entityRepository,
6666
ILoggerFactory loggerFactory,
6767
IResourceMapper mapper)
6868
{
6969
_jsonApiContext = jsonApiContext;
7070
_entities = entityRepository;
71-
_logger = loggerFactory.CreateLogger<DefaultResourceService<TResource, TEntity, TId>>();
71+
_logger = loggerFactory.CreateLogger<EntityResourceService<TResource, TEntity, TId>>();
7272
_mapper = mapper;
7373
}
7474

0 commit comments

Comments
 (0)