"Prism 5.0 source of the daytime" Bootstrapper

Source: Internet
Author: User

The prism framework needs to do some initialization work when the application starts, and bootstrapper is the point of entry.

Bootstrapper main things to do are: Create and configure the module catalog, create a di Container, configure the default region adapter for the UI, create and initialize the shell, and initialize the module.

    <summary>///Base class that provides a basic bootstrapping sequence and hooks//that specific Impl Ementations can override//</summary>//<remarks>//This class must is overridden to provide AP    Plication specific configuration. </remarks> public abstract class Bootstrapper {//<summary>//Gets the <see CRE        f= "Iloggerfacade"/> for the application. </summary>//<value>a <see cref= "Iloggerfacade"/> instance.</value> protected        Iloggerfacade Logger {get; set;}        <summary>//Gets The default <see cref= "Imodulecatalog"/> for the application.        </summary>//<value>the default <see cref= "Imodulecatalog"/> instance.</value>        Protected Imodulecatalog Modulecatalog {get; set;} <summary>//Gets the Shell user interface//</summary>        <value>the Shell user interface.</value> protected DependencyObject shell {get; set;}        <summary>//Create the <see cref= "Iloggerfacade"/> used by the bootstrapper.        </summary>//<remarks>//The base implementation returns a new Textlogger. </remarks> [System.Diagnostics.CodeAnalysis.SuppressMessage ("Microsoft.reliability", "Ca2000:dispose obj ECTS before losing scope ", justification =" The Logger is added to the container which would dispose it when the container        Goes out of scope. ")]        Protected virtual Iloggerfacade Createlogger () {return new Textlogger ();        }///<summary>//Runs the bootstrapper process. </summary> public void Run () {this.        Run (TRUE);        }///<summary>//creates the <see cref= "Imodulecatalog"/> used by Prism. /</summary>//<remarks>//The base implementation returns a new Modulecatalog. </remarks> protected Virtual Imodulecatalog Createmodulecatalog () {return new Moduleca        Talog ();        }///<summary>//Configures the <see cref= "Imodulecatalog"/> used by Prism.        </summary> protected virtual void Configuremodulecatalog () {}///<summary>  Registers the <see cref= "Type"/>s of the Exceptions that is not considered//root Exceptions by        The <see cref= "Exceptionextensions"/&GT;. </summary> protected virtual void Registerframeworkexceptiontypes () {Exceptionextensio Ns.        Registerframeworkexceptiontype (typeof (Microsoft.Practices.ServiceLocation.ActivationException)); }///<summary>//initializes the modules. May is overwritten in aDerived class to use a custom Modules Catalog//</summary> protected virtual void Initializemodules (            ) {Imodulemanager manager = servicelocator.current.getinstance<imodulemanager> (); Manager.        Run ();         }///<summary>//Configures the default region adapter mappings to use in the application, in order        To adapt UI controls defined in XAML to use a region and register it automatically.        May is overwritten in a derived class to add specific mappings required by the application. </summary>//<returns>the <see cref= "Regionadaptermappings"/> instance containing all the M            appings.</returns> protected Virtual Regionadaptermappings configureregionadaptermappings () {            Regionadaptermappings regionadaptermappings = servicelocator.current.getinstance<regionadaptermappings> ();     if (regionadaptermappings! = null)       {regionadaptermappings.registermapping (typeof (Selector), Servicelocator.current.getinstance<sele                Ctorregionadapter> ()); Regionadaptermappings.registermapping (typeof (ItemsControl), servicelocator.current.getinstance<                Itemscontrolregionadapter> ()); Regionadaptermappings.registermapping (typeof (ContentControl), servicelocator.current.getinstance<            Contentcontrolregionadapter> ());        } return regionadaptermappings;         }///<summary>//Configures the <see cref= "Iregionbehaviorfactory"/&GT;.         This would be is the list of the default behaviors that would be added to a region.            </summary> protected Virtual Iregionbehaviorfactory configuredefaultregionbehaviors () {            var defaultregionbehaviortypesdictionary = servicelocator.current.getinstance<iregionbehaviorfactory> ();     if (defaultregionbehaviortypesdictionary! = null)       {defaultregionbehaviortypesdictionary.addifmissing (Bindregioncontexttodependencyobjectbehavior.beha Viorkey, typeof (Bindregioncontexttodependencyobjectbehavi                OR));                                                                  Defaultregionbehaviortypesdictionary.addifmissing (Regionactiveawarebehavior.behaviorkey,                typeof (Regionactiveawarebehavior));                                                                  Defaultregionbehaviortypesdictionary.addifmissing (Syncregioncontextwithhostbehavior.behaviorkey,                typeof (Syncregioncontextwithhostbehavior));                                                                  Defaultregionbehaviortypesdictionary.addifmissing (Regionmanagerregistrationbehavior.behaviorkey,                typeof (Regionmanagerregistrationbehavior)); Defaultregionbehaviortypesdictionary.addifmissing (regionmemberlifetimebehavior.behaviorkEY, typeof (Regionmemberlifetimebehavior));                                                  Defaultregionbehaviortypesdictionary.addifmissing (Clearchildviewsregionbehavior.behaviorkey,                typeof (Clearchildviewsregionbehavior));                                                  Defaultregionbehaviortypesdictionary.addifmissing (Autopopulateregionbehavior.behaviorkey,            typeof (Autopopulateregionbehavior));        } return defaultregionbehaviortypesdictionary;        }///<summary>//initializes the shell. </summary> protected virtual void Initializeshell () {}//<summary>/        Run the bootstrapper process.  </summary>//<param name= "runwithdefaultconfiguration" >if <see langword= "true"/&GT;, registers Default///Prism Library services in the container. This is the default behavior.</param> public abstract void Run (bool runwithdefaultconfiguration);        <summary>//creates the shell or main window of the application.        </summary>//<returns>the shell of the application.</returns>///<remarks> If The returned instance is a <see cref= "DependencyObject"/&GT;, the////<see cref= "Bootstrapper"/&G T Would attach the default <see cref= "Iregionmanager"/> of//The application in its <see cref= "Regionmanage R.regionmanagerproperty "/> attached property///In order-be-able to-add regions by using the <see cref=" R        Egionmanager.regionnameproperty "/>//attached property from XAML.        </remarks> protected abstract DependencyObject Createshell (); <summary>//Configures the Locatorprovider for the <see cref= "Microsoft.Practices.ServiceLocation.Se        Rvicelocator "/&GT; </summary> protected abstract void configureservicelocator (); }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.