The people have spoken
And I’ve listened. There are two big changes in the latest Extension Manager version – you can bring in your own admin UI and default settings page provided by manager became dynamic. Now it is not just two predefined boxes, you can add as many parameters as you like.
You can tell Manager to use your own admin page instead of default one by including this code in the extension initialization:
ExtensionManager.SetAdminPage("MyExtension", "~/path/to/mycustompage.aspx");
Where "MyExtension" is your extension class name and "~/path/to/mycustompage.aspx" is a path to your default custom page. When used, "settings/edit" link will point to your custom admin UI rather than standard setting page.
Default settings page became dynamic. This means you can define number of parameters you want Extension Manager to handle and for each parameter text box will be added to settings page at run time. It has basic validation on maximum characters allowed, required field and uniqueness. It is not yet support strong typing but it will in the future with corresponding validation provided. It also only uses text box for parameter input at this stage, support for other controls (combo boxes, check boxes, date and color picker etc.) will be added later on. I will put together section in the WIKI documentation on how to use it when 1.3 released, but here is quick preview of the main features:
With default page, main focus was on ease of use - couple of examples should be sufficient for learning how to use it. At the simplest level, all you need to do is add your parameters as so:
ExtensionSettings settings = new ExtensionSettings("BBCode");
settings.AddParameter("Code");
settings.AddParameter("OpenTag");
settings.AddParameter("CloseTag");
ExtensionManager.ImportSettings(settings);
Then, you can grab your data as data table, where columns are your parameter names and rows are actual values:
DataTable table = _settings.GetDataTable();
foreach (DataRow row in table.Rows)
{
if (string.IsNullOrEmpty((string)row["CloseTag"]))
Parse(ref body, (string)row["Code"], (string)row["OpenTag"]);
else
Parse(ref body, (string)row["Code"], (string)row["OpenTag"], (string)row["CloseTag"]);
}
Extension manager will automatically set default validation rules, all of which overridable. You can also import your default values to Extension Manager and they will show up in settings list right away. The full list of options you can use will be published in the WIKI once 1.3 is in.
settings.AddValues(new string[] { "b", "strong", "" });
settings.AddValues(new string[] { "u", "span style=\"text-decoration:underline\"", "span" });
At this point, I consider current version is a "release candidate". There is still some work to do, but interface itself is highly unlikely to change. Now I'll concentrate on stabilizing code, error handling, adding more validation, localization and probably a bit of refactoring. And a lot of testing to make sure code is solid and works on every machine every time. If you'll be playing with it and run into issues or have any concerns - don't hesitate to drop a line.