Skip to content

Commit aab51f6

Browse files
committed
Allow LastModified to be (internally) updated
Previously, `LastModified` was treated as readonly, to align with the original expectation that `AttributeValue` would be immutable. That's not how it's ended up being treated, however, and here we have a scenario where the `LastModified` needs to be updated. This is because `EnforceBusinessLogic` will trigger `SetValue()` indirectly via an `[AttributeSetter]` property. That's fine for updating the value. But for load and import scenarios, the `[AttributeSetter]` property will orphan the `Version` date intended to be used for the `LastModified` property. As such, we're exposing a setter to allow that property to be updated after this occurs. Since this is an outside scenario intended only to support infrastructure, however, the setter is marked as `internal`; there is no supported scenario where this should be updated directly by external callers.
1 parent 25b99b4 commit aab51f6

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

OnTopic/Attributes/AttributeValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ internal AttributeValue(
189189
/// <summary>
190190
/// Read-only reference to the last DateTime the <see cref="AttributeValue"/> instance was updated.
191191
/// </summary>
192-
public DateTime LastModified { get; } = DateTime.Now;
192+
public DateTime LastModified { get; internal set; } = DateTime.Now;
193193

194194
} //Class
195195
} //Namespace

OnTopic/Collections/AttributeValueCollection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ private bool EnforceBusinessLogic(AttributeValue originalAttribute, out Attribut
414414
}
415415
_typeCache.SetPropertyValue(_associatedTopic, originalAttribute.Key, originalAttribute.Value);
416416
this[originalAttribute.Key].IsDirty = originalAttribute.IsDirty;
417+
this[originalAttribute.Key].LastModified = originalAttribute.LastModified;
417418
_setCounter = 0;
418419
return false;
419420
}

0 commit comments

Comments
 (0)