The infrastructure generated by the AB Suite MVC Scaffolder is geared to accommodate application switching, if you want to switch between different AB Suite runtime systems.
The following steps allow you to add Views and Controllers from different application DataModels and enable the context to switch between application Views at runtime:
Create an MVC application. See Creating the ASP.NET MVC Projects for more information.
Add the DataModel references for each application that has to be integrated into the MVC application.
Select the primary AB Suite application (typically, the initial system that the user connect to on startup) and scaffold the MVC application by using the AB Suite Scaffolder with the DataModels for that AB Suite application.
Select a secondary AB Suite application that is switched to at runtime. Scaffold the same MVC application by using the AB Suite Scaffolder with the DataModels for the secondary application.
Sub folders qualified by the application name appear under the Controllers and Views folder in the MVC project. These contain Controllers and Views for each application that was scaffolded.
Repeat the previous step for each AB Suite application that has to be integrated into the MVC project to allow application switching at runtime.
Open the ABSuiteSession class under the Utility folder and locate the method GetIspecDataModelFactory(). You must add one or more Case statements in the Switch statement to include all secondary AB Suite applications that were scaffolded. A Case statement for the primary application already exists. For example,
switch (forSystemName) { case "SAMPLE": return new SAMPLE.Custom.DataModels.Core.IspecFactory(); case "SwitchApp": return new SwitchApp.Custom.DataModels.Core.IspecFactory(); //case "<Other System to switch to>": // return new <Other System to switch to>.IspecFactory(); // e.g. return new Sample.Custom.DataModels.Core.IspecFactory(); default: throw new ArgumentException(String.Format("System [{0}] not recognized. Unable to resolve IspecDataModelFactory", forSystemName)); }
You can now run the MVC application. When a System Switch occurs, the appropriate Views appear from each system.