* Web.csproj: * Web.config: * Blog.cs: * Index.aspx: * BBCodeHelper.cs: * Comment.cs: * yavscModel.csproj: * BlogEntry.cs: * UserPost.aspx: * UserPosts.aspx: * Estimate.cs: * RemovePost.aspx: * TitleNotFound.aspx: * BlogProvider.cs: * AccountController.cs: * BlogsApiController.cs: * WorkFlowController.cs: * BlogEditEntryModel.cs: * FindBlogEntryFlags.cs: * BlogEntryCollection.cs: * Comment.cs: * BlogEditCommentModel.cs: * NpgsqlBlogProvider.cs: * NpgsqlContentProvider.cs: * BlogEntry.cs: * NpgsqlBlogProvider.csproj: * NpgsqlMembershipProvider.cs: * FindBlogEntryFlags.cs: * BlogEntryCollection.cs: * BlogHelper.cs: refactoring: moving code from NpgsqlBlogProvider to yavscModel.Blogs * BlogManager.cs: NpgsqlBlogProvider/BlogHelper.cs * BlogsController.cs: a successfull confirmed removal * Blog.cs: refactoring
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.Reflection;
|
|
using System.Collections.Specialized;
|
|
using Npgsql.Web.Blog.Configuration;
|
|
using yavscModel.Blogs;
|
|
|
|
namespace Npgsql.Web.Blog
|
|
{
|
|
public static class BlogHelper
|
|
{
|
|
public static BlogProvider GetProvider ()
|
|
{
|
|
BlogProvidersConfigurationSection config = ConfigurationManager.GetSection ("system.web/blog") as BlogProvidersConfigurationSection;
|
|
if (config == null)
|
|
throw new ConfigurationErrorsException("The configuration bloc for the blog provider was not found");
|
|
BlogProviderConfigurationElement celt =
|
|
config.Providers.GetElement (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);
|
|
return bp;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|