DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Static Public Member Functions | Static Private Member Functions | List of all members
Deveel.Data.Configuration.ConfigurationExtensions Class Reference

Static Public Member Functions

static IEnumerable< string > GetKeys (this IConfiguration config)
 
static IEnumerable< object > GetValues (this IConfiguration config, ConfigurationLevel level)
 
static object GetValue (this IConfiguration config, string keyName)
 
static object GetValue (this IConfiguration config, string keyName, object defaultValue)
 
static T GetValue< T > (this IConfiguration config, string keyName)
 
static T GetValue< T > (this IConfiguration config, string keyName, T defaultValue)
 
static string GetString (this IConfiguration config, string propertyKey)
 
static string GetString (this IConfiguration config, string propertyKey, string defaultValue)
 
static byte GetByte (this IConfiguration config, string propertyKey)
 
static byte GetByte (this IConfiguration config, string propertyKey, byte defaultValue)
 
static sbyte GetSByte (this IConfiguration config, string propertyKey, sbyte defaultValue)
 
static short GetInt16 (this IConfiguration config, string propertyKey)
 
static short GetInt16 (this IConfiguration config, string propertyKey, short defaultValue)
 
static ushort GetUInt16 (this IConfiguration config, string propertyKey)
 
static ushort GetUInt16 (this IConfiguration config, string propertyKey, ushort defaultValue)
 
static int GetInt32 (this IConfiguration config, string propertyKey)
 
static int GetInt32 (this IConfiguration config, string propertyKey, int defaultValue)
 
static uint GetUInt32 (this IConfiguration config, string propertyKey)
 
static uint GetUInt32 (this IConfiguration config, string propertyKey, uint defaultValue)
 
static long GetInt64 (this IConfiguration config, string propertyKey)
 
static long GetInt64 (this IConfiguration config, string propertyKey, long defaultValue)
 
static ulong GetUInt64 (this IConfiguration config, string propertyKey)
 
static ulong GetUInt64 (this IConfiguration config, string propertyKey, ulong defaultValue)
 
static bool GetBoolean (this IConfiguration config, string propertyKey)
 
static bool GetBoolean (this IConfiguration config, string propertyKey, bool defaultValue)
 
static float GetSingle (this IConfiguration config, string propertyKey)
 
static float GetSingle (this IConfiguration config, string propertyKey, float defaultValue)
 
static double GetDouble (this IConfiguration config, string propertyKey)
 
static double GetDouble (this IConfiguration config, string propertyKey, double defaultValue)
 
static void Load (this IConfiguration config, IConfigSource source)
 
static void Load (this IConfiguration config, IConfigFormatter formatter)
 
static void Load (this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
 
static void Load (this IConfiguration config, string fileName, IConfigFormatter formatter)
 
static void Load (this IConfiguration config, string fileName)
 
static void Load (this IConfiguration config, Stream inputStream, IConfigFormatter formatter)
 
static void Load (this IConfiguration config, Stream inputStream)
 
static void Save (this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
 
static void Save (this IConfiguration config, IConfigSource source, ConfigurationLevel level, IConfigFormatter formatter)
 
static void Save (this IConfiguration config, IConfigFormatter formatter)
 
static void Save (this IConfiguration config, ConfigurationLevel level, IConfigFormatter formatter)
 
static void Save (this IConfiguration config)
 
static void Save (this IConfiguration config, ConfigurationLevel level)
 
static void Save (this IConfiguration config, string fileName)
 
static void Save (this IConfiguration config, ConfigurationLevel level, string fileName)
 
static void Save (this IConfiguration config, string fileName, IConfigFormatter formatter)
 
static void Save (this IConfiguration config, ConfigurationLevel level, string fileName, IConfigFormatter formatter)
 
static void Save (this IConfiguration config, Stream outputStream)
 
static void Save (this IConfiguration config, ConfigurationLevel level, Stream outputStream)
 
static void Save (this IConfiguration config, Stream outputStream, IConfigFormatter formatter)
 
static void Save (this IConfiguration config, ConfigurationLevel level, Stream outputStream, IConfigFormatter formatter)
 
static IConfiguration MergeWith (this IConfiguration configuration, IConfiguration other)
 

Static Private Member Functions

static T ToType< T > (object value)
 
static T ConvertToEnum< T > (object value)
 
static object ConvertToBoolean (string value)
 

Detailed Description

Definition at line 24 of file ConfigurationExtensions.cs.

Member Function Documentation

static object Deveel.Data.Configuration.ConfigurationExtensions.ConvertToBoolean ( string  value)
inlinestaticprivate

Definition at line 92 of file ConfigurationExtensions.cs.

92  {
93  if (String.Equals(value, "true", StringComparison.OrdinalIgnoreCase) ||
94  String.Equals(value, "enabled", StringComparison.OrdinalIgnoreCase) ||
95  String.Equals(value, "1") ||
96  String.Equals(value, "on", StringComparison.OrdinalIgnoreCase))
97  return true;
98  if (String.Equals(value, "false", StringComparison.OrdinalIgnoreCase) ||
99  String.Equals(value, "disabled", StringComparison.OrdinalIgnoreCase) ||
100  String.Equals(value, "0") ||
101  String.Equals(value, "off"))
102  return false;
103 
104  throw new InvalidCastException();
105  }
A long string in the system.
static T Deveel.Data.Configuration.ConfigurationExtensions.ConvertToEnum< T > ( object  value)
inlinestaticprivate

Definition at line 78 of file ConfigurationExtensions.cs.

78  {
79  if (value is int ||
80  value is short ||
81  value is long ||
82  value is byte)
83  return (T)value;
84 
85  if (value == null)
86  return default(T);
87 
88  var s = value.ToString();
89  return (T)Enum.Parse(typeof(T), s, true);
90  }
static bool Deveel.Data.Configuration.ConfigurationExtensions.GetBoolean ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 190 of file ConfigurationExtensions.cs.

190  {
191  return GetBoolean(config, propertyKey, false);
192  }
static bool GetBoolean(this IConfiguration config, string propertyKey)
static bool Deveel.Data.Configuration.ConfigurationExtensions.GetBoolean ( this IConfiguration  config,
string  propertyKey,
bool  defaultValue 
)
inlinestatic

Definition at line 194 of file ConfigurationExtensions.cs.

194  {
195  return config.GetValue(propertyKey, defaultValue);
196  }
static byte Deveel.Data.Configuration.ConfigurationExtensions.GetByte ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 123 of file ConfigurationExtensions.cs.

123  {
124  return GetByte(config, propertyKey, 0);
125  }
static byte GetByte(this IConfiguration config, string propertyKey)
static byte Deveel.Data.Configuration.ConfigurationExtensions.GetByte ( this IConfiguration  config,
string  propertyKey,
byte  defaultValue 
)
inlinestatic

Definition at line 127 of file ConfigurationExtensions.cs.

127  {
128  return config.GetValue(propertyKey, defaultValue);
129  }
static double Deveel.Data.Configuration.ConfigurationExtensions.GetDouble ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 206 of file ConfigurationExtensions.cs.

206  {
207  return GetDouble(config, propertyKey, 0);
208  }
static double GetDouble(this IConfiguration config, string propertyKey)
static double Deveel.Data.Configuration.ConfigurationExtensions.GetDouble ( this IConfiguration  config,
string  propertyKey,
double  defaultValue 
)
inlinestatic

Definition at line 210 of file ConfigurationExtensions.cs.

210  {
211  return config.GetValue<double>(propertyKey, defaultValue);
212  }
static short Deveel.Data.Configuration.ConfigurationExtensions.GetInt16 ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 136 of file ConfigurationExtensions.cs.

136  {
137  return GetInt16(config, propertyKey, 0);
138  }
static short GetInt16(this IConfiguration config, string propertyKey)
static short Deveel.Data.Configuration.ConfigurationExtensions.GetInt16 ( this IConfiguration  config,
string  propertyKey,
short  defaultValue 
)
inlinestatic

Definition at line 140 of file ConfigurationExtensions.cs.

140  {
141  return config.GetValue<short>(propertyKey, defaultValue);
142  }
static int Deveel.Data.Configuration.ConfigurationExtensions.GetInt32 ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 154 of file ConfigurationExtensions.cs.

154  {
155  return GetInt32(config, propertyKey, 0);
156  }
static int GetInt32(this IConfiguration config, string propertyKey)
static int Deveel.Data.Configuration.ConfigurationExtensions.GetInt32 ( this IConfiguration  config,
string  propertyKey,
int  defaultValue 
)
inlinestatic

Definition at line 158 of file ConfigurationExtensions.cs.

158  {
159  return config.GetValue(propertyKey, defaultValue);
160  }
static long Deveel.Data.Configuration.ConfigurationExtensions.GetInt64 ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 172 of file ConfigurationExtensions.cs.

172  {
173  return GetInt64(config, propertyKey, 0);
174  }
static long GetInt64(this IConfiguration config, string propertyKey)
static long Deveel.Data.Configuration.ConfigurationExtensions.GetInt64 ( this IConfiguration  config,
string  propertyKey,
long  defaultValue 
)
inlinestatic

Definition at line 176 of file ConfigurationExtensions.cs.

176  {
177  return config.GetValue(propertyKey, defaultValue);
178  }
static IEnumerable<string> Deveel.Data.Configuration.ConfigurationExtensions.GetKeys ( this IConfiguration  config)
inlinestatic

Definition at line 27 of file ConfigurationExtensions.cs.

27  {
28  return config.GetKeys(ConfigurationLevel.Current);
29  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static sbyte Deveel.Data.Configuration.ConfigurationExtensions.GetSByte ( this IConfiguration  config,
string  propertyKey,
sbyte  defaultValue 
)
inlinestatic

Definition at line 132 of file ConfigurationExtensions.cs.

132  {
133  return config.GetValue(propertyKey, defaultValue);
134  }
static float Deveel.Data.Configuration.ConfigurationExtensions.GetSingle ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 198 of file ConfigurationExtensions.cs.

198  {
199  return GetSingle(config, propertyKey, 0);
200  }
static float GetSingle(this IConfiguration config, string propertyKey)
static float Deveel.Data.Configuration.ConfigurationExtensions.GetSingle ( this IConfiguration  config,
string  propertyKey,
float  defaultValue 
)
inlinestatic

Definition at line 202 of file ConfigurationExtensions.cs.

202  {
203  return config.GetValue(propertyKey, defaultValue);
204  }
static string Deveel.Data.Configuration.ConfigurationExtensions.GetString ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 115 of file ConfigurationExtensions.cs.

115  {
116  return GetString(config, propertyKey, null);
117  }
static string GetString(this IConfiguration config, string propertyKey)
static string Deveel.Data.Configuration.ConfigurationExtensions.GetString ( this IConfiguration  config,
string  propertyKey,
string  defaultValue 
)
inlinestatic

Definition at line 119 of file ConfigurationExtensions.cs.

119  {
120  return config.GetValue(propertyKey, defaultValue);
121  }
static ushort Deveel.Data.Configuration.ConfigurationExtensions.GetUInt16 ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 145 of file ConfigurationExtensions.cs.

145  {
146  return GetUInt16(config, propertyKey, 0);
147  }
static ushort GetUInt16(this IConfiguration config, string propertyKey)
static ushort Deveel.Data.Configuration.ConfigurationExtensions.GetUInt16 ( this IConfiguration  config,
string  propertyKey,
ushort  defaultValue 
)
inlinestatic

Definition at line 150 of file ConfigurationExtensions.cs.

150  {
151  return config.GetValue(propertyKey, defaultValue);
152  }
static uint Deveel.Data.Configuration.ConfigurationExtensions.GetUInt32 ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 163 of file ConfigurationExtensions.cs.

163  {
164  return GetUInt32(config, propertyKey, 0);
165  }
static uint GetUInt32(this IConfiguration config, string propertyKey)
static uint Deveel.Data.Configuration.ConfigurationExtensions.GetUInt32 ( this IConfiguration  config,
string  propertyKey,
uint  defaultValue 
)
inlinestatic

Definition at line 168 of file ConfigurationExtensions.cs.

168  {
169  return config.GetValue(propertyKey, defaultValue);
170  }
static ulong Deveel.Data.Configuration.ConfigurationExtensions.GetUInt64 ( this IConfiguration  config,
string  propertyKey 
)
inlinestatic

Definition at line 181 of file ConfigurationExtensions.cs.

181  {
182  return GetUInt64(config, propertyKey, 0);
183  }
static ulong GetUInt64(this IConfiguration config, string propertyKey)
static ulong Deveel.Data.Configuration.ConfigurationExtensions.GetUInt64 ( this IConfiguration  config,
string  propertyKey,
ulong  defaultValue 
)
inlinestatic

Definition at line 186 of file ConfigurationExtensions.cs.

186  {
187  return config.GetValue(propertyKey, defaultValue);
188  }
static object Deveel.Data.Configuration.ConfigurationExtensions.GetValue ( this IConfiguration  config,
string  keyName 
)
inlinestatic

Definition at line 42 of file ConfigurationExtensions.cs.

42  {
43  return GetValue(config, keyName, null);
44  }
static object GetValue(this IConfiguration config, string keyName)
static object Deveel.Data.Configuration.ConfigurationExtensions.GetValue ( this IConfiguration  config,
string  keyName,
object  defaultValue 
)
inlinestatic

Definition at line 46 of file ConfigurationExtensions.cs.

46  {
47  var value = config.GetValue(keyName);
48  if (value == null)
49  return defaultValue;
50 
51  return value;
52  }
static T Deveel.Data.Configuration.ConfigurationExtensions.GetValue< T > ( this IConfiguration  config,
string  keyName 
)
inlinestatic

Definition at line 54 of file ConfigurationExtensions.cs.

54  {
55  return GetValue<T>(config, keyName, default(T));
56  }
static T GetValue< T >(this IConfiguration config, string keyName)
static T Deveel.Data.Configuration.ConfigurationExtensions.GetValue< T > ( this IConfiguration  config,
string  keyName,
defaultValue 
)
inlinestatic

Definition at line 107 of file ConfigurationExtensions.cs.

107  {
108  var value = config.GetValue(keyName);
109  if (value == null)
110  return defaultValue;
111 
112  return ToType<T>(value);
113  }
static IEnumerable<object> Deveel.Data.Configuration.ConfigurationExtensions.GetValues ( this IConfiguration  config,
ConfigurationLevel  level 
)
inlinestatic

Definition at line 31 of file ConfigurationExtensions.cs.

31  {
32  var keys = config.GetKeys(level);
33  var values = keys.Select(x => config.GetValue(x))
34  .Where(value => value != null)
35  .ToList();
36 
37  return values.ToArray();
38  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Load ( this IConfiguration  config,
IConfigSource  source 
)
inlinestatic

Definition at line 220 of file ConfigurationExtensions.cs.

220  {
221  config.Load(source, new PropertiesConfigFormatter());
222  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Load ( this IConfiguration  config,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 224 of file ConfigurationExtensions.cs.

224  {
225  if (config.Source == null)
226  throw new InvalidOperationException("Source was not configured");
227 
228  config.Load(config.Source, formatter);
229  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Load ( this IConfiguration  config,
IConfigSource  source,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 231 of file ConfigurationExtensions.cs.

231  {
232  try {
233  if (source != null) {
234  using (var sourceStream = source.InputStream) {
235  if (!sourceStream.CanRead)
236  throw new ArgumentException("The input stream cannot be read.");
237 
238  sourceStream.Seek(0, SeekOrigin.Begin);
239  formatter.LoadInto(config, sourceStream);
240  }
241  }
242  } catch (Exception ex) {
243  throw new DatabaseConfigurationException(String.Format("Cannot load data from source"), ex);
244  }
245  }
A long string in the system.
static void Deveel.Data.Configuration.ConfigurationExtensions.Load ( this IConfiguration  config,
string  fileName,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 248 of file ConfigurationExtensions.cs.

248  {
249  config.Load(new FileConfigSource(fileName), formatter);
250  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Load ( this IConfiguration  config,
string  fileName 
)
inlinestatic

Definition at line 252 of file ConfigurationExtensions.cs.

252  {
253  config.Load(fileName, new PropertiesConfigFormatter());
254  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Load ( this IConfiguration  config,
Stream  inputStream,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 257 of file ConfigurationExtensions.cs.

257  {
258  config.Load(new StreamConfigSource(inputStream), formatter);
259  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Load ( this IConfiguration  config,
Stream  inputStream 
)
inlinestatic

Definition at line 261 of file ConfigurationExtensions.cs.

261  {
262  config.Load(inputStream, new PropertiesConfigFormatter());
263  }
static IConfiguration Deveel.Data.Configuration.ConfigurationExtensions.MergeWith ( this IConfiguration  configuration,
IConfiguration  other 
)
inlinestatic

Definition at line 338 of file ConfigurationExtensions.cs.

338  {
339  var newConfig = new Configuration(configuration);
340  foreach (var pair in other) {
341  newConfig.SetValue(pair.Key, pair.Value);
342  }
343 
344  return newConfig;
345  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
IConfigSource  source,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 265 of file ConfigurationExtensions.cs.

265  {
266  Save(config, source, ConfigurationLevel.Current, formatter);
267  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
IConfigSource  source,
ConfigurationLevel  level,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 269 of file ConfigurationExtensions.cs.

269  {
270  try {
271  using (var outputStream = source.OutputStream) {
272  if (!outputStream.CanWrite)
273  throw new InvalidOperationException("The destination source cannot be written.");
274 
275  outputStream.Seek(0, SeekOrigin.Begin);
276  formatter.SaveFrom(config, level, outputStream);
277  outputStream.Flush();
278  }
279  } catch (Exception ex) {
280  throw new DatabaseConfigurationException("Cannot save the configuration.", ex);
281  }
282  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 284 of file ConfigurationExtensions.cs.

284  {
285  Save(config, ConfigurationLevel.Current, formatter);
286  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
ConfigurationLevel  level,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 288 of file ConfigurationExtensions.cs.

288  {
289  if (config.Source == null)
290  throw new DatabaseConfigurationException("The source was not configured in the configuration.");
291 
292  config.Save(config.Source, level, formatter);
293  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config)
inlinestatic

Definition at line 295 of file ConfigurationExtensions.cs.

295  {
296  Save(config, ConfigurationLevel.Current);
297  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
ConfigurationLevel  level 
)
inlinestatic

Definition at line 299 of file ConfigurationExtensions.cs.

299  {
300  Save(config, level, new PropertiesConfigFormatter());
301  }
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
string  fileName 
)
inlinestatic

Definition at line 304 of file ConfigurationExtensions.cs.

304  {
305  Save(config, ConfigurationLevel.Current, fileName);
306  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
ConfigurationLevel  level,
string  fileName 
)
inlinestatic

Definition at line 308 of file ConfigurationExtensions.cs.

308  {
309  Save(config, level, fileName, new PropertiesConfigFormatter());
310  }
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
string  fileName,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 312 of file ConfigurationExtensions.cs.

312  {
313  Save(config, ConfigurationLevel.Current, fileName, formatter);
314  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
ConfigurationLevel  level,
string  fileName,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 315 of file ConfigurationExtensions.cs.

315  {
316  config.Save(new FileConfigSource(fileName), level, formatter);
317  }
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
Stream  outputStream 
)
inlinestatic

Definition at line 320 of file ConfigurationExtensions.cs.

320  {
321  Save(config, ConfigurationLevel.Current, outputStream);
322  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
ConfigurationLevel  level,
Stream  outputStream 
)
inlinestatic

Definition at line 324 of file ConfigurationExtensions.cs.

324  {
325  Save(config, level, outputStream, new PropertiesConfigFormatter());
326  }
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
Stream  outputStream,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 328 of file ConfigurationExtensions.cs.

328  {
329  Save(config, ConfigurationLevel.Current, outputStream, formatter);
330  }
ConfigurationLevel
Defines the level of configuration settings to save or read
static void Save(this IConfiguration config, IConfigSource source, IConfigFormatter formatter)
static void Deveel.Data.Configuration.ConfigurationExtensions.Save ( this IConfiguration  config,
ConfigurationLevel  level,
Stream  outputStream,
IConfigFormatter  formatter 
)
inlinestatic

Definition at line 332 of file ConfigurationExtensions.cs.

332  {
333  config.Save(new StreamConfigSource(outputStream), level, formatter);
334  }
static T Deveel.Data.Configuration.ConfigurationExtensions.ToType< T > ( object  value)
inlinestaticprivate

Definition at line 58 of file ConfigurationExtensions.cs.

58  {
59  if (value == null)
60  return default(T);
61 
62  if (value is T)
63  return (T)value;
64 
65  if (typeof(T) == typeof(bool) &&
66  value is string)
67  return (T)ConvertToBoolean((string)value);
68 
69  if (typeof(T).IsEnum)
70  return ConvertToEnum<T>(value);
71 
72  if (!(value is IConvertible))
73  throw new InvalidCastException();
74 
75  return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
76  }

The documentation for this class was generated from the following file: