Skip to content

Commit 10c7c09

Browse files
committed
Introduce new isExtendedAttribute parameter to SetValue()
In order for `ITopicRepository` to establish that an `AttributeValue` is an `IsExtendedAttribute`, it needs to be able to pass that value to an overload of `SetValue()`. To handle this, a new, optional `isExtendedAttribute` parameter is appended to the `SetValue()` method to allow callers to specify the `IsExtendedAttribute` property of the underlying `AttributeValue`. This also requires updating a few XMLDocs which reference the `SetValue() method. Each of those pieces of documentation must be updated to reflect the updated signature and potentially "repaginated" to maintain our 128 character code width standard.
1 parent aa40acd commit 10c7c09

2 files changed

Lines changed: 36 additions & 19 deletions

File tree

OnTopic/Attributes/AttributeValue.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ namespace OnTopic.Attributes {
3333
/// <para>
3434
/// This class is immutable: once it is constructed, the values cannot be changed. To change a value, callers must either
3535
/// create a new instance of the <see cref="AttributeValue"/> class or, preferably, call the
36-
/// <see cref="Topic.Attributes"/>'s <see cref="AttributeValueCollection.SetValue(String, String, Boolean?, DateTime?)"/>
36+
/// <see cref="Topic.Attributes"/>'s <see cref="AttributeValueCollection.SetValue(String, String, Boolean?, DateTime?,
37+
/// Boolean?)"/>
3738
/// method.
3839
/// </para>
3940
/// </remarks>
@@ -168,13 +169,14 @@ internal AttributeValue(
168169
/// </summary>
169170
/// <remarks>
170171
/// By default, when a user attempts to update an attribute's value by calling <see
171-
/// cref="AttributeValueCollection.SetValue(String, String, Boolean?, DateTime?)"/>, or when an <see cref="AttributeValue"
172-
/// /> is added to the <see cref="AttributeValueCollection"/>, the <see cref="AttributeValueCollection"/> will
173-
/// automatically attempt to call any corresponding setters on <see cref="Topic"/> (or a derived instance) to ensure that
174-
/// the business logic is enforced. To avoid an infinite loop, however, this is disabled when properties on <see
175-
/// cref="Topic"/> call <see cref="Topic.SetAttributeValue(String, String, Boolean?)"/>. When that happens, the
176-
/// <see cref="EnforceBusinessLogic"/> value is set to false to communicate to the <see cref="AttributeValueCollection"/>
177-
/// that it should not call the local property. This value is only intended for internal use.
172+
/// cref="AttributeValueCollection.SetValue(String, String, Boolean?, DateTime?, Boolean?)"/>, or when an <see
173+
/// cref="AttributeValue"/> is added to the <see cref="AttributeValueCollection"/>, the <see
174+
/// cref="AttributeValueCollection"/> will automatically attempt to call any corresponding setters on <see cref="Topic"/>
175+
/// (or a derived instance) to ensure that the business logic is enforced. To avoid an infinite loop, however, this is
176+
/// disabled when properties on <see cref="Topic"/> call <see cref="Topic.SetAttributeValue(String, String, Boolean?)"/>.
177+
/// When that happens, the <see cref="EnforceBusinessLogic"/> value is set to false to communicate to the <see
178+
/// cref="AttributeValueCollection"/> that it should not call the local property. This value is only intended for internal
179+
/// use.
178180
/// </remarks>
179181
/// <requires description="The value from the getter must be specified." exception="T:System.ArgumentNullException">
180182
/// !String.IsNullOrWhiteSpace(value)

OnTopic/Collections/AttributeValueCollection.cs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ public bool IsDirty(string name) {
233233
/// populating the topic graph from a persistent data store as a means of indicating the current version for each
234234
/// attribute. This is used when e.g. importing values to determine if the existing value is newer than the source value.
235235
/// </param>
236+
/// <param name="isExtendedAttribute">Determines if the attribute originated from an extended attributes data store.</param>
236237
/// <requires
237238
/// description="The key must be specified for the AttributeValue key/value pair."
238239
/// exception="T:System.ArgumentNullException">
@@ -248,8 +249,14 @@ public bool IsDirty(string name) {
248249
/// exception="T:System.ArgumentException">
249250
/// !value.Contains(" ")
250251
/// </requires>
251-
public void SetValue(string key, string? value, bool? isDirty = null, DateTime? version = null)
252-
=> SetValue(key, value, isDirty, true, version);
252+
public void SetValue(
253+
string key,
254+
string? value,
255+
bool? isDirty = null,
256+
DateTime? version = null,
257+
bool? isExtendedAttribute = null
258+
)
259+
=> SetValue(key, value, isDirty, true, version, isExtendedAttribute);
253260

254261
/// <summary>
255262
/// Protected helper method that either adds a new <see cref="AttributeValue"/> object or updates the value of an existing
@@ -277,6 +284,7 @@ public void SetValue(string key, string? value, bool? isDirty = null, DateTime?
277284
/// populating the topic graph from a persistent data store as a means of indicating the current version for each
278285
/// attribute. This is used when e.g. importing values to determine if the existing value is newer than the source value.
279286
/// </param>
287+
/// <param name="isExtendedAttribute">Determines if the attribute originated from an extended attributes data store.</param>
280288
/// <requires
281289
/// description="The key must be specified for the AttributeValue key/value pair."
282290
/// exception="T:System.ArgumentNullException">
@@ -292,7 +300,14 @@ public void SetValue(string key, string? value, bool? isDirty = null, DateTime?
292300
/// exception="T:System.ArgumentException">
293301
/// !value.Contains(" ")
294302
/// </requires>
295-
internal void SetValue(string key, string? value, bool? isDirty, bool enforceBusinessLogic, DateTime? version = null) {
303+
internal void SetValue(
304+
string key,
305+
string? value,
306+
bool? isDirty,
307+
bool enforceBusinessLogic,
308+
DateTime? version = null,
309+
bool? isExtendedAttribute = null
310+
) {
296311

297312
/*------------------------------------------------------------------------------------------------------------------------
298313
| Validate input
@@ -327,7 +342,7 @@ internal void SetValue(string key, string? value, bool? isDirty, bool enforceBus
327342
else if (originalAttribute.Value != value) {
328343
markAsDirty = true;
329344
}
330-
var newAttribute = new AttributeValue(key, value, markAsDirty, enforceBusinessLogic, version);
345+
var newAttribute = new AttributeValue(key, value, markAsDirty, enforceBusinessLogic, version, isExtendedAttribute);
331346
this[IndexOf(originalAttribute)] = newAttribute;
332347
}
333348

@@ -345,7 +360,7 @@ internal void SetValue(string key, string? value, bool? isDirty, bool enforceBus
345360
| Create new attribute value
346361
\-----------------------------------------------------------------------------------------------------------------------*/
347362
else {
348-
Add(new AttributeValue(key, value, isDirty ?? true, enforceBusinessLogic, version));
363+
Add(new AttributeValue(key, value, isDirty ?? true, enforceBusinessLogic, version, isExtendedAttribute));
349364
}
350365

351366
}
@@ -361,8 +376,8 @@ internal void SetValue(string key, string? value, bool? isDirty, bool enforceBus
361376
/// <para>
362377
/// If a settable property is available corresponding to the <see cref="AttributeValue.Key"/>, the call should be routed
363378
/// through that to ensure local business logic is enforced. This is determined by looking for the "__" prefix, which is
364-
/// set by the <see cref="SetValue(String, String, Boolean?, Boolean, DateTime?)"/>'s enforceBusinessLogic parameter. To
365-
/// avoid an infinite loop, internal setters _must_ call this overload.
379+
/// set by the <see cref="SetValue(String, String, Boolean?, Boolean, DateTime?, Boolean?)"/>'s
380+
/// <c>enforceBusinessLogic</c> parameter. To avoid an infinite loop, internal setters <i>must</i> call this overload.
366381
/// </para>
367382
/// <para>
368383
/// Compared to the base implementation, will throw a specific <see cref="ArgumentException"/> error if a duplicate key
@@ -402,8 +417,8 @@ protected override void InsertItem(int index, AttributeValue item) {
402417
/// <remarks>
403418
/// If a settable property is available corresponding to the <see cref="AttributeValue.Key"/>, the call should be routed
404419
/// through that to ensure local business logic is enforced. This is determined by looking for the "__" prefix, which is
405-
/// set by the <see cref="SetValue(String, String, Boolean?, Boolean, DateTime?)"/>'s enforceBusinessLogic parameter. To
406-
/// avoid an infinite loop, internal setters _must_ call this overload.
420+
/// set by the <see cref="SetValue(String, String, Boolean?, Boolean, DateTime?, Boolean?)"/>'s
421+
/// <c>enforceBusinessLogic</c> parameter. To avoid an infinite loop, internal setters <i>must</i> call this overload.
407422
/// </remarks>
408423
/// <param name="index">The location that the <see cref="AttributeValue"/> should be set.</param>
409424
/// <param name="item">The <see cref="AttributeValue"/> object which is being inserted.</param>
@@ -424,8 +439,8 @@ protected override void SetItem(int index, AttributeValue item) {
424439
/// <remarks>
425440
/// If a settable property is available corresponding to the <see cref="AttributeValue.Key"/>, the call should be routed
426441
/// through that to ensure local business logic is enforced. This is determined by looking for the "__" prefix, which is
427-
/// set by the <see cref="SetValue(String, String, Boolean?, Boolean, DateTime?)"/>'s enforceBusinessLogic parameter. To
428-
/// avoid an infinite loop, internal setters _must_ call this overload.
442+
/// set by the <see cref="SetValue(String, String, Boolean?, Boolean, DateTime?, Boolean?)"/>'s
443+
/// <c>enforceBusinessLogic</c> parameter. To avoid an infinite loop, internal setters <i>must</i> call this overload.
429444
/// </remarks>
430445
/// <param name="originalAttribute">The <see cref="AttributeValue"/> object which is being inserted.</param>
431446
/// <param name="settableAttribute">

0 commit comments

Comments
 (0)