标签:des style blog color 使用 os io strong
UnityBootstrapper (abstract class)继承自Bootstrapper(abstract)类, 在Prism.UnityExtensions.Desktop project中。主要是为了支持Unity Container(Dependency Injection Container)。
打开UnityBoostrapper源代码我们可以看到这里面主要有以下逻辑:
1. 定义Unity Container属性
public IUnityContainer Container { get; protected set; }
2. 重写Run()方法
public override void Run(bool runWithDefaultConfiguration) { ...... }
这是Bootstrapper的入口方法,亦是整个应用的入口方法。在Run()方法里主要调用了应用程序初始化的逻辑。
this.Logger = this.CreateLogger();
this.ModuleCatalog = this.CreateModuleCatalog();
this.ConfigureModuleCatalog();
this.Container = this.CreateContainer();
this.ConfigureContainer();
protected override void ConfigureServiceLocator() { ServiceLocator.SetLocatorProvider(() => this.Container.Resolve<IServiceLocator>()); }
this.ConfigureRegionAdapterMappings();
this.ConfigureDefaultRegionBehaviors();
protected override void RegisterFrameworkExceptionTypes() { base.RegisterFrameworkExceptionTypes(); ExceptionExtensions.RegisterFrameworkExceptionType( typeof(Microsoft.Practices.Unity.ResolutionFailedException)); }
this.Shell = this.CreateShell();
if (this.Shell != null) { this.Logger.Log(Resources.SettingTheRegionManager, Category.Debug, Priority.Low); RegionManager.SetRegionManager(this.Shell, this.Container.Resolve<IRegionManager>()); this.Logger.Log(Resources.UpdatingRegions, Category.Debug, Priority.Low); RegionManager.UpdateRegions(); this.Logger.Log(Resources.InitializingShell, Category.Debug, Priority.Low); this.InitializeShell(); }
if (this.Container.IsRegistered<IModuleManager>()) { this.Logger.Log(Resources.InitializingModules, Category.Debug, Priority.Low); this.InitializeModules(); }
至此,Run()方法的工作完成。
《Prism 5.0源码走读》UnityBootstrapper,布布扣,bubuko.com
《Prism 5.0源码走读》UnityBootstrapper
标签:des style blog color 使用 os io strong
原文地址:http://www.cnblogs.com/codesee/p/3925539.html