@@ -172,6 +172,81 @@ private string GetValue(string name, string defaultValue, bool inheritFromParent
172172
173173 }
174174
175+ /*==========================================================================================================================
176+ | METHOD: GET BOOLEAN VALUE
177+ \-------------------------------------------------------------------------------------------------------------------------*/
178+ /// <summary>
179+ /// Gets a named attribute from the Attributes dictionary with a specified default value, an optional setting for enabling
180+ /// of inheritance, and an optional setting for searching through derived topics for values. Return as a boolean.
181+ /// </summary>
182+ /// <param name="name">The string identifier for the <see cref="AttributeValue"/>.</param>
183+ /// <param name="defaultValue">A string value to which to fall back in the case the value is not found.</param>
184+ /// <param name="inheritFromParent">
185+ /// Boolean indicator nothing whether to search through the topic's parents in order to get the value.
186+ /// </param>
187+ /// <param name="inheritFromDerived">
188+ /// Boolean indicator nothing whether to search through any of the topic's <see cref="Topic.DerivedTopic"/> topics in
189+ /// order to get the value.
190+ /// </param>
191+ /// <returns>The string value for the Attribute.</returns>
192+ public bool GetBoolean ( string name , bool defaultValue , bool inheritFromParent = false , bool inheritFromDerived = true ) {
193+ Contract . Requires < ArgumentNullException > ( ! String . IsNullOrWhiteSpace ( name ) ) ;
194+ return Int32 . TryParse (
195+ GetValue ( name , defaultValue ? "1" : "0" , inheritFromParent , ( inheritFromDerived ? 5 : 0 ) ) ,
196+ out var result
197+ ) ? result . Equals ( 1 ) : defaultValue ;
198+ }
199+
200+ /*==========================================================================================================================
201+ | METHOD: GET INTEGER
202+ \-------------------------------------------------------------------------------------------------------------------------*/
203+ /// <summary>
204+ /// Gets a named attribute from the Attributes dictionary with a specified default value, an optional setting for enabling
205+ /// of inheritance, and an optional setting for searching through derived topics for values. Return as a integer.
206+ /// </summary>
207+ /// <param name="name">The string identifier for the <see cref="AttributeValue"/>.</param>
208+ /// <param name="defaultValue">A string value to which to fall back in the case the value is not found.</param>
209+ /// <param name="inheritFromParent">
210+ /// Boolean indicator nothing whether to search through the topic's parents in order to get the value.
211+ /// </param>
212+ /// <param name="inheritFromDerived">
213+ /// Boolean indicator nothing whether to search through any of the topic's <see cref="Topic.DerivedTopic"/> topics in
214+ /// order to get the value.
215+ /// </param>
216+ /// <returns>The string value for the Attribute.</returns>
217+ public int GetInteger ( string name , int defaultValue , bool inheritFromParent = false , bool inheritFromDerived = true ) {
218+ Contract . Requires < ArgumentNullException > ( ! String . IsNullOrWhiteSpace ( name ) ) ;
219+ return Int32 . TryParse (
220+ GetValue ( name , defaultValue . ToString ( ) , inheritFromParent , ( inheritFromDerived ? 5 : 0 ) ) ,
221+ out var result
222+ ) ? result : defaultValue ;
223+ }
224+
225+ /*==========================================================================================================================
226+ | METHOD: GET DATETIME
227+ \-------------------------------------------------------------------------------------------------------------------------*/
228+ /// <summary>
229+ /// Gets a named attribute from the Attributes dictionary with a specified default value, an optional setting for enabling
230+ /// of inheritance, and an optional setting for searching through derived topics for values. Return as a datetime.
231+ /// </summary>
232+ /// <param name="name">The string identifier for the <see cref="AttributeValue"/>.</param>
233+ /// <param name="defaultValue">A string value to which to fall back in the case the value is not found.</param>
234+ /// <param name="inheritFromParent">
235+ /// Boolean indicator nothing whether to search through the topic's parents in order to get the value.
236+ /// </param>
237+ /// <param name="inheritFromDerived">
238+ /// Boolean indicator nothing whether to search through any of the topic's <see cref="Topic.DerivedTopic"/> topics in
239+ /// order to get the value.
240+ /// </param>
241+ /// <returns>The string value for the Attribute.</returns>
242+ public DateTime GetDateTime ( string name , DateTime defaultValue , bool inheritFromParent = false , bool inheritFromDerived = true ) {
243+ Contract . Requires < ArgumentNullException > ( ! String . IsNullOrWhiteSpace ( name ) ) ;
244+ return DateTime . TryParse (
245+ GetValue ( name , defaultValue . ToString ( ) , inheritFromParent , ( inheritFromDerived ? 5 : 0 ) ) ,
246+ out var result
247+ ) ? result : defaultValue ;
248+ }
249+
175250 /*==========================================================================================================================
176251 | METHOD: SET VALUE
177252 \-------------------------------------------------------------------------------------------------------------------------*/
@@ -291,6 +366,102 @@ internal void SetValue(string key, string value, bool? isDirty, bool enforceBusi
291366
292367 }
293368
369+ /*==========================================================================================================================
370+ | METHOD: SET BOOLEAN
371+ \-------------------------------------------------------------------------------------------------------------------------*/
372+ /// <summary>
373+ /// Helper method that either adds a new <see cref="AttributeValue"/> object or updates the value of an existing one,
374+ /// depending on whether that value already exists.
375+ /// </summary>
376+ /// <param name="key">The string identifier for the AttributeValue.</param>
377+ /// <param name="value">The text value for the AttributeValue.</param>
378+ /// <param name="isDirty">
379+ /// Specified whether the value should be marked as <see cref="AttributeValue.IsDirty"/>. By default, it will be marked as
380+ /// dirty if the value is new or has changed from a previous value. By setting this parameter, that behavior is
381+ /// overwritten to accept whatever value is submitted. This can be used, for instance, to prevent an update from being
382+ /// persisted to the data store on <see cref="ITopicRepository.Save(Topic, Boolean, Boolean)"/>.
383+ /// </param>
384+ /// <requires
385+ /// description="The key must be specified for the AttributeValue key/value pair."
386+ /// exception="T:System.ArgumentNullException">
387+ /// !String.IsNullOrWhiteSpace(key)
388+ /// </requires>
389+ /// <requires
390+ /// description="The value must be specified for the AttributeValue key/value pair."
391+ /// exception="T:System.ArgumentNullException">
392+ /// !String.IsNullOrWhiteSpace(value)
393+ /// </requires>
394+ /// <requires
395+ /// description="The key should be an alphanumeric sequence; it should not contain spaces or symbols"
396+ /// exception="T:System.ArgumentException">
397+ /// !value.Contains(" ")
398+ /// </requires>
399+ public void SetBoolean ( string key , bool value , bool ? isDirty = null ) => SetValue ( key , value ? "1" : "0" , isDirty , true ) ;
400+
401+ /*==========================================================================================================================
402+ | METHOD: SET INTEGER
403+ \-------------------------------------------------------------------------------------------------------------------------*/
404+ /// <summary>
405+ /// Helper method that either adds a new <see cref="AttributeValue"/> object or updates the value of an existing one,
406+ /// depending on whether that value already exists.
407+ /// </summary>
408+ /// <param name="key">The string identifier for the AttributeValue.</param>
409+ /// <param name="value">The text value for the AttributeValue.</param>
410+ /// <param name="isDirty">
411+ /// Specified whether the value should be marked as <see cref="AttributeValue.IsDirty"/>. By default, it will be marked as
412+ /// dirty if the value is new or has changed from a previous value. By setting this parameter, that behavior is
413+ /// overwritten to accept whatever value is submitted. This can be used, for instance, to prevent an update from being
414+ /// persisted to the data store on <see cref="ITopicRepository.Save(Topic, Boolean, Boolean)"/>.
415+ /// </param>
416+ /// <requires
417+ /// description="The key must be specified for the AttributeValue key/value pair."
418+ /// exception="T:System.ArgumentNullException">
419+ /// !String.IsNullOrWhiteSpace(key)
420+ /// </requires>
421+ /// <requires
422+ /// description="The value must be specified for the AttributeValue key/value pair."
423+ /// exception="T:System.ArgumentNullException">
424+ /// !String.IsNullOrWhiteSpace(value)
425+ /// </requires>
426+ /// <requires
427+ /// description="The key should be an alphanumeric sequence; it should not contain spaces or symbols"
428+ /// exception="T:System.ArgumentException">
429+ /// !value.Contains(" ")
430+ /// </requires>
431+ public void SetInteger ( string key , int value , bool ? isDirty = null ) => SetValue ( key , value . ToString ( ) , isDirty , true ) ;
432+
433+ /*==========================================================================================================================
434+ | METHOD: SET DATETIME
435+ \-------------------------------------------------------------------------------------------------------------------------*/
436+ /// <summary>
437+ /// Helper method that either adds a new <see cref="AttributeValue"/> object or updates the value of an existing one,
438+ /// depending on whether that value already exists.
439+ /// </summary>
440+ /// <param name="key">The string identifier for the AttributeValue.</param>
441+ /// <param name="value">The text value for the AttributeValue.</param>
442+ /// <param name="isDirty">
443+ /// Specified whether the value should be marked as <see cref="AttributeValue.IsDirty"/>. By default, it will be marked as
444+ /// dirty if the value is new or has changed from a previous value. By setting this parameter, that behavior is
445+ /// overwritten to accept whatever value is submitted. This can be used, for instance, to prevent an update from being
446+ /// persisted to the data store on <see cref="ITopicRepository.Save(Topic, Boolean, Boolean)"/>.
447+ /// </param>
448+ /// <requires
449+ /// description="The key must be specified for the AttributeValue key/value pair."
450+ /// exception="T:System.ArgumentNullException">
451+ /// !String.IsNullOrWhiteSpace(key)
452+ /// </requires>
453+ /// <requires
454+ /// description="The value must be specified for the AttributeValue key/value pair."
455+ /// exception="T:System.ArgumentNullException">
456+ /// !String.IsNullOrWhiteSpace(value)
457+ /// </requires>
458+ /// <requires
459+ /// description="The key should be an alphanumeric sequence; it should not contain spaces or symbols"
460+ /// exception="T:System.ArgumentException">
461+ /// !value.Contains(" ")
462+ /// </requires>
463+ public void SetDateTime ( string key , DateTime value , bool ? isDirty = null ) => SetValue ( key , value . ToString ( ) , isDirty , true ) ;
464+
294465 /*==========================================================================================================================
295466 | OVERRIDE: INSERT ITEM
296467 \-------------------------------------------------------------------------------------------------------------------------*/
0 commit comments