简体   繁体   中英

MVC Plugin Architecture and Entityframework

I am building an application as follows;

There is only one table in the database and the domain as a base entity (Ipage) which represents an html page when viewed by the public. Inheriting that is an entity (IPageBuilder) which contains the information required to build the page, admin view. The concept is to prerender pages on the admin side and store everything in a single table. Below is the interface class for these two entities:

public interface IPage
{
    string BodyPreRender { get; set; }
    string ExcerptPreRender { get; set; }
    int ID { get; set; }
    bool IsPublished { get; set; }
    string Key { get; set; }
    string MetaTagsPreRender { get; set; }
    int Order { get; set; }
    string PageKey { get; set; }
}

public interface IPageBuild : IPage
{
    string Author { get; set; }
    string CreatedBy { get; set; }
    DateTime CreatedOn { get; set; }
    string Description { get; set; }
    string EditListItemPreRender { get; set; }
    string Html { get; set; }
    string Keywords { get; set; }
    string Language { get; set; }
    string MetaDescription { get; set; }
    DateTime? ReleasedOn { get; set; }
    string Title { get; set; }
    int Version { get; set; }
}

I have created an plugin manager which will discover a dll containing a plugin descriptor interface and create a list of plugins for use in the application. Here is the plug descriptor interface:

internal interface IPluginDescriptor
{
    Assembly Assembly { get; }
    string Author { get; }
    string AuthorUrl { get; }
    Type DomainType { get; }
    PlugInFactories Factories { get; }
    void Install();
    string Key { get; }
    string MenuName { get; }
    string Name { get; }
    string PageKey { get; }
    PluginRoute Route { get; }
    string SupportUrl { get; }
    void Uninstall();
    Version Version { get; }
}

What I would like to do is create a domain object within the plugin, which is based upon the base page builder class, thus allowing the plugin to create and store any web page it wants, such as:

public class Foo : IPageBuild
{
    public string FooInfo { get; set; }
}

In the application startup I would like to run a method in my plugin descriptor, call it install(), which will check the data table and see if it has a column for FooInfo. So what is best method to accomplish this task? Thanks in advance.

In addition I have setup the columns in the table to be formatted as:

  • Page_BodyPreRender,
  • Page_ExcerptPreRender,
  • etc.,
  • Foo_FooInfo

I am using

  • .Net Framework 4.0
  • Entity Framework 4.3.1.0
  • System.Data.SqlServerCe.Entity4.0.0.0
  • System.Web.Mvc 3.0.0.0

Some time has gone by since I asked this question, so I thought I would attempt to answer it myself. Basically I moved onto NHibernate to solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM