private static void initializeDependency() { // var container = new AutofacContainer(); // container.AddActivationHook<EventRegistrationHook>(); var container = new CastleWindsorContainer(); container.AddFacility <EventRegisterFacility>(); container.AddFacility <TypedFactoryFacility>(); IoC.InitializeWith(container); var serializerRegister = new CoreSerializerRegister(); using (container.OptimizeDependencyResolution()) { container.RegisterImplementationOf((IContainer)container); container.Register <IObjectBaseFactory, ObjectBaseFactory>(LifeStyle.Singleton); container.AddRegister(x => x.FromType <PresenterRegister>()); container.AddRegister(x => x.FromType <UIRegister>()); container.AddRegister(x => x.FromType <CoreRegister>()); container.AddRegister(x => x.FromType <TestRegister>()); container.AddRegister(x => x.FromType <InfrastructureRegister>()); container.AddRegister(x => x.FromType <InfrastructureExportRegister>()); container.AddRegister(x => x.FromType <InfrastructureSerializationRegister>()); container.AddRegister(x => x.FromType <InfrastructureImportRegister>()); container.AddRegister(x => x.FromInstance(serializerRegister)); container.Register <IDimensionFactory, DimensionFactory>(LifeStyle.Singleton); container.Register <IApplicationController, ApplicationController>(LifeStyle.Singleton); container.Register <IEventPublisher, EventPublisher>(LifeStyle.Singleton); container.RegisterImplementationOf(getCurrentContext()); container.Register <IHistoryManager, HistoryManager <MyContext> >(); container.Register <IFullPathDisplayResolver, FullPathDisplayResolver>(); container.Register <MyContext, MyContext>(); container.Register <IConfigurableContainerLayoutView, AccordionLayoutView>(); container.Register <DxContainer, DxContainer>(LifeStyle.Singleton); // container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().ApplicationMenu).As<ApplicationMenu>(); // container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().BarManager).As<BarManager>(); // container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().PanelControl).As<PanelControl>(); // container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().RibbonControl).As<RibbonControl>(); // container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().RibbonBarManager).As<RibbonBarManager>(); // container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().UserLookAndFeel).As<UserLookAndFeel>(); // container.AutofacBuilder.Register(c => c.Resolve<DxContainer>().XtraTabbedMdiManager).As<XtraTabbedMdiManager>(); container.Register <RegionsContainer, RegionsContainer>(LifeStyle.Singleton); // container.AutofacBuilder.Register(c => c.Resolve<RegionsContainer>().Journal).Keyed<IRegion>(RegionNames.Journal.Name); // container.AutofacBuilder.Register(c => c.Resolve<RegionsContainer>().Comparison).Keyed<IRegion>(RegionNames.Comparison.Name); // container.AutofacBuilder.Register(c => c.Resolve<RegionsContainer>().Explorer).Keyed<IRegion>(RegionNames.Explorer.Name); } serializerRegister.PerformMappingForSerializerIn(IoC.Container); }
public override void GlobalContext() { if (IoC.Container != null) { return; } base.GlobalContext(); var container = new CastleWindsorContainer(); IoC.InitializeWith(container); IoC.RegisterImplementationOf(IoC.Container); container.WindsorContainer.AddFacility <TypedFactoryFacility>(); container.Register <IObjectBaseFactory, ObjectBaseFactory>(LifeStyle.Singleton); container.Register <IDimensionFactory, DimensionFactoryForIntegrationTests>(LifeStyle.Singleton); container.Register <IGroupRepository, GroupRepositoryForSpecs>(LifeStyle.Singleton); container.Register <IDisplayNameProvider, DisplayNameProvider>(); container.Register <SimulationHelperForSpecs, SimulationHelperForSpecs>(); container.Register <ModelHelperForSpecs, ModelHelperForSpecs>(); container.Register <ConcentrationBaseModelHelperForSpecs, ConcentrationBaseModelHelperForSpecs>(); container.Register <IReactionDimensionRetriever, ReactionDimensionRetrieverForSpecs>(LifeStyle.Singleton); container.Register(typeof(IRepository <>), typeof(ImplementationRepository <>)); container.RegisterImplementationOf(A.Fake <IStartOptions>()); var stringCompression = A.Fake <IStringCompression>(); A.CallTo(() => stringCompression.Compress(A <string> ._)).ReturnsLazily(x => x.GetArgument <string>(0)); A.CallTo(() => stringCompression.Decompress(A <string> ._)).ReturnsLazily(x => x.GetArgument <string>(0)); container.RegisterImplementationOf(stringCompression); container.RegisterImplementationOf(A.Fake <IObjectTypeResolver>()); container.RegisterImplementationOf(A.Fake <IDisplayUnitRetriever>()); container.RegisterImplementationOf(A.Fake <IDataRepositoryTask>()); container.RegisterImplementationOf(A.Fake <IOSPSuiteExecutionContext>()); container.RegisterImplementationOf(A.Fake <IProjectRetriever>()); container.RegisterImplementationOf(A.Fake <IApplicationDiscriminator>()); container.RegisterImplementationOf(A.Fake <IRelatedItemDescriptionCreator>()); container.RegisterImplementationOf(A.Fake <IJournalDiagramManagerFactory>()); container.RegisterImplementationOf(A.Fake <ICoreUserSettings>()); container.RegisterImplementationOf(A.Fake <ICoreSimulationFactory>()); var applicationConfiguration = A.Fake <IApplicationConfiguration>(); A.CallTo(() => applicationConfiguration.Product).Returns(Origins.Other); container.RegisterImplementationOf(applicationConfiguration); initGroupRepository(); var progressMananager = A.Fake <IProgressManager>(); A.CallTo(() => progressMananager.Create()).Returns(A.Fake <IProgressUpdater>()); container.RegisterImplementationOf(progressMananager); using (container.OptimizeDependencyResolution()) { container.AddRegister(x => x.FromType <CoreRegister>()); container.AddRegister(x => x.FromType <InfrastructureRegister>()); var register = new CoreSerializerRegister(); container.AddRegister(x => x.FromInstance(register)); register.PerformMappingForSerializerIn(container); } initializeDimensions(); Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; }
public override void GlobalContext() { base.GlobalContext(); var container = new CastleWindsorContainer(); IoC.InitializeWith(container); IoC.RegisterImplementationOf(container); container.RegisterImplementationOf(container.DowncastTo <IContainer>()); container.WindsorContainer.AddFacility <TypedFactoryFacility>(); //need to register these services for which the default implementation is in the UI using (container.OptimizeDependencyResolution()) { container.RegisterImplementationOf(new SynchronizationContext()); container.Register <IExceptionManager, ExceptionManagerForSpecs>(LifeStyle.Singleton); container.RegisterImplementationOf(A.Fake <IUserSettings>()); container.RegisterImplementationOf(A.Fake <IDialogCreator>()); container.RegisterImplementationOf(A.Fake <IProgressUpdater>()); container.RegisterImplementationOf(A.Fake <IMoBiHistoryManager>()); container.RegisterImplementationOf(A.Fake <IXmlContentSelector>()); container.RegisterImplementationOf(A.Fake <IDiagramModel>()); container.RegisterImplementationOf(A.Fake <IDiagramTask>()); container.RegisterImplementationOf(A.Fake <IMRUProvider>()); container.RegisterImplementationOf(A.Fake <IContextMenuView>()); container.RegisterImplementationOf(A.Fake <IFileLocker>()); container.RegisterImplementationOf(A.Fake <IDisplayUnitRetriever>()); container.RegisterImplementationOf(A.Fake <IJournalDiagramManagerFactory>()); container.RegisterImplementationOf(A.Fake <ISimulationDiagramManager>()); container.RegisterImplementationOf(A.Fake <ISpatialStructureDiagramManager>()); container.RegisterImplementationOf(A.Fake <IMoBiReactionDiagramManager>()); container.RegisterImplementationOf(A.Fake <ISimulationDiagramView>()); container.RegisterImplementationOf(A.Fake <IContainerBaseLayouter>()); container.RegisterImplementationOf(A.Fake <ILayerLayouter>()); container.Register <IDiagramModelToXmlMapper, BatchDiagramModelToXmlMapper>(); container.Register <IMoBiConfiguration, MoBiConfiguration>(LifeStyle.Singleton); container.Register <IEventPublisher, EventPublisher>(LifeStyle.Singleton); IHeavyWorkManager heavyWorkManager = new HeavyWorkManagerForSpecs(); container.RegisterImplementationOf(heavyWorkManager); container.RegisterImplementationOf(A.Fake <IProgressManager>()); var config = container.Resolve <IMoBiConfiguration>(); container.RegisterImplementationOf((IApplicationConfiguration)config); var register = new SerializerRegister(); container.AddRegister(x => { x.FromType <CoreRegister>(); x.FromType <Core.CoreRegister>(); x.FromInstance(new PresentationRegister(false)); x.FromType <InfrastructureRegister>(); x.FromType <EngineRegister>(); x.FromInstance(register); }); register.PerformMappingForSerializerIn(container); container.RegisterImplementationOf(A.Fake <IMoBiMainViewPresenter>()); setupDimensions(container); setupCalculationMethods(container); var context = container.Resolve <IMoBiContext>(); container.RegisterImplementationOf <IWorkspace>(context); } //Required for usage with nunit 3 Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; }
public override void GlobalContext() { if (IoC.Container != null) { return; } base.GlobalContext(); var container = new CastleWindsorContainer(); IoC.InitializeWith(container); IoC.RegisterImplementationOf(IoC.Container); container.WindsorContainer.AddFacility <TypedFactoryFacility>(); container.Register <IObjectBaseFactory, ObjectBaseFactory>(LifeStyle.Singleton); container.Register <IDimensionFactory, DimensionFactoryForIntegrationTests>(LifeStyle.Singleton); container.Register <IGroupRepository, GroupRepositoryForSpecs>(LifeStyle.Singleton); container.Register <IDataRepositoryTask, DataRepositoryTask>(); container.Register <IImporter, Importer>(); container.Register <IDataSourceFileParser, DataSourceFileParser>(); container.Register <ICsvDataSourceFile, CsvDataSourceFile>(); container.Register <IImportLogger, ImportLogger>(); container.Register <IExcelDataSourceFile, ExcelDataSourceFile>(); container.Register <IDataSetToDataRepositoryMapper, DataSetToDataRepositoryMapper>(); container.Register <IDataFormat, MixColumnsDataFormat>(); container.Register <SimulationHelperForSpecs, SimulationHelperForSpecs>(); container.Register <ModelHelperForSpecs, ModelHelperForSpecs>(); container.Register <IDisplayNameProvider, DisplayNameProvider>(); container.Register <ConcentrationBaseModelHelperForSpecs, ConcentrationBaseModelHelperForSpecs>(); container.Register <IReactionDimensionRetriever, ReactionDimensionRetrieverForSpecs>(LifeStyle.Singleton); container.RegisterImplementationOf(A.Fake <IStartOptions>()); container.RegisterImplementationOf(A.Fake <IApplicationController>()); container.RegisterImplementationOf(A.Fake <IObjectTypeResolver>()); container.RegisterImplementationOf(A.Fake <IDisplayUnitRetriever>()); container.RegisterImplementationOf(A.Fake <IOSPSuiteExecutionContext>()); container.RegisterImplementationOf(A.Fake <IProjectRetriever>()); container.RegisterImplementationOf(A.Fake <IApplicationDiscriminator>()); container.RegisterImplementationOf(A.Fake <IRelatedItemDescriptionCreator>()); container.RegisterImplementationOf(A.Fake <IJournalDiagramManagerFactory>()); container.RegisterImplementationOf(A.Fake <ICoreUserSettings>()); container.RegisterImplementationOf(A.Fake <ICoreSimulationFactory>()); var applicationConfiguration = A.Fake <IApplicationConfiguration>(); A.CallTo(() => applicationConfiguration.Product).Returns(Origins.Other); container.RegisterImplementationOf(applicationConfiguration); initGroupRepository(); var progressManager = A.Fake <IProgressManager>(); A.CallTo(() => progressManager.Create()).Returns(A.Fake <IProgressUpdater>()); container.RegisterImplementationOf(progressManager); var csvSeparatorSelector = A.Fake <ICsvSeparatorSelector>(); A.CallTo(() => csvSeparatorSelector.GetCsvSeparator(A <string> .Ignored)).Returns(';'); container.RegisterImplementationOf(csvSeparatorSelector); using (container.OptimizeDependencyResolution()) { container.AddRegister(x => x.FromType <CoreRegister>()); container.AddRegister(x => x.FromType <InfrastructureRegister>()); var register = new CoreSerializerRegister(); container.AddRegister(x => x.FromInstance(register)); register.PerformMappingForSerializerIn(container); } initializeDimensions(); initPKParameters(); Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory; }