Skip to content

Commit d038582

Browse files
committed
style: ContextEntity --> ResourceContext
1 parent 519513d commit d038582

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+131
-131
lines changed

benchmarks/Query/QueryParser_Benchmarks.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class QueryParser_Benchmarks {
2323

2424
public QueryParser_Benchmarks() {
2525
var requestMock = new Mock<IRequestContext>();
26-
requestMock.Setup(m => m.GetRequestResource()).Returns(new ContextEntity {
26+
requestMock.Setup(m => m.GetRequestResource()).Returns(new ResourceContext {
2727
Attributes = new List<AttrAttribute> {
2828
new AttrAttribute(ATTRIBUTE, ATTRIBUTE)
2929
}

src/Examples/GettingStarted/ResourceDefinitionExample/ModelDefinition.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GettingStarted.ResourceDefinitionExample
66
{
77
public class ModelDefinition : ResourceDefinition<Model>
88
{
9-
public ModelDefinition(IContextEntityProvider provider) : base(provider)
9+
public ModelDefinition(IResourceContextProvider provider) : base(provider)
1010
{
1111
}
1212

src/Examples/JsonApiDotNetCoreExample/Services/CustomArticleService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public CustomArticleService(ISortService sortService,
2020
IIncludeService includeService,
2121
ISparseFieldsService sparseFieldsService,
2222
IPageService pageService,
23-
IContextEntityProvider provider,
23+
IResourceContextProvider provider,
2424
IResourceHookExecutor hookExecutor = null,
2525
ILoggerFactory loggerFactory = null)
2626
: base(sortService, filterService, repository, options, includeService, sparseFieldsService,

src/JsonApiDotNetCore/Builders/JsonApiApplicationBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void ConfigureServices()
149149
_services.AddSingleton(resourceGraph);
150150
_services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
151151
_services.AddSingleton<IResourceGraph>(resourceGraph);
152-
_services.AddSingleton<IContextEntityProvider>(resourceGraph);
152+
_services.AddSingleton<IResourceContextProvider>(resourceGraph);
153153
_services.AddScoped<ICurrentRequest, CurrentRequest>();
154154
_services.AddScoped<IScopedServiceProvider, RequestScopedServiceProvider>();
155155
_services.AddScoped<IJsonApiWriter, JsonApiWriter>();

src/JsonApiDotNetCore/Builders/ResourceGraphBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace JsonApiDotNetCore.Builders
1717
{
1818
public class ResourceGraphBuilder : IResourceGraphBuilder
1919
{
20-
private readonly List<ContextEntity> _entities = new List<ContextEntity>();
20+
private readonly List<ResourceContext> _entities = new List<ResourceContext>();
2121
private readonly List<ValidationResult> _validationResults = new List<ValidationResult>();
2222
private readonly IResourceNameFormatter _resourceNameFormatter = new KebabCaseFormatter();
2323

@@ -36,7 +36,7 @@ public IResourceGraph Build()
3636
return resourceGraph;
3737
}
3838

39-
private void SetResourceLinksOptions(ContextEntity resourceContext)
39+
private void SetResourceLinksOptions(ResourceContext resourceContext)
4040
{
4141
var attribute = (LinksAttribute)resourceContext.EntityType.GetCustomAttribute(typeof(LinksAttribute));
4242
if (attribute != null)
@@ -67,7 +67,7 @@ public IResourceGraphBuilder AddResource(Type entityType, Type idType, string pl
6767
return this;
6868
}
6969

70-
private ContextEntity GetEntity(string pluralizedTypeName, Type entityType, Type idType) => new ContextEntity
70+
private ResourceContext GetEntity(string pluralizedTypeName, Type entityType, Type idType) => new ResourceContext
7171
{
7272
EntityName = pluralizedTypeName,
7373
EntityType = entityType,

src/JsonApiDotNetCore/Internal/ContextEntity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace JsonApiDotNetCore.Internal
88
{
9-
public class ContextEntity
9+
public class ResourceContext
1010
{
1111
/// <summary>
1212
/// The exposed resource name

src/JsonApiDotNetCore/Internal/Contracts/IContextEntityProvider.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@
77
namespace JsonApiDotNetCore.Internal.Contracts
88
{
99
/// <summary>
10-
/// Responsible for getting <see cref="ContextEntity"/>s from the <see cref="ResourceGraph"/>.
10+
/// Responsible for getting <see cref="ResourceContext"/>s from the <see cref="ResourceGraph"/>.
1111
/// </summary>
12-
public interface IContextEntityProvider
12+
public interface IResourceContextProvider
1313
{
1414
/// <summary>
1515
/// Gets all registered context entities
1616
/// </summary>
17-
ContextEntity[] GetContextEntities();
17+
ResourceContext[] GetContextEntities();
1818

1919
/// <summary>
2020
/// Get the resource metadata by the DbSet property name
2121
/// </summary>
22-
ContextEntity GetContextEntity(string exposedResourceName);
22+
ResourceContext GetResourceContext(string exposedResourceName);
2323

2424
/// <summary>
2525
/// Get the resource metadata by the resource type
2626
/// </summary>
27-
ContextEntity GetContextEntity(Type resourceType);
27+
ResourceContext GetResourceContext(Type resourceType);
2828

2929
/// <summary>
3030
/// Get the resource metadata by the resource type
3131
/// </summary>
32-
ContextEntity GetContextEntity<TResource>() where TResource : class, IIdentifiable;
32+
ResourceContext GetResourceContext<TResource>() where TResource : class, IIdentifiable;
3333
}
3434
}

src/JsonApiDotNetCore/Internal/Contracts/IResourceGraphExplorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace JsonApiDotNetCore.Internal.Contracts
99
/// Responsible for retrieving the exposed resource fields (attributes and
1010
/// relationships) of registered resources in the resource resourceGraph.
1111
/// </summary>
12-
public interface IResourceGraph : IContextEntityProvider
12+
public interface IResourceGraph : IResourceContextProvider
1313
{
1414
/// <summary>
1515
/// Gets all fields (attributes and relationships) for <typeparamref name="TResource"/>

src/JsonApiDotNetCore/Internal/InverseRelationships.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ public interface IInverseRelationships
2929
/// <inheritdoc />
3030
public class InverseRelationships : IInverseRelationships
3131
{
32-
private readonly IContextEntityProvider _provider;
32+
private readonly IResourceContextProvider _provider;
3333
private readonly IDbContextResolver _resolver;
3434

35-
public InverseRelationships(IContextEntityProvider provider, IDbContextResolver resolver = null)
35+
public InverseRelationships(IResourceContextProvider provider, IDbContextResolver resolver = null)
3636
{
3737
_provider = provider;
3838
_resolver = resolver;
@@ -45,7 +45,7 @@ public void Resolve()
4545
{
4646
DbContext context = _resolver.GetContext();
4747

48-
foreach (ContextEntity ce in _provider.GetContextEntities())
48+
foreach (ResourceContext ce in _provider.GetContextEntities())
4949
{
5050
IEntityType meta = context.Model.FindEntityType(ce.EntityType);
5151
if (meta == null) continue;

src/JsonApiDotNetCore/Internal/ResourceGraph.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ namespace JsonApiDotNetCore.Internal
1313
public class ResourceGraph : IResourceGraph
1414
{
1515
internal List<ValidationResult> ValidationResults { get; }
16-
private List<ContextEntity> _entities { get; }
16+
private List<ResourceContext> _entities { get; }
1717

18-
public ResourceGraph(List<ContextEntity> entities, List<ValidationResult> validationResults = null)
18+
public ResourceGraph(List<ResourceContext> entities, List<ValidationResult> validationResults = null)
1919
{
2020
_entities = entities;
2121
ValidationResults = validationResults;
2222
}
2323

2424
/// <inheritdoc />
25-
public ContextEntity[] GetContextEntities() => _entities.ToArray();
25+
public ResourceContext[] GetContextEntities() => _entities.ToArray();
2626

2727
/// <inheritdoc />
28-
public ContextEntity GetContextEntity(string entityName)
28+
public ResourceContext GetResourceContext(string entityName)
2929
=> _entities.SingleOrDefault(e => string.Equals(e.EntityName, entityName, StringComparison.OrdinalIgnoreCase));
3030

3131
/// <inheritdoc />
32-
public ContextEntity GetContextEntity(Type entityType)
32+
public ResourceContext GetResourceContext(Type entityType)
3333
=> _entities.SingleOrDefault(e => e.EntityType == entityType);
3434
/// <inheritdoc />
35-
public ContextEntity GetContextEntity<TResource>() where TResource : class, IIdentifiable
36-
=> GetContextEntity(typeof(TResource));
35+
public ResourceContext GetResourceContext<TResource>() where TResource : class, IIdentifiable
36+
=> GetResourceContext(typeof(TResource));
3737

3838
/// <inheritdoc/>
3939
public List<IResourceField> GetFields<T>(Expression<Func<T, dynamic>> selector = null) where T : IIdentifiable
@@ -53,24 +53,24 @@ public List<RelationshipAttribute> GetRelationships<T>(Expression<Func<T, dynami
5353
/// <inheritdoc/>
5454
public List<IResourceField> GetFields(Type type)
5555
{
56-
return GetContextEntity(type).Fields.ToList();
56+
return GetResourceContext(type).Fields.ToList();
5757
}
5858
/// <inheritdoc/>
5959
public List<AttrAttribute> GetAttributes(Type type)
6060
{
61-
return GetContextEntity(type).Attributes.ToList();
61+
return GetResourceContext(type).Attributes.ToList();
6262
}
6363
/// <inheritdoc/>
6464
public List<RelationshipAttribute> GetRelationships(Type type)
6565
{
66-
return GetContextEntity(type).Relationships.ToList();
66+
return GetResourceContext(type).Relationships.ToList();
6767
}
6868

6969
/// <inheritdoc />
7070
public RelationshipAttribute GetInverse(RelationshipAttribute relationship)
7171
{
7272
if (relationship.InverseNavigation == null) return null;
73-
return GetContextEntity(relationship.DependentType)
73+
return GetResourceContext(relationship.DependentType)
7474
.Relationships
7575
.SingleOrDefault(r => r.InternalRelationshipName == relationship.InverseNavigation);
7676
}
@@ -79,11 +79,11 @@ private IEnumerable<IResourceField> Getter<T>(Expression<Func<T, dynamic>> selec
7979
{
8080
IEnumerable<IResourceField> available;
8181
if (type == FieldFilterType.Attribute)
82-
available = GetContextEntity(typeof(T)).Attributes.Cast<IResourceField>();
82+
available = GetResourceContext(typeof(T)).Attributes.Cast<IResourceField>();
8383
else if (type == FieldFilterType.Relationship)
84-
available = GetContextEntity(typeof(T)).Relationships.Cast<IResourceField>();
84+
available = GetResourceContext(typeof(T)).Relationships.Cast<IResourceField>();
8585
else
86-
available = GetContextEntity(typeof(T)).Fields;
86+
available = GetResourceContext(typeof(T)).Fields;
8787

8888
if (selector == null)
8989
return available;

0 commit comments

Comments
 (0)