/// <summary> /// Initializes a new instance of the ViewModelLocator class. /// </summary> public ViewModelLocator() { if (GalaSoft.MvvmLight.ViewModelBase.IsInDesignModeStatic) { m_Container = new CompositionContainer( new DesignTimeCatalog( new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()))); } else { #if Db4o Db4objects.Db4o.Db4oFactory.Configure().CallConstructors(true); var server = Db4objects.Db4o.CS.Db4oClientServer.OpenServer(c_Storage, 0); var factory = new Func <ExportProvider, IDomainContext>( ep => new Domain.Db4o.Db4oDomainContext(server.OpenClient())); #elif Ef var factory = new DelegateDomainContextFactory(() => new Domain.Ef.EfDomainContext()); #endif var provider = new FactoryExportProvider(); provider.Register <IDomainContext>(factory); m_Container = new CompositionContainer( new DesignTimeCatalog( new AggregateCatalog( new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()), new DirectoryCatalog("Plugins"))), provider); } m_Container.ComposeExportedValue <IMessageBus>(new MessageBus()); }
/// <summary> /// Initializes a new instance of the ViewModelLocator class. /// </summary> public ViewModelLocator() { if (GalaSoft.MvvmLight.ViewModelBase.IsInDesignModeStatic) { m_Container = new CompositionContainer( new DesignTimeCatalog( new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()))); } else { #if Db4o Db4objects.Db4o.Db4oFactory.Configure().CallConstructors(true); var server = Db4objects.Db4o.CS.Db4oClientServer.OpenServer(c_Storage, 0); var factory = new Func<ExportProvider, IDomainContext>( ep => new Domain.Db4o.Db4oDomainContext(server.OpenClient())); #elif Ef var factory = new DelegateDomainContextFactory(() => new Domain.Ef.EfDomainContext()); #endif var provider = new FactoryExportProvider(); provider.Register<IDomainContext>(factory); m_Container = new CompositionContainer( new DesignTimeCatalog( new AggregateCatalog( new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()), new DirectoryCatalog("Plugins"))), provider); } m_Container.ComposeExportedValue<IMessageBus>(new MessageBus()); }