public void Register(IWindsorContainer container)
        {
            container.AddComponent(
                    "entityDuplicateChecker",
                    typeof(IEntityDuplicateChecker),
                    typeof(EntityDuplicateChecker));

            container.AddComponent(
                    "repositoryType",
                    typeof(IRepository<>),
                    typeof(Repository<>));

            container.AddComponent(
                    "nhibernateRepositoryType",
                    typeof(INHibernateRepository<>),
                    typeof(NHibernateRepository<>));

            container.AddComponent(
                    "repositoryWithTypedId",
                    typeof(IRepositoryWithTypedId<,>),
                    typeof(RepositoryWithTypedId<,>));

            container.AddComponent(
                    "nhibernateRepositoryWithTypedId",
                    typeof(INHibernateRepositoryWithTypedId<,>),
                    typeof(NHibernateRepositoryWithTypedId<,>));
        }
 private static void AddRepositoriesTo(IWindsorContainer container)
 {
     container.AddComponent("repository", typeof(IRepository), typeof(Repository));
     container.AddComponent("genericRepository", typeof(IRepository<>), typeof(Repository<>));
     container.AddComponent("typedRepository", typeof(IRepositoryWithTypedId<,>),
                            typeof(RepositoryWithTypedId<,>));
 }
        public static void AddComponentsTo(IWindsorContainer container)
        {
            AddGenericRepositoriesTo(container);

            container.AddComponent("validator",
                                   typeof(IValidator), typeof(Validator));
            container.AddComponent("dbContext", typeof(IDbContext), typeof(DbContext));
        }
Пример #4
0
		public void SetUp()
		{
			_container = new WindsorContainer(ConfigHelper.ResolvePath("../Castle.Facilities.Cache.Tests.config"));
			_container.AddComponent("ServiceA",typeof(IServiceA), typeof(ServiceA));
			_container.AddComponent("ServiceC",typeof(IServiceC), typeof(ServiceC));
			_container.AddComponent("ServiceD",typeof(IServiceD), typeof(ServiceD));

			ResetConsoleOut();
		}
        public static void AddComponentsTo(IWindsorContainer container)
        {
            ParameterCheck.ParameterRequired(container, "container");

            if (!container.Kernel.HasComponent("ExceptionLogger")) {
                container.AddComponent("ExceptionLogger", typeof(IExceptionLogger), typeof(ExceptionLogger));
                container.AddComponent("MethodLogger", typeof(IMethodLogger), typeof(MethodLogger));
            }
        }
 private static void AddGenericRepositoriesTo(IWindsorContainer container) {
     container.AddComponent("repositoryType",
         typeof(IRepository<>), typeof(Repository<>));
     container.AddComponent("nhibernateRepositoryType",
         typeof(INHibernateRepository<>), typeof(NHibernateRepository<>));
     container.AddComponent("repositoryWithTypedId",
         typeof(IRepositoryWithTypedId<,>), typeof(RepositoryWithTypedId<,>));
     container.AddComponent("nhibernateRepositoryWithTypedId",
         typeof(INHibernateRepositoryWithTypedId<,>), typeof(NHibernateRepositoryWithTypedId<,>));
 }
		public void Init()
		{
			_container = new WindsorContainer( @"..\typedFactory_castle_config.xml" );
			
			_container.AddFacility( "typedfactory", new TypedFactoryFacility() );

			_container.AddComponent( "miranda", typeof(IProtocolHandler), typeof(MirandaProtocolHandler) );
			_container.AddComponent( "messenger", typeof(IProtocolHandler), typeof(MessengerProtocolHandler) );
			_container.AddComponent( "comp1", typeof(IDummyComponent), typeof(Component1) );
			_container.AddComponent( "comp2", typeof(IDummyComponent), typeof(Component2) );
		}
Пример #8
0
 private void SetupWindsor()
 {
     container = new WindsorContainer(new XmlInterpreter());
     var configBuilder = new NHConfigBuilder(Server.MapPath("/"));
     container.AddFacility("nhibernate", new NHibernateFacility(configBuilder));
     container.AddFacility<TransactionFacility>();
     container.AddComponent<TransactionalService>();
     container.AddComponent<HomeController>("home");
     new SchemaExport(configBuilder.GetConfiguration(null)).Execute(false, true, false);
     ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
 }
Пример #9
0
        public void Register(IWindsorContainer container)
        {
            container.Register(
                   AllTypes.Pick()
                           .FromAssembly(Assembly.GetAssembly(typeof(ControllersRegistrarMarker)))
                           .If(f => f.Namespace.Contains(".Mappers"))
                           .WithService.FirstInterface());

            container.AddComponent("mapper1", typeof(IMapper<,>), typeof(Mapper<,>));
            container.AddComponent("mapper2", typeof(IMapper<,,>), typeof(Mapper<,,>));
        }
Пример #10
0
        public static void AddComponentsTo(IWindsorContainer container)
        {
            //Add your components here
            container.AddComponent("validator", typeof(IValidator), typeof(Validator));
            container.AddComponent("dbContext", typeof(IDbContext), typeof(DbContext));
            container.AddComponent("emailProvider", typeof(IEmailProvider), typeof(EmailProvider));
            container.AddComponent("ticketControllerService", typeof (ITicketControllerService),
                                   typeof (TicketControllerService));

            AddRepositoriesTo(container);
        }
        public static void AddComponentsTo(IWindsorContainer container)
        {
            //Add your components here
            container.AddComponent("validator",
                                   typeof(IValidator), typeof(Validator));
            container.AddComponent("dbContext", typeof (IDbContext), typeof (DbContext));

            AddBLLsTo(container);

            AddRepositoriesTo(container);
        }
		public void Init()
		{
			container = new WindsorContainer(ConfigHelper.ResolveConfigPath("Facilities/TypedFactory/typedFactory_castle_config.xml"));
			
			container.AddFacility( "typedfactory", new TypedFactoryFacility() );

			container.AddComponent( "miranda", typeof(IProtocolHandler), typeof(MirandaProtocolHandler) );
			container.AddComponent( "messenger", typeof(IProtocolHandler), typeof(MessengerProtocolHandler) );
			container.AddComponent( "comp1", typeof(IDummyComponent), typeof(Component1) );
			container.AddComponent( "comp2", typeof(IDummyComponent), typeof(Component2) );
		}
Пример #13
0
        public static IWindsorContainer GetInstance()
        {
            if (container == null)
            {
                container = new WindsorContainer(new XmlInterpreter("CastleIoc/BasicUsage.xml"));

                container.AddComponent("txtLog", typeof(ILog), typeof(TextFileLog));
                container.AddComponent("txtFormat", typeof(ILogFormatter), typeof(TextFormat));
            }

            return container;
        }
Пример #14
0
        /// <summary>
        /// Adds all of the implemented classes within the BLL assembly and their first interfaces to the windsor container.
        /// </summary>
        private static void AddBLLClassesTo(IWindsorContainer container)
        {
            container.AddComponent("userBLL", typeof (IUserBLL), typeof (UserBLL));
            container.AddComponent("reportBLL", typeof (IReportBLL), typeof (ReportBLL));

            #if DEBUG

            container.AddComponent("devTimeRecordBLL", typeof(ITimeRecordBLL), typeof(DevTimeRecordBLL));
            container.AddComponent("devCostShareBLL", typeof(ICostShareBLL), typeof(DevCostShareBLL));
            container.AddComponent("devDelegateBLL", typeof (IDelegateBLL), typeof (DevDelegateBLL));

            #else

            container.AddComponent("TimeRecordBLL", typeof(ITimeRecordBLL), typeof(TimeRecordBLL));
            container.AddComponent("CostShareBLL", typeof(ICostShareBLL), typeof(CostShareBLL));
            container.AddComponent("DelegateBLL", typeof (IDelegateBLL), typeof (DelegateBLL));

            #endif

            /*
            var types = typeof(GenericBLL<,>).Assembly.GetTypes().Where(t => t.IsInterface == false && t.IsAbstract == false); //.Where(a => a.BaseType == typeof (GenericBLL<,>));

            foreach (var type in types)
            {
                var matchingInterface = type.GetInterfaces().FirstOrDefault();

                if (matchingInterface != null)
                {
                    container.AddComponent(type.Name, matchingInterface, type);
                }
            }
             */
        }
Пример #15
0
 private static void AddGenericRepositoriesTo(IWindsorContainer container)
 {
     container.AddComponent(
         "sessionFactoryKeyProvider", typeof(ISessionFactoryKeyProvider), typeof(DefaultSessionFactoryKeyProvider));
     container.AddComponent("repositoryType", typeof(IRepository<>), typeof(NHibernateRepository<>));
     container.AddComponent(
         "nhibernateRepositoryType", typeof(INHibernateRepository<>), typeof(NHibernateRepository<>));
     container.AddComponent(
         "repositoryWithTypedId", typeof(IRepositoryWithTypedId<,>), typeof(NHibernateRepositoryWithTypedId<,>));
     container.AddComponent(
         "nhibernateRepositoryWithTypedId",
         typeof(INHibernateRepositoryWithTypedId<,>),
         typeof(NHibernateRepositoryWithTypedId<,>));
 }
        public static void AddComponentsTo(IWindsorContainer container)
        {
            AddGenericRepositoriesTo(container);
            AddCustomRepositoriesTo(container);
            AddApplicationServicesTo(container);
            AddMappersTo(container);

            container.AddComponent("validator",
                                   typeof(IValidator), typeof(Validator));
            container.AddComponent("validationResult",
                                   typeof (IValidationResult), typeof (ValidationResult));
            container.AddComponent("collection",
                                   typeof (ICollection<>), typeof (Collection<>));
        }
Пример #17
0
		public void Init()
		{
			container = new WindsorContainer(new XmlInterpreter(new ConfigResource()));

			container.AddFacility("transactionfacility", new TransactionFacility() );
			container.AddFacility("arfacility", new ActiveRecordFacility() );

			container.AddComponent( "blog.service", typeof(BlogService) );
			container.AddComponent( "post.service", typeof(PostService) );
			container.AddComponent( "first.service", typeof(FirstService) );
			container.AddComponent( "wiring.service", typeof(WiringSession) );

			Recreate();
		}
        public void Setup()
        {
            _container = new WindsorContainer();
            _factory = new WindsorControllerFactory(_container);

            _container.AddComponent("simplecontroller", typeof(WindsorSimpleController));
            _container.AddComponent("StubDependency", typeof(IDependency), typeof(StubDependency));
            _container.AddComponent("dependencycontroller", typeof(WindsorDependencyController));

            _factory.InitializeWithControllerTypes(typeof(WindsorSimpleController), typeof(WindsorDependencyController));

            var mocks = new MockRepository();
            _context = new RequestContext(mocks.DynamicHttpContextBase(), new RouteData());
            mocks.ReplayAll();
        }
        private static void AddWcfServiceFactoriesTo(IWindsorContainer container) {
            container.AddFacility("factories", new FactorySupportFacility());
            container.AddComponent("standard.interceptor", typeof(StandardInterceptor));

            string factoryKey = "territoriesWcfServiceFactory";
            string serviceKey = "territoriesWcfService";

            container.AddComponent(factoryKey, typeof(TerritoriesWcfServiceFactory));
            MutableConfiguration config = new MutableConfiguration(serviceKey);
            config.Attributes["factoryId"] = factoryKey;
            config.Attributes["factoryCreate"] = "Create";
            container.Kernel.ConfigurationStore.AddComponentConfiguration(serviceKey, config);
            container.Kernel.AddComponent(serviceKey, typeof(ITerritoriesWcfService), 
                typeof(TerritoriesWcfServiceClient), LifestyleType.PerWebRequest);
        }
        private static void RegisterComponents(IWindsorContainer container)
        {
            container.Register(
                AllTypes.Pick()
                    //Scan repository assembly for domain model interfaces implementation
                    .FromAssemblyNamed("NDDDSample.Persistence.NHibernate")
                    .WithService.FirstNonGenericCoreInterface("NDDDSample.Domain.Model"));

            container.AddComponent("bookingInterface",
                                   Type.GetType("NDDDSample.Application.IBookingService, NDDDSample.Application"),
                                   Type.GetType("NDDDSample.Application.Impl.BookingService, NDDDSample.Application"));
           
            container.AddComponent("routingService",                                   
                                   Type.GetType("NDDDSample.Domain.Service.IRoutingService, NDDDSample.Domain"),
                                   Type.GetType("NDDDSample.Infrastructure.ExternalRouting.ExternalRoutingService, NDDDSample.Infrastructure.ExternalRouting"));

            container.AddFacility<WcfFacility>();

            container.Register(
                Component.For<MessageLifecycleBehavior>(),
                Component.For<UnitOfWorkBehavior>(),
                Component
                    .For<IBookingServiceFacade>()
                    .ImplementedBy<BookingServiceFacade>()
                    .Named("BookingService")
                    .LifeStyle.Transient
                    .ActAs(new DefaultServiceModel()
                               .AddEndpoints(WcfEndpoint
                                                 .BoundTo(new NetTcpBinding())
                                                 //.At("net.tcp://localhost:8081/BookingServiceFacade")
                                                 .At(String.Format("net.tcp://{0}/BookingServiceFacade", bookingRemoteServiceWorkerRoleEndpoint))
                                                 // adds this message action to this endpoint
                                                 .AddExtensions(new LifestyleMessageAction()
                                                 )
                               ))
                );

            container.Register(
                Component
                    .For<IGraphTraversalService>()                
                    .Named("pathfinderRemoteFacade")
                    .LifeStyle.Transient
                    .ActAs(DefaultClientModel
                    .On(WcfEndpoint.BoundTo(new NetTcpBinding())
                        .At(String.Format("net.tcp://{0}/GraphTraversalService", pathfinderRemoteServiceWorkerRoleEndpoint))
                        ))
                        .LifeStyle.Transient);
        }
Пример #21
0
 public void Register(IWindsorContainer container)
 {
     container.AddComponent(
              "validator",
              typeof(IValidator),
              typeof(Validator));
 }
Пример #22
0
        public static void Initialise()
        {
            container = new WindsorContainer();

            container.AddComponent("LoggerService", typeof(ILoggerService), typeof(LoggerService));
            container.AddComponent("AccountService", typeof(IAccountService), typeof(AccountService));
            container.AddComponent("MainWindowViewModel", typeof(MainWindowViewModel));//LoginWindowViewModel
            container.AddComponent("LoginWindowViewModel", typeof(LoginWindowViewModel));
            //container.AddComponent("LoginWindow", typeof(LoginWindow));
            container.AddComponent("MainWindow", typeof(MainWindow));

            //DependencyResolver.SetResolver(new UnityDependencyResolver(container));
            //MainWindow loginWindow = container.Resolve<LoginWindow>();
            MainWindow MainWindow = container.Resolve<MainWindow>();
            MainWindow.Show();
        }
        public static void AddComponentsTo(IWindsorContainer container) {
            AddGenericRepositoriesTo(container);
            AddCustomRepositoriesTo(container);
            AddApplicationServicesTo(container);

            container.AddComponent("validator", 
                typeof(IValidator), typeof(Validator));
        }
        public static void Initialize()
        {
            Container = new WindsorContainer();

            RegisterControllers();

            Container.AddComponent<IMessageProvider, WindsorMessageProvider>();
        }
Пример #25
0
        public void Install(IWindsorContainer container)
        {
            container.AddFacility<EventPublisherFacility>();
            container.AddFacility<StartableFacility>();
            container.AddFacility<DockingFacility>();
            container.AddFacility<MenuFacility>();

            container.AddComponent("applicationShell", typeof (IApplicationShell), typeof (ApplicationShell));
            
            container.AddComponent("presenter.factory", typeof (IPresenterFactory), typeof (PresenterFactory));

            container.Register(
                Component.For<IImageSource>().ImplementedBy<ResourceManagerImageSource>().Named("imageSource.res"));
            
            container.Register(
                Component.For<IImageFactory>()
                    .ImplementedBy<ImageFactory>()
                    .ServiceOverrides(
                    ServiceOverride.ForKey("sources").Eq<IImageSource>("imageSource.res")));

            // todo: refactor to register all views and presenters declaratively.
            container.Register(
                Component.For<IOutputView>().ImplementedBy<OutputView>(),
                Component.For<IOutputPresenter>().ImplementedBy<OutputPresenter>(),
                Component.For<IProjectExplorerView>().ImplementedBy<ProjectExplorerView>(),
                Component.For<IProjectExplorerPresenter>().ImplementedBy<ProjectExplorerPresenter>(),
                Component.For<IPropertyGridView>().ImplementedBy<PropertyGridView>(),
                Component.For<IPropertyGridPresenter>().ImplementedBy<PropertyGridPresenter>(),
                Component.For<IToolBoxView>().ImplementedBy<ToolBoxView>(),
                Component.For<IToolBoxPresenter>().ImplementedBy<ToolBoxPresenter>());

            container.Register(
                Component
                    .For<IMenuPresenter>()
                    .ImplementedBy<MenuStripPresenter>()
                    .Parameters(
                    Parameter
                        .ForKey("menu")
                        .Eq("${" + MainMenuToolStripKey + "}")));

            container.Register(AllTypes.Of<AbstractCommand>().FromAssembly(typeof (AbstractCommand).Assembly));

            container.Register(
                Component.For<DockedWindowsMenuModel>());
        }
        public void MBRInterfaceProxy()
        {
            _container.AddComponent("interceptor", typeof(ResultModifierInterceptor));
            _container.AddComponent("key", typeof(ICalcService), typeof(MarshalCalculatorService));

            ICalcService service = (ICalcService)_container.Resolve("key");

            Assert.IsNotNull(service);
            Assert.IsTrue(RemotingServices.IsTransparentProxy(service));
            Assert.AreEqual(7, service.Sum(2, 2));
        }
        public void BusinessLayerWithTransactions()
        {
            IWindsorContainer container = CreateConfiguredContainer();

            container.AddFacility("transaction", new TransactionFacility());

            container.AddComponent("blogdao", typeof(BlogDao));
            container.AddComponent("business", typeof(MyBusinessClass));

            MyBusinessClass service = (MyBusinessClass)container[typeof(MyBusinessClass)];
            Blog            blog    = service.Create("myblog");

            BlogDao dao = (BlogDao)container["blogdao"];

            IList blogs = dao.ObtainBlogs();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Count);
        }
        public static void AddComponentsTo(IWindsorContainer container)
        {
            AddGenericRepositoriesTo(container);
            AddCustomRepositoriesTo(container);
            AddApplicationServicesTo(container);
            AddWcfServiceFactoriesTo(container);

            container.AddComponent("validator",
                                   typeof(IValidator), typeof(Validator));
        }
Пример #29
0
        public MessageLoggingTests()
        {
            container = new WindsorContainer(new XmlInterpreter());
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            container.AddComponent <MessageLoggingModule>();

            messageSerializer = container.Resolve <IMessageSerializer>();

            transport = MockRepository.GenerateStub <ITransport>();
        }
Пример #30
0
        protected void Application_Start(object sender, EventArgs e)
        {
            container = new WindsorContainer(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Windsor.config"));

            container.AddFacility<MonoRailFacility>();
            container.Register(AllTypes.Of<IController>().FromAssembly(Assembly.GetExecutingAssembly()));

            container.Register(
                Component.For<DefinitionProvider>(),
                Component.For<DefinitionCreator<PersistentClass>>()
            );

            container.AddComponent<IConfigurationContributor, DynamicMappingFileContributor>();
            container.AddComponent<ITranslateFrom<PersistentClass>, TranslateFromPersistentClass>();
            container.AddComponent<INamedEntityRepository, NHNamedEntityRepository>();

            container.Resolve<IConfigurationContributor>();
            container.Resolve<ITranslateFrom<PersistentClass>>();
        }
Пример #31
0
        public MessageLoggingTests()
        {
            container = new WindsorContainer(new XmlInterpreter());
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            container.AddComponent<MessageLoggingModule>();

            messageSerializer = container.Resolve<IMessageSerializer>();

            transport = MockRepository.GenerateStub<ITransport>();
        }
Пример #32
0
        public static void Configure(IWindsorContainer container)
        {
            //allows us to take a dependency on arrays
            container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));

            //
            container.AddComponent<Dispatcher>("dispatcher");

            //argument parsing

            container.AddComponentLifeStyle<IArgumentParser, ArgumentParser>("argumentParser", LifestyleType.Transient);
            container.AddComponentLifeStyle<IArgumentMapFactory, ArgumentMapFactory>("argumentMapFactory", LifestyleType.Transient);

            //helper shims
            container.AddComponentLifeStyle<IConsole, ConsoleHelper>("consoleHelper", LifestyleType.Transient);
            container.AddComponentLifeStyle<IPath, PathAdapter>("pathAdapter", LifestyleType.Transient);
            container.AddComponentLifeStyle<IFileSystem, FileSystem>("fileSystem", LifestyleType.Transient);

            //templating
            container.AddComponentLifeStyle<ITemplateProcessor, NVelocityTemplateProcessor>("templateProcessor",
                                                                                                LifestyleType.Transient);

            //package repository
            container.AddComponent<IPackageRepository, LocalPackageRepository>("package.repository");

            //project stuff
            container.AddComponentLifeStyle<IProjectManifestStore, XmlProjectManifestStore>("xmlProjectStore", LifestyleType.Transient);
            container.AddComponentLifeStyle<IProjectManifestRepository, ProjectManifestRepository>("projectManifestRepository", LifestyleType.Transient);

            //default package commands
            container.AddComponent<ICommand, HelpCommand>("help");
            container.Register(
                Component.For<ICommand>().ImplementedBy<NewProjectCommand>()
                .Named("project")
                .Parameters(
                    Parameter.ForKey("rootTemplateDirectory").Eq("a"), //TODO: correct this
                    Parameter.ForKey("defaultTemplate").Eq("b"))); //TODO: Correct this

            SetupNewProject(container);
            container.AddComponent<ICommand, ListCommand>("list");
            container.AddComponent<ICommand, InstallCommand>("install");
        }
Пример #33
0
        public static void AddComponentsTo(IWindsorContainer container)
        {
            AddGenericRepositoriesTo(container);
            AddCustomRepositoriesTo(container);
            AddTasksTo(container);
            AddQueryServicesTo(container);
            AddMappersTo(container);

            container.Register(Component.For <CommandProcessor, ICommandProcessor>());
            container.Register(Component.For <FileAttachmentUtility, IFileAttachmentUtility>());
            container.Register(Component.For <HttpRuntimeCache, ICache>());
            //container.Register(Component.For<Log4NetLogger, ILogger>());
            container.Register(Component.For <EnsNhUnitOfWork, IUnitOfWork>().Named("uow"));
            container.Register(Component.For <DefaultSessionFactoryKeyProvider, ISessionFactoryKeyProvider>().Named("ISessionFactoryKeyProvider"));

            // 缓存映射
            container.AddComponent("cache", typeof(ICache), typeof(HttpRuntimeCache));
            //// 日志记录
            container.AddComponent("logger", typeof(Cotide.Framework.Logging.ILogServer), typeof(Cotide.Framework.Logging.Log4NetLogServer));
        }
Пример #34
0
        private static void AddWcfServiceFactoriesTo(IWindsorContainer container)
        {
            container.AddFacility("factories", new FactorySupportFacility());
            container.AddComponent("standard.interceptor", typeof(StandardInterceptor));

            var factoryKey = "territoriesWcfServiceFactory";
            var serviceKey = "territoriesWcfService";

            container.AddComponent(factoryKey, typeof(TerritoriesWcfServiceFactory));
            var config = new MutableConfiguration(serviceKey);

            config.Attributes["factoryId"]     = factoryKey;
            config.Attributes["factoryCreate"] = "Create";
            container.Kernel.ConfigurationStore.AddComponentConfiguration(serviceKey, config);
            container.Kernel.AddComponent(
                serviceKey,
                typeof(ITerritoriesWcfService),
                typeof(TerritoriesWcfServiceClient),
                LifestyleType.PerWebRequest);
        }
        public static void AddComponentsTo(IWindsorContainer container, Type transactionManagerType)
        {
            ParameterCheck.ParameterRequired(container, "container");
            ParameterCheck.ParameterRequired(transactionManagerType, "transactionManagerType");

            if (!container.Kernel.HasComponent("TransactionManager")) {
                Core.CastleWindsor.ComponentRegistrar.AddComponentsTo(container);
                container.AddComponent("TransactionManager", typeof(ITransactionManager),
                                       transactionManagerType);
            }
        }
Пример #36
0
        public TwoBusesCommunicating()
        {
            container1 = new WindsorContainer(new XmlInterpreter());
            container2 = new WindsorContainer(new XmlInterpreter("AnotherBus.config"));

            container1.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            container2.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());

            container1.AddComponent <PingHandler>();
            container2.AddComponent <PongHandler>();
        }
Пример #37
0
        public static void AddComponentsTo(IWindsorContainer container)
        {
            AddGenericRepositoriesTo(container);
            AddCustomRepositoriesTo(container);
            AddApplicationServicesTo(container);

            container.AddComponent("validator",
                typeof(IValidator), typeof(Validator));

            container.Register(Component.For<IRPXService>().ImplementedBy<RPXService>());
            container.Register(Component.For<IRPXApiSettings>().ImplementedBy<RPXApiSettings>());
        }
        public static void AddComponentsTo(IWindsorContainer container, Type transactionManagerType)
        {
            ParameterCheck.ParameterRequired(container, "container");
            ParameterCheck.ParameterRequired(transactionManagerType, "transactionManagerType");

            if (!container.Kernel.HasComponent("TransactionManager"))
            {
                Core.CastleWindsor.ComponentRegistrar.AddComponentsTo(container);
                container.AddComponent("TransactionManager", typeof(ITransactionManager),
                                       transactionManagerType);
            }
        }
Пример #39
0
        public void SimpleTest()
        {
            container.AddComponent("component", typeof(Classes.LoggingComponent));
            Classes.LoggingComponent test = container["component"] as Classes.LoggingComponent;

            test.DoSomething();

            String expectedLogOutput = String.Format("[Info] '{0}' Hello world\r\n", typeof(Classes.LoggingComponent).FullName);
            String actualLogOutput   = outWriter.GetStringBuilder().ToString();

            Assert.AreEqual(expectedLogOutput, actualLogOutput);
        }
Пример #40
0
        public void AllowAdmin()
        {
            IWindsorContainer container = this.CreateConfiguredContainer();

            container.AddFacility("security", new SecurityFacility());
            container.AddComponent("test", typeof(SecureComponent));

            SecureComponent s = container["test"] as SecureComponent;

            LoginAsAdmin();
            s.AllowMethod();
        }
Пример #41
0
        public MessageModuleTests()
        {
            Module2.Stopped = Module2.Started = false;

            container = new WindsorContainer(new XmlInterpreter());
            container.Kernel.AddFacility("rhino.esb",
                                         new RhinoServiceBusFacility()
                                         .AddMessageModule <Module1>()
                                         .AddMessageModule <Module2>()
                                         );

            container.AddComponent <BadHandler>();
        }
Пример #42
0
        public void WiringRemoteComponentCallback()
        {
            IWindsorContainer clientContainer = CreateRemoteContainer(clientDomain,
                                                                      "../Castle.Facilities.Remoting.Tests/client_simple_scenario.xml");

            clientContainer.AddComponent("comp", typeof(ConsumerComp));

            ConsumerComp service = (ConsumerComp)clientContainer[typeof(ConsumerComp)];

            Assert.IsNotNull(service.Calcservice);
            Assert.IsTrue(RemotingServices.IsTransparentProxy(service.Calcservice));
            Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(service.Calcservice));
        }
        public With_accepting_work_queue()
        {
            if (MessageQueue.Exists(acceptingWorkQueuePath) == false)
            {
                MessageQueue.Create(acceptingWorkQueuePath);
            }
            var acceptingWork = new MessageQueue(acceptingWorkQueuePath);

            acceptingWork.Purge();

            var interpreter = new XmlInterpreter(@"LoadBalancer\BusWithAcceptingWorkLoadBalancer.config");

            container = new WindsorContainer(interpreter);
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());

            container.AddComponent <MyHandler>();

            container.Register(
                Component.For <MsmqLoadBalancer>()
                .DependsOn(new
            {
                threadCount           = 1,
                endpoint              = new Uri(loadBalancerQueue),
                transactional         = TransactionalOptions.FigureItOut,
                secondaryLoadBalancer = TestQueueUri2.Uri
            })
                );

            container.Register(
                Component.For <MsmqReadyForWorkListener>()
                .DependsOn(new
            {
                threadCount   = 1,
                endpoint      = new Uri(acceptingWorkQueue),
                transactional = TransactionalOptions.FigureItOut
            })
                );

            container.Register(
                Component.For <MsmqSecondaryLoadBalancer>()
                .DependsOn(new
            {
                threadCount         = 1,
                endpoint            = TestQueueUri2.Uri,
                primaryLoadBalancer = new Uri(loadBalancerQueue),
                transactional       = TransactionalOptions.FigureItOut
            })
                );
        }
Пример #44
0
        public static void AddComponentsTo(IWindsorContainer container)
        {
            AddGenericRepositoriesTo(container);
            AddCustomRepositoriesTo(container);
            AddApplicationServicesTo(container);

            container.AddComponent("tokenizer",
                                   typeof(ITokenizer), typeof(ExpireTokenizer));

            container.AddComponent("encryptionHelper",
                                   typeof(IEncryptionHelper), typeof(EncryptionHelper));

            container.AddComponent("passwordGenerator",
                                   typeof(IPasswordGenerator), typeof(BasicPasswordGenerator));

            container.AddComponent("hashGenerator",
                                   typeof(IHashGenerator), typeof(Sha1HashGenerator));

            container.AddComponent("stringEncryptor",
                                   typeof(IStringEncryptor), typeof(TripleDesStringEncryptor));

            container.AddComponent("saltGenerator",
                                   typeof(ISaltGenerator), typeof(SaltGenerator));

            container.AddComponent("authenticationService",
                                   typeof(IAuthenticationService <IUserContext>), typeof(FormsAuthenticationService <IUserContext>));

            container.AddComponent("messageSenderService",
                                   typeof(IMessageSenderService), typeof(SmtpMessageSenderService));

            container.AddComponent("cache",
                                   typeof(ICache), typeof(WebCache));

            container.AddComponent("validator",
                                   typeof(IValidator), typeof(Validator));
        }
Пример #45
0
        public void CommonUsage()
        {
            IWindsorContainer container = CreateConfiguredContainer();

            container.AddComponent("blogdao", typeof(BlogDao));

            BlogDao dao = (BlogDao)container["blogdao"];

            dao.CreateBlog("my blog");

            IList blogs = dao.ObtainBlogs();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Count);
        }
Пример #46
0
        private void RegisterTypes(Assembly interfaces, Assembly implementation, bool registerComponents)
        {
            var lst = (from t in interfaces.GetTypes()
                       where t.IsInterface
                       select t).ToList();

            foreach (var t in lst)
            {
                Type impl = implementation.GetTypes().Where(type => type.GetInterfaces().Where(x => x == t).Count() > 0).First();
                container.Register(Component.For(t).ImplementedBy(impl).LifeStyle.Transient);
                if (registerComponents)
                {
                    container.AddComponent(impl.Name, impl);
                }
            }
        }
Пример #47
0
        public void Run(StopWatch watch)
        {
            _container = new HeavyLoadContainer();

            _bus = _container.Resolve <IServiceBus>();

            var management = MsmqEndpointManagement.New(_bus.Endpoint.Address.Uri);

            management.Purge();

            watch.Start();

            //BatchServiceComponent component = new BatchServiceComponent();

            //_bus.Subscribe(component);

            _container.AddComponent <BatchServiceComponent>();

            _bus.Subscribe <BatchServiceComponent>();

            int batchCount = 100;

            CheckPoint publishCheckpoint = watch.Mark("Publishing " + batchCount + " batches");

            _threads = new ManagedThreadPool <int>(delegate(int batchLength) { SendBatch(batchLength); }, 10, 10);

            for (int i = 0; i < batchCount; i++)
            {
                _threads.Enqueue(100);
            }

            for (int i = 0; i < batchCount; i++)
            {
                bool received = BatchServiceComponent.Received.WaitOne(TimeSpan.FromSeconds(30), true);
                if (!received)
                {
                    _log.Error("Something went wrong, we never got a batch completed");
                    break;
                }
            }

            publishCheckpoint.Complete(batchCount * 100);

            watch.Stop();

            _log.Info("Test Complete");
        }
Пример #48
0
        public void TransactionalUsage()
        {
            IWindsorContainer container = CreateConfiguredContainer();

            container.AddFacility("transaction", new TransactionFacility());

            container.AddComponent("blogdao", typeof(BlogDaoTransactional));

            BlogDao dao = (BlogDao)container["blogdao"];

            dao.CreateBlog("my blog");

            IList blogs = dao.ObtainBlogs();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Count);
        }
Пример #49
0
        public void Factory1()
        {
            _facility.AddTypedFactoryEntry(
                new FactoryEntry(
                    "protocolHandlerFactory", typeof(IProtocolHandlerFactory1), "Create", "Release"));

            _container.AddComponent("miranda", typeof(IProtocolHandler), typeof(MirandaProtocolHandler));
            _container.AddComponent("messenger", typeof(IProtocolHandler), typeof(MessengerProtocolHandler));

            IProtocolHandlerFactory1 factory =
                (IProtocolHandlerFactory1)_container["protocolHandlerFactory"];

            Assert.IsNotNull(factory);

            IProtocolHandler handler = factory.Create();

            Assert.IsNotNull(handler);

            factory.Release(handler);
        }
Пример #50
0
        public With_load_balancing()
        {
            var interpreter = new XmlInterpreter(@"LoadBalancer\BusWithLoadBalancer.config");

            container = new WindsorContainer(interpreter);
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());

            container.AddComponent <MyHandler>();

            container.Register(
                Component.For <MsmqLoadBalancer>()
                .DependsOn(new
            {
                threadCount   = 1,
                endpoint      = new Uri(loadBalancerQueue),
                transactional = TransactionalOptions.FigureItOut
            })
                );
        }
Пример #51
0
 private static void RegisterTestServices(IWindsorContainer container)
 {
     container.AddComponent("LogTestClass", typeof(ILogTestClass), typeof(LogTestClass));
     container.AddComponent("SystemTransactionTestProvider", typeof(ITransactionTestProvider),
                            typeof(SystemTransactionTestProvider));
     container.AddComponent("NHibernateTransactionTestProvider", typeof(ITransactionTestProvider),
                            typeof(NHibernateTransactionTestProvider));
     container.AddComponent("SystemUnitOfWorkTestProvider", typeof(ITransactionTestProvider),
                            typeof(SystemUnitOfWorkTestProvider));
     container.AddComponent("NHibernateUnitOfWorkTestProvider", typeof(ITransactionTestProvider),
                            typeof(NHibernateUnitOfWorkTestProvider));
     container.AddComponent("ExceptionHandlerTestClass", typeof(IExceptionHandlerTestClass),
                            typeof(ExceptionHandlerTestClass));
 }
        public Full_test_of_load_balancer_and_failover_and_recovery()
        {
            var loadBalancerQueuePathUri = new Uri(loadBalancerQueue).ToEndpoint().Uri;
            var lb2Endpoint               = new Uri("msmq://localhost/test_queue.balancer2").ToEndpoint();
            var loadBalancerQueuePath2    = MsmqUtil.GetQueuePath(lb2Endpoint).QueuePath;
            var loadBalancerQueuePathUri2 = lb2Endpoint.Uri;

            if (MessageQueue.Exists(loadBalancerQueuePath2))
            {
                MessageQueue.Delete(loadBalancerQueuePath2);
            }
            MessageQueue.Create(loadBalancerQueuePath2, true);

            container = new WindsorContainer(new XmlInterpreter(@"LoadBalancer\SendingBusToLoadBalancer.config"));
            container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            container.Register(
                Component.For <MsmqLoadBalancer>()
                .DependsOn(new
            {
                endpointRouter        = new EndpointRouter(),
                threadCount           = 1,
                endpoint              = loadBalancerQueuePathUri,
                secondaryLoadBalancer = loadBalancerQueuePathUri2,
                transactional         = TransactionalOptions.FigureItOut
            }).LifeStyle.Transient,
                Component.For <MsmqSecondaryLoadBalancer>()
                .DependsOn(new
            {
                endpointRouter      = new EndpointRouter(),
                threadCount         = 1,
                endpoint            = loadBalancerQueuePathUri2,
                primaryLoadBalancer = loadBalancerQueuePathUri,
                transactional       = TransactionalOptions.FigureItOut
            })
                );

            //New conatainer to more closely mimic as separate app.
            receivingBusContainer = new WindsorContainer(new XmlInterpreter(@"LoadBalancer\ReceivingBusWithLoadBalancer.config"));
            receivingBusContainer.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility());
            receivingBusContainer.AddComponent <TestHandler>();
        }
Пример #53
0
 private static void AddGenericRepositoriesTo(IWindsorContainer container)
 {
     container.AddComponent(
         "entityDuplicateChecker", typeof(IEntityDuplicateChecker), typeof(EntityDuplicateChecker));
     container.AddComponent(
         "sessionFactoryKeyProvider", typeof(ISessionFactoryKeyProvider), typeof(DefaultSessionFactoryKeyProvider));
     container.AddComponent("repositoryType", typeof(IRepository <>), typeof(NHibernateRepository <>));
     container.AddComponent(
         "nhibernateRepositoryType", typeof(INHibernateRepository <>), typeof(NHibernateRepository <>));
     container.AddComponent(
         "repositoryWithTypedId", typeof(IRepositoryWithTypedId <,>), typeof(NHibernateRepositoryWithTypedId <,>));
     container.AddComponent(
         "nhibernateRepositoryWithTypedId",
         typeof(INHibernateRepositoryWithTypedId <,>),
         typeof(NHibernateRepositoryWithTypedId <,>));
 }
Пример #54
0
        public void CommonUsageMultithread()
        {
            IWindsorContainer container = CreateConfiguredContainer();

            container.AddComponent("blogdao", typeof(BlogDao));
            _dao = (BlogDao)container["blogdao"];

            const int threadCount = 10;

            Thread[] threads = new Thread[threadCount];

            for (int i = 0; i < threadCount; i++)
            {
                threads[i] = new Thread(new ThreadStart(ExecuteMethodUntilSignal));
                threads[i].Start();
            }

            _startEvent.Set();

            Thread.CurrentThread.Join(1 * 2000);

            _stopEvent.Set();
        }
Пример #55
0
        private static void RegisterComponents(IWindsorContainer container)
        {
            container.AddComponent("graphDAO", typeof(GraphDAO), typeof(GraphDAO));

            container.AddFacility <WcfFacility>();

            container.Register(
                Component.For <MessageLifecycleBehavior>(),
                Component.For <IGraphTraversalService>()
                .ImplementedBy <GraphTraversalService>()
                .Named("GraphTraversalService")
                .LifeStyle.Transient
                .ActAs(new DefaultServiceModel()
                       .AddEndpoints(WcfEndpoint
                                     .BoundTo(new NetTcpBinding())
                                     //.At("net.tcp://localhost:8082/GraphTraversalService")
                                     .At(String.Format("net.tcp://{0}/GraphTraversalService", pathfinderRemoteServiceWorkerRoleEndpoint))
                                     // adds this message action to this endpoint
                                     .AddExtensions(new LifestyleMessageAction()
                                                    )
                                     ))
                );
        }
Пример #56
0
 protected override void DoInstall(IWindsorContainer container)
 {
     container.AddComponent("TestObject", typeof(ITestObject), typeof(TestObject));
 }
Пример #57
0
 private static void AddWcfServicesTo(IWindsorContainer container)
 {
     // Since the TerritoriesService.svc must be associated with a concrete class,
     // we must register the concrete implementation here as the service
     container.AddComponent("territoriesWcfService", typeof(TerritoriesWcfService));
 }
Пример #58
0
 void IContainer.RegisterComponent(string key, Type classType)
 {
     _container.AddComponent(key, classType);
 }
Пример #59
0
 /// <summary>
 /// 向容器中注册一个实例
 /// </summary>
 /// <param name="instance">类型T的实例</param>
 public void Register <T>(T instance)
 {
     _container.AddComponent <T>();
 }
Пример #60
0
 public static DependencyAdder Register <Interface, Implementation>(string key)
 {
     EnsureInitialized();
     _container.AddComponent(key, typeof(Interface), typeof(Implementation));
     return(new DependencyAdder(key, _container.Kernel));
 }