开发者

asp.net MVC dynamic configuration/ui

开发者 https://www.devze.com 2023-03-08 16:35 出处:网络
I have plugins that implement IPlugin (IMenuPlugin, IThemePlugin, etc). I want the ability to have a each plugin provide my application with configurable properties that my application will consume an

I have plugins that implement IPlugin (IMenuPlugin, IThemePlugin, etc). I want the ability to have a each plugin provide my application with configurable properties that my application will consume and provide an edit/update UI for.

My thoughts is to have each implementation to provide a list of IEditables (defined by the interface). Each editable would provide a name of a template (EditorFor(), etc). I then want to enumerate over all of them, render the templates, then post the values back to a controller to save the values for the plugin.

Your thoughts?开发者_StackOverflow社区 Is there something out there right now that is similar?


I'm guessing this is something similar to what you're proposing, but I'm getting confused with the wording.

I would say that you should simply create another interface for IPluginProperty and then add a read-only collection of IPluginPropertys to IPlugin. The IPluginProperty interface could then have a property to supply the IPropertyEditor for the property:

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
}
0

精彩评论

暂无评论...
验证码 换一张
取 消