Skip to content

Commit a208460

Browse files
committed
revert the exposing of internal name
1 parent bed4e9d commit a208460

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

src/JsonApiDotNetCore/Models/HasManyAttribute.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
13
namespace JsonApiDotNetCore.Models
24
{
35
public class HasManyAttribute : RelationshipAttribute
@@ -7,7 +9,6 @@ public class HasManyAttribute : RelationshipAttribute
79
/// </summary>
810
///
911
/// <param name="publicName">The relationship name as exposed by the API</param>
10-
/// <param name="internalName">The relationship name as defined in the entity layer, if not provided defaults to the variable name</param>
1112
/// <param name="documentLinks">Which links are available. Defaults to <see cref="Link.All"/></param>
1213
/// <param name="canInclude">Whether or not this relationship can be included using the <c>?include=public-name</c> query string</param>
1314
///
@@ -22,23 +23,22 @@ public class HasManyAttribute : RelationshipAttribute
2223
/// </code>
2324
///
2425
/// </example>
25-
public HasManyAttribute(string publicName, string internalName = null, Link documentLinks = Link.All,
26-
bool canInclude = true)
27-
: base(publicName, internalName, documentLinks, canInclude)
26+
public HasManyAttribute(string publicName, Link documentLinks = Link.All, bool canInclude = true)
27+
: base(publicName, documentLinks, canInclude)
2828
{ }
2929

3030
/// <summary>
3131
/// Sets the value of the property identified by this attribute
3232
/// </summary>
33-
/// <param name="entity">The target object</param>
33+
/// <param name="resource">The target object</param>
3434
/// <param name="newValue">The new property value</param>
35-
public override void SetValue(object entity, object newValue)
35+
public override void SetValue(object resource, object newValue)
3636
{
37-
var propertyInfo = entity
37+
var propertyInfo = resource
3838
.GetType()
3939
.GetProperty(InternalRelationshipName);
4040

41-
propertyInfo.SetValue(entity, newValue);
41+
propertyInfo.SetValue(resource, newValue);
4242
}
4343
}
4444
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
13
namespace JsonApiDotNetCore.Models
24
{
35
public class HasOneAttribute : RelationshipAttribute
@@ -7,10 +9,9 @@ public class HasOneAttribute : RelationshipAttribute
79
/// </summary>
810
///
911
/// <param name="publicName">The relationship name as exposed by the API</param>
10-
/// <param name="internalName">The relationship name as defined in the entity layer, if not provided defaults to the variable name</param>
1112
/// <param name="documentLinks">Which links are available. Defaults to <see cref="Link.All"/></param>
1213
/// <param name="canInclude">Whether or not this relationship can be included using the <c>?include=public-name</c> query string</param>
13-
/// <param name="withForiegnKey">The foreign key property name. Defaults to <c>"{RelationshipName}Id"</c></param>
14+
/// <param name="withForeignKey">The foreign key property name. Defaults to <c>"{RelationshipName}Id"</c></param>
1415
///
1516
/// <example>
1617
/// Using an alternative foreign key:
@@ -25,17 +26,16 @@ public class HasOneAttribute : RelationshipAttribute
2526
/// </code>
2627
///
2728
/// </example>
28-
public HasOneAttribute(string publicName, string internalName = null, Link documentLinks = Link.All,
29-
bool canInclude = true, string withForiegnKey = null)
30-
: base(publicName, internalName, documentLinks, canInclude)
29+
public HasOneAttribute(string publicName, Link documentLinks = Link.All, bool canInclude = true, string withForeignKey = null)
30+
: base(publicName, documentLinks, canInclude)
3131
{
32-
_explicitIdentifiablePropertyName = withForiegnKey;
32+
_explicitIdentifiablePropertyName = withForeignKey;
3333
}
3434

3535
private readonly string _explicitIdentifiablePropertyName;
3636

3737
/// <summary>
38-
/// The independent entity identifier.
38+
/// The independent resource identifier.
3939
/// </summary>
4040
public string IdentifiablePropertyName => string.IsNullOrWhiteSpace(_explicitIdentifiablePropertyName)
4141
? $"{InternalRelationshipName}Id"
@@ -44,19 +44,19 @@ public HasOneAttribute(string publicName, string internalName = null, Link docum
4444
/// <summary>
4545
/// Sets the value of the property identified by this attribute
4646
/// </summary>
47-
/// <param name="entity">The target object</param>
47+
/// <param name="resource">The target object</param>
4848
/// <param name="newValue">The new property value</param>
49-
public override void SetValue(object entity, object newValue)
49+
public override void SetValue(object resource, object newValue)
5050
{
5151
var propertyName = (newValue?.GetType() == Type)
5252
? InternalRelationshipName
5353
: IdentifiablePropertyName;
5454

55-
var propertyInfo = entity
55+
var propertyInfo = resource
5656
.GetType()
5757
.GetProperty(propertyName);
5858

59-
propertyInfo.SetValue(entity, newValue);
59+
propertyInfo.SetValue(resource, newValue);
6060
}
6161

6262
// HACK: this will likely require boxing
@@ -65,16 +65,16 @@ public override void SetValue(object entity, object newValue)
6565
/// Gets the value of the independent identifier (e.g. Article.AuthorId)
6666
/// </summary>
6767
///
68-
/// <param name="entity">
68+
/// <param name="resource">
6969
/// An instance of dependent resource
7070
/// </param>
7171
///
7272
/// <returns>
7373
/// The property value or null if the property does not exist on the model.
7474
/// </returns>
75-
internal object GetIdentifiablePropertyValue(object entity) => entity
75+
internal object GetIdentifiablePropertyValue(object resource) => resource
7676
.GetType()
7777
.GetProperty(IdentifiablePropertyName)
78-
?.GetValue(entity);
78+
?.GetValue(resource);
7979
}
8080
}

src/JsonApiDotNetCore/Models/RelationshipAttribute.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ namespace JsonApiDotNetCore.Models
44
{
55
public abstract class RelationshipAttribute : Attribute
66
{
7-
protected RelationshipAttribute(string publicName, string internalName, Link documentLinks, bool canInclude)
7+
protected RelationshipAttribute(string publicName, Link documentLinks, bool canInclude)
88
{
99
PublicRelationshipName = publicName;
1010
DocumentLinks = documentLinks;
1111
CanInclude = canInclude;
12-
InternalRelationshipName = internalName;
1312
}
1413

1514
public string PublicRelationshipName { get; }
1615
public string InternalRelationshipName { get; internal set; }
17-
16+
1817
/// <summary>
1918
/// The related entity type. This does not necessarily match the navigation property type.
2019
/// In the case of a HasMany relationship, this value will be the generic argument type.

0 commit comments

Comments
 (0)