Skip to content

Commit ef6fa83

Browse files
committed
Added (optional) lastUpdated parameter to constructor
Previously, the `AttributeValue` property had a `LastUpdated` property, but as it was automatically assigned, it wasn't included in the constructor. In preparation for allowing this to be set as part of the loading and import processes, however, this needs to be exposed as a writeable field, at least via the constructor (since, currently, the property itself is readonly). Arguably, this _might_ make more sense being placed after `value`; since mapped properties will be calling `enforceBusinessLogic`, however, but _not_ supplying `lastModified`, we're placing it last. Regardless, as ancillary metdata on an internal overload, the order isn't too critical here.
1 parent 82c8e5e commit ef6fa83

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

OnTopic/Attributes/AttributeValue.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,28 @@ public AttributeValue(string key, string? value, bool isDirty = true) {
9292
/// If disabled, <see cref="AttributeValueCollection"/> will not call local properties on <see cref="Topic"/> that
9393
/// correspond to the <paramref name="key"/> as a means of enforcing the business logic.
9494
/// </param>
95+
/// <param name="lastModified">
96+
/// The <see cref="DateTime"/> value that the attribute was last modified. This is intended exclusively for use when
97+
/// populating the topic graph from a persistent data store as a means of indicating the current version for each
98+
/// attribute. This is used when e.g. importing values to determine if the existing value is newer than the source value.
99+
/// </param>
95100
/// <requires
96101
/// description="The key must be specified for the key/value pair." exception="T:System.ArgumentNullException">
97102
/// !String.IsNullOrWhiteSpace(key)
98103
/// </requires>
99-
internal AttributeValue(string key, string? value, bool isDirty, bool enforceBusinessLogic) : this(key, value, isDirty) {
100-
EnforceBusinessLogic = enforceBusinessLogic;
104+
internal AttributeValue(
105+
string key,
106+
string? value,
107+
bool isDirty,
108+
bool enforceBusinessLogic,
109+
DateTime? lastModified = null
110+
): this(
111+
key,
112+
value,
113+
isDirty
114+
) {
115+
EnforceBusinessLogic = enforceBusinessLogic;
116+
LastModified = lastModified?? DateTime.Now;
101117
}
102118

103119
/*==========================================================================================================================

0 commit comments

Comments
 (0)