refactoring
This commit is contained in:
parent
8cec6d44e2
commit
7fc21f1056
25 changed files with 179 additions and 335 deletions
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Configuration;
|
||||
using System.Reflection;
|
||||
using System.Collections.Specialized;
|
||||
using Yavsc.Model.Blogs.Configuration;
|
||||
|
||||
namespace Yavsc.Model.Blogs
|
||||
{
|
||||
|
|
@ -17,22 +16,17 @@ namespace Yavsc.Model.Blogs
|
|||
/// <returns>The provider.</returns>
|
||||
public static BlogProvider GetProvider ()
|
||||
{
|
||||
BlogProvidersConfigurationSection config = ConfigurationManager.GetSection ("system.web/blog") as BlogProvidersConfigurationSection;
|
||||
DataProviderConfigurationSection config = ConfigurationManager.GetSection ("system.web/blog") as DataProviderConfigurationSection;
|
||||
if (config == null)
|
||||
throw new ConfigurationErrorsException("The configuration bloc for the blog provider was not found");
|
||||
BlogProviderConfigurationElement celt =
|
||||
config.Providers.GetElement (config.DefaultProvider);
|
||||
ProviderSettings celt =
|
||||
config.Providers[config.DefaultProvider];
|
||||
if (config == null)
|
||||
throw new ConfigurationErrorsException("The default blog provider was not found");
|
||||
ConstructorInfo ci = Type.GetType (celt.Type).GetConstructor (Type.EmptyTypes);
|
||||
BlogProvider bp = ci.Invoke (Type.EmptyTypes) as BlogProvider;
|
||||
NameValueCollection c = new NameValueCollection ();
|
||||
c.Add ("name", celt.Name);
|
||||
c.Add ("type", celt.Type);
|
||||
c.Add ("connectionStringName", celt.ConnectionStringName);
|
||||
c.Add ("description", celt.Description);
|
||||
c.Add ("applicationName", celt.ApplicationName);
|
||||
bp.Initialize (celt.Name, c);
|
||||
bp.Initialize (celt.Name, celt.Parameters);
|
||||
return bp;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue