简体   繁体   English

MVC插件架构和实体框架

[英]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. 数据库中只有一个表,该域作为基础实体(Ipage),当公众查看时,该实体代表一个html页面。 Inheriting that is an entity (IPageBuilder) which contains the information required to build the page, admin view. 继承是一个实体(IPageBuilder),其中包含构建页面admin视图所需的信息。 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. 我创建了一个插件管理器,它将发现一个包含插件描述符接口的dll,并创建一个供应用程序使用的插件列表。 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. 在应用程序启动时,我想在插件描述符中运行一个方法,将其称为install(),它将检查数据表并查看其是否包含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_BodyPreRender,
  • Page_ExcerptPreRender, Page_ExcerptPreRender,
  • etc., 等等。,
  • Foo_FooInfo Foo_FooInfo

I am using 我在用

  • .Net Framework 4.0 .Net Framework 4.0
  • Entity Framework 4.3.1.0 实体框架4.3.1.0
  • System.Data.SqlServerCe.Entity4.0.0.0 System.Data.SqlServerCe.Entity4.0.0.0
  • System.Web.Mvc 3.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. 基本上,我转向NHibernate来解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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