using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace newtelligence.DasBlog.Runtime{
/// <summary>
/// Loads the storage configuration information from the newtelligence.DasBlog.Storage section in
/// the current config file. And handles the case were such a section does not exist.
/// </summary>
internal static class StorageConfigManager
{
/// <summary>
/// Gets the concrete type based on the specified type in the web.config.
/// </summary>
/// <param name="type">The name of the specified type is used a key to
/// retrieve the actual type.</param>
/// <returns>The type as specified in the database.</returns>
public static Type GetServiceType(Type type)
{
return GetServiceType(type.Name);
}
private static Type GetServiceType(string key)
{
var section = ConfigurationManager.GetSection("newtelligence.DasBlog.Storage") as System.Collections.Specialized.NameValueCollection;
if (section != null && section[key] != null)
{
return Type.GetType(section[key], /* throwOnError */ true, /* ignoreCase */ true);
}
// return default
return null;
}
}
}
|