/// <summary> /// Constructor. /// </summary> /// <param name="parentEntity">The <see cref="IDynamicEntity"/> that owns this mapper.</param> /// <param name="jsonName">The JSON property name.</param> /// <param name="propertyName">The entity property name.</param> /// <param name="context">The <see cref="IDynamicEntityContext"/> or <c>null</c>.</param> public DocLinkMapper(IDynamicEntity parentEntity, string jsonName, string propertyName, IDynamicEntityContext context) { Covenant.Requires <ArgumentNullException>(parentEntity != null); Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(jsonName)); Covenant.Requires <ArgumentNullException>(!string.IsNullOrEmpty(propertyName)); this.parentEntity = parentEntity; this.context = context; this.JsonName = jsonName; this.PropertyName = propertyName; this.property = null; this.documentValue = null; this.isDeletedFunc = null; }
/// <inheritdoc/> public bool Load(JProperty newProperty, bool reload = false) { Covenant.Requires <ArgumentNullException>(newProperty != null); var changed = !NeonHelper.JTokenEquals(property, newProperty); this.property = newProperty; this.documentValue = null; // Purge any cached entity info this.isDeletedFunc = null; if (reload && changed) { parentEntity._OnPropertyChanged(PropertyName); } return(changed); }