@@ -68,6 +68,18 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
68
68
return config . Get < T > ( new [ ] { firstKeyPart , secondKeyPart , thirdKeyPart } ) ;
69
69
}
70
70
71
+ /// <summary>
72
+ /// Get a configuration value for the given key.
73
+ /// </summary>
74
+ /// <typeparam name="T">The configuration value type.</typeparam>
75
+ /// <param name="config">The configuration being worked with.</param>
76
+ /// <param name="key">The key</param>
77
+ /// <returns>The configuration value, or the default value for the selected <see typeparamref="T"/>if not found</returns>
78
+ public static T GetValueOrDefault < T > ( this Configuration config , string key )
79
+ {
80
+ return ValueOrDefault ( config . Get < T > ( key ) , default ( T ) ) ;
81
+ }
82
+
71
83
/// <summary>
72
84
/// Get a configuration value for the given key,
73
85
/// or <paramref name="defaultValue" /> if the key is not set.
@@ -76,27 +88,52 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
76
88
/// <param name="config">The configuration being worked with.</param>
77
89
/// <param name="key">The key</param>
78
90
/// <param name="defaultValue">The default value if the key is not set.</param>
79
- /// <returns>The configuration value, or the default. </returns>
80
- public static T GetValueOrDefault < T > ( this Configuration config , string key , T defaultValue = default ( T ) )
91
+ /// <returns>The configuration value, or the default value </returns>
92
+ public static T GetValueOrDefault < T > ( this Configuration config , string key , T defaultValue )
81
93
{
82
94
return ValueOrDefault ( config . Get < T > ( key ) , defaultValue ) ;
83
95
}
84
96
97
+ /// <summary>
98
+ /// Get a configuration value for the given key
99
+ /// </summary>
100
+ /// <typeparam name="T">The configuration value type.</typeparam>
101
+ /// <param name="config">The configuration being worked with.</param>
102
+ /// <param name="key">The key.</param>
103
+ /// <param name="level">The configuration file into which the key should be searched for.</param>
104
+ /// <returns>The configuration value, or the default value for <see typeparamref="T"/> if not found</returns>
105
+ public static T GetValueOrDefault < T > ( this Configuration config , string key , ConfigurationLevel level )
106
+ {
107
+ return ValueOrDefault ( config . Get < T > ( key , level ) , default ( T ) ) ;
108
+ }
109
+
85
110
/// <summary>
86
111
/// Get a configuration value for the given key,
87
112
/// or <paramref name="defaultValue" /> if the key is not set.
88
113
/// </summary>
89
114
/// <typeparam name="T">The configuration value type.</typeparam>
90
- /// <param name="config">The configuration being worked with.</param>
115
+ /// <param name="config">The configuration being worked with.</param>
91
116
/// <param name="key">The key.</param>
92
117
/// <param name="level">The configuration file into which the key should be searched for.</param>
93
118
/// <param name="defaultValue">The selector used to generate a default value if the key is not set.</param>
94
- /// <returns>The configuration value, or the default.</returns>
95
- public static T GetValueOrDefault < T > ( this Configuration config , string key , ConfigurationLevel level , T defaultValue = default ( T ) )
119
+ /// <returns>The configuration value, or the default value .</returns>
120
+ public static T GetValueOrDefault < T > ( this Configuration config , string key , ConfigurationLevel level , T defaultValue )
96
121
{
97
122
return ValueOrDefault ( config . Get < T > ( key , level ) , defaultValue ) ;
98
123
}
99
124
125
+ /// <summary>
126
+ /// Get a configuration value for the given key parts
127
+ /// </summary>
128
+ /// <typeparam name="T">The configuration value type.</typeparam>
129
+ /// <param name="config">The configuration being worked with.</param>
130
+ /// <param name="keyParts">The key parts.</param>
131
+ /// <returns>The configuration value, or the default value for<see typeparamref="T"/> if not found</returns>
132
+ public static T GetValueOrDefault < T > ( this Configuration config , string [ ] keyParts )
133
+ {
134
+ return ValueOrDefault ( config . Get < T > ( keyParts ) , default ( T ) ) ;
135
+ }
136
+
100
137
/// <summary>
101
138
/// Get a configuration value for the given key parts,
102
139
/// or <paramref name="defaultValue" /> if the key is not set.
@@ -105,12 +142,26 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
105
142
/// <param name="config">The configuration being worked with.</param>
106
143
/// <param name="keyParts">The key parts.</param>
107
144
/// <param name="defaultValue">The default value if the key is not set.</param>
108
- /// <returns>The configuration value, or the default.</returns>
109
- public static T GetValueOrDefault < T > ( this Configuration config , string [ ] keyParts , T defaultValue = default ( T ) )
145
+ /// <returns>The configuration value, or the default value .</returns>
146
+ public static T GetValueOrDefault < T > ( this Configuration config , string [ ] keyParts , T defaultValue )
110
147
{
111
148
return ValueOrDefault ( config . Get < T > ( keyParts ) , defaultValue ) ;
112
149
}
113
150
151
+ /// <summary>
152
+ /// Get a configuration value for the given key parts.
153
+ /// </summary>
154
+ /// <typeparam name="T">The configuration value type.</typeparam>
155
+ /// <param name="config">The configuration being worked with.</param>
156
+ /// <param name="firstKeyPart">The first key part.</param>
157
+ /// <param name="secondKeyPart">The second key part.</param>
158
+ /// <param name="thirdKeyPart">The third key part.</param>
159
+ /// <returns>The configuration value, or the default value for the selected <see typeparamref="T"/> if not found</returns>
160
+ public static T GetValueOrDefault < T > ( this Configuration config , string firstKeyPart , string secondKeyPart , string thirdKeyPart )
161
+ {
162
+ return ValueOrDefault ( config . Get < T > ( firstKeyPart , secondKeyPart , thirdKeyPart ) , default ( T ) ) ;
163
+ }
164
+
114
165
/// <summary>
115
166
/// Get a configuration value for the given key parts,
116
167
/// or <paramref name="defaultValue" /> if the key is not set.
@@ -122,7 +173,7 @@ public static ConfigurationEntry<T> Get<T>(this Configuration config, string fir
122
173
/// <param name="thirdKeyPart">The third key part.</param>
123
174
/// <param name="defaultValue">The default value if the key is not set.</param>
124
175
/// <returns>The configuration value, or the default.</returns>
125
- public static T GetValueOrDefault < T > ( this Configuration config , string firstKeyPart , string secondKeyPart , string thirdKeyPart , T defaultValue = default ( T ) )
176
+ public static T GetValueOrDefault < T > ( this Configuration config , string firstKeyPart , string secondKeyPart , string thirdKeyPart , T defaultValue )
126
177
{
127
178
return ValueOrDefault ( config . Get < T > ( firstKeyPart , secondKeyPart , thirdKeyPart ) , defaultValue ) ;
128
179
}
0 commit comments