1+ using System ;
2+
13namespace 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}
0 commit comments