This project has moved. For the latest updates, please go here.

Models and ModelContainers

Prism doesn't really touch on the Model aspect of development.  AppCan adds some framework and patterns around using Models and ModeContainers(i.e. documents). The default implementation support a single document interface.

 

ModelManager

The Modelmanager keeps track of registered ModelTemplates, and created ModelContainers (i.e documents/files).  It supports getting default templates, creating/opening new ModelContainers,Closing ModelContainers, Saving model containers.  There are events for when ModelContainers have actions performed on them.

 By using the application Open, Close, Save, SaveAs commands the AppCanApp will invoke the model manager with the appropriate operation. (The behaviour can be overridden in the application class if desired.)

ModelTemplate

Model templates create a relationship between file types, model types, required serializers, and startup contexts for the Shell.  When added to the ModelManager, this way if the app is opened with a file it will look up the appropriate modeltemplate by file extension and instatiate the appropriate shell/context and ModelType.  The shell context should have a class registered using the type interface IViewContainer.

 Example of creating a new template in the OnStartup method of the App:

 protected override void OnStartup(StartupEventArgs e)
        {
           App.ModelManager.AddModelTemplate(new ModelTemplate(typeof(NoteModel), ".can", "NewFile{0}.can", new BinarySerializer(), true, typeof(Shell), "/HelloWorld;component/Shell.xaml", "HelloWorld.mainwindow"));

            
            base.OnStartup(e);


            Bootstrapper bootstrapper = new Bootstrapper(this);
            bootstrapper.Run();

    

        }

Last edited Mar 17, 2013 at 6:58 PM by davesspacebar, version 3

Comments

No comments yet.