asp.net MVC动态配置/ui



我有实现IPlugin的插件(IMenuPlugin、IThemePlugin等)。我希望每个插件都能为我的应用程序提供可配置的属性,我的应用将使用这些属性,并为其提供编辑/更新UI。

我的想法是让每个实现都提供一个IEditable列表(由接口定义)。每个可编辑项都将提供一个模板的名称(EditorFor()等)。然后我想枚举所有这些,渲染模板,然后将值发布回控制器,以保存插件的值。

你的想法?现在有类似的东西吗?

我猜这与您的建议类似,但我对措辞感到困惑。

我想说的是,您应该简单地为IPluginProperty创建另一个接口,然后向IPlugin添加一个只读的IPluginPropertys集合。IPluginProperty接口可以有一个属性来为属性提供IPropertyEditor

public interface IPluginEditor
{
    // interface members
}
public interface IPluginProperty
{
    IPluginEditor Editor { get; }
    // Rest of interface members
}
public interface IPlugin
{
    IEnumerable<IPluginProperty> Properties { get; }
    // Rest of interface members
}

最新更新