Skip to content

Commit 354a1be

Browse files
committed
chore: fix NoEntityFrameworkExample project
1 parent 6a186a5 commit 354a1be

File tree

24 files changed

+93
-80
lines changed

24 files changed

+93
-80
lines changed

src/Examples/GettingStarted/Controllers/ArticlesController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using GettingStarted.Models;
22
using JsonApiDotNetCore.Configuration;
33
using JsonApiDotNetCore.Controllers;
4-
using JsonApiDotNetCore.Internal.Contracts;
54
using JsonApiDotNetCore.Services;
65

76
namespace GettingStarted

src/Examples/GettingStarted/Controllers/PeopleController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using GettingStarted.Models;
22
using JsonApiDotNetCore.Configuration;
33
using JsonApiDotNetCore.Controllers;
4-
using JsonApiDotNetCore.Internal.Contracts;
54
using JsonApiDotNetCore.Services;
65

76
namespace GettingStarted

src/Examples/GettingStarted/Data/SampleDbContext.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ namespace GettingStarted
66
{
77
public class SampleDbContext : DbContext
88
{
9-
public SampleDbContext(DbContextOptions<SampleDbContext> options)
10-
: base(options)
11-
{ }
12-
9+
public SampleDbContext(DbContextOptions<SampleDbContext> options) : base(options) { }
1310
public DbSet<Article> Articles { get; set; }
1411
public DbSet<Person> People { get; set; }
1512
public DbSet<Model> Models { get; set; }

src/Examples/GettingStarted/Models/Person.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public class Person : Identifiable
77
{
88
[Attr]
99
public string Name { get; set; }
10-
1110
[HasMany]
1211
public List<Article> Articles { get; set; }
1312
}

src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ namespace GettingStarted.ResourceDefinitionExample
66
{
77
public class ModelDefinition : ResourceDefinition<Model>
88
{
9-
public ModelDefinition(IResourceContextProvider provider) : base(provider)
9+
public ModelDefinition(IResourceGraph resourceGraph) : base(resourceGraph)
1010
{
11+
// this allows POST / PATCH requests to set the value of a
12+
// property, but we don't include this value in the response
13+
// this might be used if the incoming value gets hashed or
14+
// encrypted prior to being persisted and this value should
15+
// never be sent back to the client
16+
HideFields(model => model.DontExpose);
1117
}
12-
13-
// this allows POST / PATCH requests to set the value of a
14-
// property, but we don't include this value in the response
15-
// this might be used if the incoming value gets hashed or
16-
// encrypted prior to being persisted and this value should
17-
// never be sent back to the client
18-
protected override List<AttrAttribute> OutputAttrs()
19-
=> Remove(model => model.DontExpose);
2018
}
2119
}

src/Examples/GettingStarted/ResourceDefinitionExample/ModelsController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using JsonApiDotNetCore.Configuration;
22
using JsonApiDotNetCore.Controllers;
3-
using JsonApiDotNetCore.Internal.Contracts;
43
using JsonApiDotNetCore.Services;
54

65
namespace GettingStarted.ResourceDefinitionExample

src/Examples/GettingStarted/Startup.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Builder;
1+
using Microsoft.AspNetCore.Builder;
62
using Microsoft.AspNetCore.Hosting;
7-
using Microsoft.AspNetCore.Http;
83
using Microsoft.Extensions.DependencyInjection;
94
using Microsoft.EntityFrameworkCore;
105
using JsonApiDotNetCore.Extensions;
@@ -23,7 +18,7 @@ public void ConfigureServices(IServiceCollection services)
2318
var mvcBuilder = services.AddMvcCore();
2419
services.AddJsonApi(
2520
options => options.Namespace = "api",
26-
discover => discover.AddCurrentAssembly(), mvcBuilder);
21+
discover => discover.AddCurrentAssembly(), mvcBuilder: mvcBuilder);
2722
}
2823

2924
public void Configure(IApplicationBuilder app, IHostingEnvironment env, SampleDbContext context)

src/JsonApiDotNetCore/Builders/JsonApiApplicationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void ConfigureServices()
154154
_services.AddScoped<IScopedServiceProvider, RequestScopedServiceProvider>();
155155
_services.AddScoped<IJsonApiWriter, JsonApiWriter>();
156156
_services.AddScoped<IJsonApiReader, JsonApiReader>();
157-
_services.AddScoped<IGenericServiceFactory, genericServiceFactory>();
157+
_services.AddScoped<IGenericServiceFactory, GenericServiceFactory>();
158158
_services.AddScoped(typeof(HasManyThroughUpdateHelper<>));
159159
_services.AddScoped<IQueryParameterDiscovery, QueryParameterDiscovery>();
160160
_services.AddScoped<ITargetedFields, TargetedFields>();

src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,18 +423,18 @@ public class DefaultResourceRepository<TResource> : DefaultResourceRepository<TR
423423
{
424424
public DefaultResourceRepository(ITargetedFields targetedFields,
425425
IDbContextResolver contextResolver,
426-
IResourceGraph contextEntityProvider,
426+
IResourceGraph resourceContextProvider,
427427
IGenericServiceFactory genericServiceFactory)
428-
: base(targetedFields, contextResolver, contextEntityProvider, genericServiceFactory)
428+
: base(targetedFields, contextResolver, resourceContextProvider, genericServiceFactory)
429429
{
430430
}
431431

432432
public DefaultResourceRepository(ITargetedFields targetedFields,
433433
IDbContextResolver contextResolver,
434-
IResourceGraph contextEntityProvider,
434+
IResourceGraph resourceContextProvider,
435435
IGenericServiceFactory genericServiceFactory,
436436
ILoggerFactory loggerFactory = null)
437-
: base(targetedFields, contextResolver, contextEntityProvider, genericServiceFactory, loggerFactory)
437+
: base(targetedFields, contextResolver, resourceContextProvider, genericServiceFactory, loggerFactory)
438438
{
439439
}
440440
}

src/JsonApiDotNetCore/Hooks/Execution/HookExecutorHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ internal class HookExecutorHelper : IHookExecutorHelper
1919
{
2020
private readonly IdentifiableComparer _comparer = new IdentifiableComparer();
2121
private readonly IJsonApiOptions _options;
22-
protected readonly IGenericProcessorFactory _genericProcessorFactory;
22+
protected readonly IGenericServiceFactory _genericProcessorFactory;
2323
protected readonly Dictionary<RightType, IResourceHookContainer> _hookContainers;
2424
protected readonly Dictionary<RightType, IHooksDiscovery> _hookDiscoveries;
2525
protected readonly List<ResourceHook> _targetedHooksForRelatedEntities;
2626

27-
public HookExecutorHelper(IGenericProcessorFactory genericProcessorFactory,
27+
public HookExecutorHelper(IGenericServiceFactory genericProcessorFactory,
2828
IJsonApiOptions options)
2929
{
3030
_options = options;
@@ -43,7 +43,7 @@ public IResourceHookContainer GetResourceHookContainer(RightType rightType, Reso
4343
/// so we need not even bother.
4444
if (!_hookContainers.TryGetValue(rightType, out IResourceHookContainer container))
4545
{
46-
container = (_genericProcessorFactory.GetProcessor<IResourceHookContainer>(typeof(ResourceDefinition<>), rightType));
46+
container = (_genericProcessorFactory.Get<IResourceHookContainer>(typeof(ResourceDefinition<>), rightType));
4747
_hookContainers[rightType] = container;
4848
}
4949
if (container == null) return container;
@@ -123,7 +123,7 @@ IHooksDiscovery GetHookDiscovery(Type entityType)
123123
{
124124
if (!_hookDiscoveries.TryGetValue(entityType, out IHooksDiscovery discovery))
125125
{
126-
discovery = _genericProcessorFactory.GetProcessor<IHooksDiscovery>(typeof(IHooksDiscovery<>), entityType);
126+
discovery = _genericProcessorFactory.Get<IHooksDiscovery>(typeof(IHooksDiscovery<>), entityType);
127127
_hookDiscoveries[entityType] = discovery;
128128
}
129129
return discovery;
@@ -138,7 +138,7 @@ IEnumerable<TResource> GetWhereAndInclude<TResource, TId>(IEnumerable<TId> ids,
138138

139139
IResourceReadRepository<TResource, TId> GetRepository<TResource, TId>() where TResource : class, IIdentifiable<TId>
140140
{
141-
return _genericProcessorFactory.GetProcessor<IResourceReadRepository<TResource, TId>>(typeof(IResourceReadRepository<,>), typeof(TResource), typeof(TId));
141+
return _genericProcessorFactory.Get<IResourceReadRepository<TResource, TId>>(typeof(IResourceReadRepository<,>), typeof(TResource), typeof(TId));
142142
}
143143

144144

0 commit comments

Comments
 (0)