@@ -96,6 +96,44 @@ out var result
9696 ) ? result : defaultValue ;
9797 }
9898
99+ /*==========================================================================================================================
100+ | METHOD: GET DOUBLE
101+ \-------------------------------------------------------------------------------------------------------------------------*/
102+ /// <summary>
103+ /// Gets a named attribute from the Attributes dictionary with a specified default value, an optional setting for enabling
104+ /// of inheritance, and an optional setting for searching through derived topics for values. Return as a double.
105+ /// </summary>
106+ /// <param name="attributes">The instance of the <see cref="AttributeValueCollection"/> this extension is bound to.</param>
107+ /// <param name="name">The string identifier for the <see cref="AttributeValue"/>.</param>
108+ /// <param name="defaultValue">A string value to which to fall back in the case the value is not found.</param>
109+ /// <param name="inheritFromParent">
110+ /// Boolean indicator nothing whether to search through the topic's parents in order to get the value.
111+ /// </param>
112+ /// <param name="inheritFromDerived">
113+ /// Boolean indicator nothing whether to search through any of the topic's <see cref="Topic.DerivedTopic"/> topics in
114+ /// order to get the value.
115+ /// </param>
116+ /// <returns>The value for the attribute as a double.</returns>
117+ public static double GetDouble (
118+ this AttributeValueCollection attributes ,
119+ string name ,
120+ double defaultValue ,
121+ bool inheritFromParent = false ,
122+ bool inheritFromDerived = true
123+ ) {
124+ Contract . Requires ( attributes ) ;
125+ Contract . Requires < ArgumentNullException > ( ! String . IsNullOrWhiteSpace ( name ) ) ;
126+ return Double . TryParse (
127+ attributes . GetValue (
128+ name ,
129+ defaultValue . ToString ( CultureInfo . InvariantCulture ) ,
130+ inheritFromParent ,
131+ inheritFromDerived ? 5 : 0
132+ ) ,
133+ out var result
134+ ) ? result : defaultValue ;
135+ }
136+
99137 /*==========================================================================================================================
100138 | METHOD: GET DATETIME
101139 \-------------------------------------------------------------------------------------------------------------------------*/
0 commit comments