예제 #1
0
        public static IContainer Initialize()
        {
            var container = new CastleWindsorContainer();

            IoC.InitializeWith(container);
            container.WindsorContainer.AddFacility <TypedFactoryFacility>();
            container.WindsorContainer.AddFacility <EventRegisterFacility>();

            container.RegisterImplementationOf(container.DowncastTo <IContainer>());
            container.Register <IApplicationConfiguration, IQualificationRunnerConfiguration, QualificationRunnerConfiguration>(LifeStyle.Singleton);

            registerLogging(container);

            return(container);
        }
예제 #2
0
        private static IContainer initializeContainer()
        {
            var container = new CastleWindsorContainer();

            IoC.InitializeWith(container);

            container.WindsorContainer.AddFacility <EventRegisterFacility>();
            container.WindsorContainer.AddFacility <SerializationFacility>();

            //required to used abstract factory pattern with container
            container.WindsorContainer.AddFacility <TypedFactoryFacility>();

            //Register container into container to avoid any reference to dependency in code
            container.RegisterImplementationOf(container.DowncastTo <IContainer>());
            return(container);
        }
예제 #3
0
        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;
        }