IModuleSetup Interface |
Namespace: AskiaPortalCmn.Setup
The IModuleSetup type exposes the following members.
Name | Description | |
---|---|---|
Authors |
Get or set the author(s) of the module.
| |
Category |
Get or set the category of the module.
| |
Description |
Get or set the description of the module.
| |
Guid |
Indicates the module GUID that
will be use for registration or update.
| |
IsBackground |
Indicates if the module is a background module.
A background module, doesn't have a frontal User Interface. | |
Name |
Get or set the name of the module.
| |
RootUrl |
Get or set the root URL of the module.
| |
State |
Get or set the state of the module (active by default).
| |
Version |
Indicates the module version that
will be use for registration or update.
|
Name | Description | |
---|---|---|
Save |
Save the module in the database.
| |
SetDefaultConfig |
Set the default configuration.
| |
SetDefaultTranslations |
Set the default module translations.
| |
SetUrls |
Set the URLs associated with the module.
|
Register a module using his main web service (Global.asax).
using System; using System.Web; using System.Collections.Generic; using AskiaPortalCmn; using AskiaPortalCmn.Setup; using AskiaPortalCmn.Common; namespace MyWebModule { public class Global : HttpApplication { protected void Application_Start(object sender, EventArgs e) { AskiaPortalCmnApi.OnSetup += AskiaPortalCmnApi_OnSetup; var myWebModuleGuid = Guid.Parse("26f6ab8b-2fdb-4f4f-ad14-7507892846a5"); var myWebModuleVersion = new Version("1.0.0.0"); AskiaPortalCmnApi.InitializeModule(myWebModuleGuid, myWebModuleVersion); } private void AskiaPortalCmnApi_OnSetup(IModuleSetup moduleSetup, IModule currentModule) { if (currentModule != null) { // This is an update of the version: // currentModule.Version // to the current assembly version } else { // This is the first registration // of the module } // Set meta information moduleSetup.Name = "MyWebModule"; moduleSetup.Description = "Web module to do something..."; moduleSetup.Authors = "Myself and Co."; moduleSetup.RootUrl = "MyWebModule/"; moduleSetup.Category = ModuleCategory.SurveysCreation; // Set the default module configuration moduleSetup.SetDefaultConfig(new Dictionary<string, object> { {"myStringKey", "default value"}, {"myBoolKey", false}, {"myIntKey", 50}, {"myDblKey", 50.2}, {"myGuidKey", Guid.Parse("26f6ab8b-2fdb-4f4f-ad14-7507892846a5"} } ); // Set the default module translations moduleSetup.SetDefaultTranslations("en-GB", new Dictionary<string, string> { {"new", "New"}, {"open", "Open"} } ); moduleSetup.SetDefaultTranslations("fr-FR", new Dictionary<string, string> { {"new", "Nouveau"}, {"open", "Ouvrir"} } ); // Set URLs of the module moduleSetup.SetUrls(new Dictionary<ModuleUrlFor, string> { {ModuleUrlTo.ModulePage, ""}, {ModuleUrlTo.ModuleLogo, "img/logo.svg"}, {ModuleUrlTo.ModuleLogoHover, "img/logo-hover.svg"}, {ModuleUrlTo.AdminUserPage, "admin/User/"}, {ModuleUrlTo.AdminUserProfilePage, "admin/UserProfile/"}, {ModuleUrlTo.AdminSurveyPage, "admin/Survey/"}, {ModuleUrlTo.AdminSurveyUserPage, "admin/SurveyUser/"}, {ModuleUrlTo.AdminSurveyGroupage, "admin/SurveyGroup/"} }); // Save the module moduleSetup.Save(); } } }