Example #1
0
 private static void AddApplicationServicesTo(IWindsorContainer container)
 {
     container.Register(
         AllTypes.Pick()
         .FromAssemblyNamed("Anuncios.ApplicationServices")
         .WithService.FirstInterface());
 }
Example #2
0
        private static IWindsorContainer InitContainer()
        {
            IWindsorContainer container = new WindsorContainer();

            container.Register(
                AllTypes
                .Pick()
                .FromAssembly(typeof(IController).Assembly)
                .Unless(type => type.IsAbstract)
                .WithService.FirstInterface()
                .Configure(registration =>
            {
                if (!typeof(IController).IsAssignableFrom(registration.Implementation))
                {
                    return;
                }

                registration.LifeStyle.Is(LifestyleType.Transient);
                string componentName = registration.Implementation.Name;
                componentName        = (componentName.Substring(0, componentName.Length - "Controller".Length));
                registration.Named(componentName.ToLowerInvariant());
            })
                );

            return(container);
        }
Example #3
0
        protected void Application_Start(object sender, EventArgs e)
        {
            var container = new WindsorContainer();

            container.Register(
                AllTypes
                .Pick().FromAssembly(typeof(ProductPresenter).Assembly)
                .If(s => s.Name.EndsWith("Presenter"))
                .WithService.FirstInterface()
                );

            container.Register(
                AllTypes
                .Pick().FromAssembly(typeof(ProductService).Assembly)
                .If(s => s.Name.EndsWith("Service"))
                .WithService.FirstInterface()
                );

            container.Register(
                AllTypes
                .Pick().FromAssembly(typeof(ProductRepository).Assembly)
                .If(s => s.Name.EndsWith("Repository"))
                .WithService.FirstInterface()
                );
            container.Register(Component.For <IDataContext>().ImplementedBy <MyOrmDataContext>());
            container.Register(Component.For <IProductView>().ImplementedBy <Default>());

            IoC.Init(container);
        }
Example #4
0
 private static void AddCustomRepositoriesTo(IWindsorContainer container)
 {
     container.Register(
         AllTypes.Pick()
         .FromAssemblyNamed("Anuncios.Data")
         .WithService.FirstNonGenericCoreInterface("Anuncios.Core"));
 }
Example #5
0
 private static void RegisterControllers()
 {
     container
     .Register(AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly())
               .Configure(c => c.LifeStyle.Transient)
               .If(c => c.Name.Contains("Controller")));
 }
Example #6
0
 public static void AddServicesTo(IWindsorContainer container)
 {
     container.Register(
         AllTypes.Pick()
         .FromAssemblyNamed("FashionAde.Services")
         .WithService.FirstInterface());
 }
Example #7
0
    static void Main(string[] args)
    {
        var container = new WindsorContainer();

        container.Register(AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly()).AllowMultipleMatches());
        var dog     = container.Resolve <Dog>();
        var animals = container.ResolveAll <IAnimal>();
    }
    protected override void Init()
    {
        var asmList = FacilityConfig.Children["assemblies"].Children;

        foreach (var asm in asmList)
        {
            Kernel.Register(AllTypes.Pick().FromAssemblyNamed(asm.Value));
        }
    }
Example #9
0
        private static void AddCustomRepositoriesTo(IWindsorContainer container)
        {
            container.Register(
                AllTypes.Pick().FromAssemblyNamed("__NAME__.Infrastructure").WithService.FirstNonGenericCoreInterface(
                    "__NAME__.Domain"));

            container.Register(
                AllTypes.Pick().FromAssemblyNamed("__NAME__.Tasks").WithService.FirstNonGenericCoreInterface(
                    "__NAME__.Domain.Contracts.Tasks"));
        }
Example #10
0
 private static void AddCustomRepositoriesTo(IWindsorContainer container)
 {
     container.Register(
         AllTypes.Pick()
         .FromAssemblyNamed("wrms.Data")
         .WithService.FirstNonGenericCoreInterface("wrms.Core"));
     container.Register(
         AllTypes.Pick()
         .FromAssemblyNamed("TimeEntryAuditConsole")
         .WithService.FirstInterface());
 }
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                AllTypes.Of <IController>().FromAssembly(Assembly.GetExecutingAssembly()).Configure(c => c.LifestyleTransient()));


            container.Register(AllTypes.Pick().FromAssemblyNamed("Marketplace.Interview.Business")
                               .Configure(c => c.LifestyleTransient())
                               .If(t => t.FindInterfaces((t1, o) => t1.Name == "IWorkflow", null).Length > 0)
                               .BasedOn(typeof(IWorkflow <,>)).WithService.FromInterface(typeof(IWorkflow <,>)));
        }
Example #12
0
 private static void AddSecurityRepositoriesTo(IWindsorContainer container)
 {
     container.Register(
         AllTypes.Pick()
         .FromAssemblyNamed("wrms.Web.Controllers")
         .WithService.FirstInterface());
     container.Register(
         AllTypes.Pick()
         .FromAssemblyNamed("TucsonAz.Framework")
         .WithService.FirstInterface());
 }
 private void RegisterServices(IKernel kernel)
 {
     kernel.Register(
         AllTypes.Pick().FromAssembly(_assembly)
         .If(t => t.Name.EndsWith("Service"))
         .Configure(c => c.LifeStyle.Transient)
         .WithService.FirstInterface()
         .ConfigureFor <IAlbumService>(c => c.Parameters(Parameter.ForKey("albumRootDirPath").Eq(HostingEnvironment.MapPath("~/App_Data/Albums/"))))
         .ConfigureFor <IProfileService>(c => c.Parameters(Parameter.ForKey("profilesDirectoryPath").Eq(HostingEnvironment.MapPath("~/App_Data/Profiles/"))))
         .ConfigureFor <IRoleService>(c => c.Parameters(Parameter.ForKey("rolesDirectoryPath").Eq(HostingEnvironment.MapPath("~/App_Data/Roles/"))))
         );
 }
Example #14
0
        //public const string WindsorConfigFilename = @"Windsor.config.xml";

        public static void CommonSetup()
        {
            _container.Register(AllTypes.Pick()
                                .FromAssembly(typeof(EDIContainer).Assembly)
                                .WithService
                                .FirstInterface()
                                .Configure(x => x.Named(x.Implementation.Name)));

//            Register<IEdiConfiguration, EdiConfiguration>();
//            Register<IFileUtilities, FileUtilities>();
//            Register<IFileSystemDataSet, FileSystemDataSet>();
        }
Example #15
0
        private void Bootstrapper()
        {
            IWindsorContainer container = new WindsorContainer();

            // IFooService with DummyFooService
            container.Register(AllTypes.Pick().FromAssembly(typeof(MvcApplication).Assembly)
                               .WithService.FirstInterface());
            // Controller
            container.RegisterControllers(typeof(HomeController).Assembly);

            // Set the controller factory
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
        }
        public void Registering_With_FirstInterfaceOnClass()
        {
            var container = new WindsorContainer();

            container.Register(AllTypes.Pick(TypesToRegister)
                               .Where(t => t != null /*Any Predicate*/)
                               .WithService.FirstInterfaceOnClass());

            var component = container.Resolve <IFirst>();

            Assert.NotNull(component);
            Assert.Throws <ComponentNotFoundException>(() => container.Resolve <ISecond>());
        }
Example #17
0
        static void Main(string[] args)
        {
            IWindsorContainer container = new WindsorContainer();

            container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel));
            container.Register(AllTypes.Pick().FromAssembly(typeof(ApplicationRunner).Assembly)
                               .WithService.FirstInterface());

            IApplicationRunner runner = container.Resolve <IApplicationRunner>();

            runner.Run();

            Console.ReadLine();
        }
    public void Interceptor()
    {
        var container = new WindsorContainer();

        container.Register(
            Component.For <MyInterceptor>().LifeStyle.Transient,
            AllTypes.Pick()
            .From(typeof(Foo))
            .If(t => typeof(IFoo).IsAssignableFrom(t))
            .Configure(c => c.LifeStyle.Is(LifestyleType.Transient)
                       .Interceptors(new InterceptorReference(typeof(MyInterceptor))).Anywhere)
            .WithService.Select(new[] { typeof(IFoo) }));
        container.Resolve <IFoo>().Do();
    }
Example #19
0
        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.Register(Component.For <IMessageBus>()
                               .ImplementedBy <MessageBus>()
                               .LifeStyle.Singleton);

            container.Register(Component.For <IWindsorContainer>()
                               .Instance(container));

            container.Register(Component.For <IApplicationEvents>()
                               .ImplementedBy <EsbApplicationEventsImpl>());

            container.Register(Component.For <IHandlingEventService>()
                               .ImplementedBy <HandlingEventService>());

            container.Register(Component.For <HandlingEventFactory>()
                               .ImplementedBy <HandlingEventFactory>());

            container.Register(Component.For <ICargoInspectionService>()
                               .ImplementedBy <CargoInspectionService>());

            container.AddFacility <WcfFacility>();

            container.Register(
                Component.For <MessageLifecycleBehavior>(),
                Component.For <UnitOfWorkBehavior>(),
                Component
                .For <IHandlingReportService>()
                .ImplementedBy <HandlingReportService>()
                .Named("HandlingReportService")
                .LifeStyle.Transient
                .ActAs(new DefaultServiceModel()
                       .AddEndpoints(WcfEndpoint
                                     .BoundTo(new BasicHttpBinding())
                                     //.At("http://localhost:8089/HandlingReportServiceFacade")
                                     .At(new Uri(String.Format("http://{0}/HandlingReportServiceFacade", handlingServiceWorkerRoleEndpoint)))
                                     // adds this message action to this endpoint
                                     .AddExtensions(new LifestyleMessageAction()
                                                    )
                                     ))
                );
        }
Example #20
0
        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);
        }
Example #21
0
        private static void AddCustomRepositoriesTo(IWindsorContainer container)
        {
            container.Register(
                AllTypes.Pick()
                //Scan repository assembly for domain model interfaces implementation
                .FromAssemblyNamed("NDDDSample.Persistence.NHibernate")
                .WithService.FirstNonGenericCoreInterface("NDDDSample.Domain.Model"));

            container.AddFacility <WcfFacility>();

            container.Register(
                Component.For <MessageLifecycleBehavior>(),
                Component.For <IBookingServiceFacade>()
                .Named("bookingServiceFacade")
                .LifeStyle.Transient
                .ActAs(DefaultClientModel
                       .On(WcfEndpoint.BoundTo(new NetTcpBinding())
                           .At(String.Format("net.tcp://{0}/BookingServiceFacade", bookingRemoteServiceWorkerRoleEndpoint))
                           )));
        }
        public ContainerControllerFactory()
        {
            container = new WindsorContainer();

            container.Register(
                AllTypes.Of(typeof(IController))
                .FromAssembly(typeof(HomeController).Assembly)
                );

            container.Register(
                AllTypes
                .Pick().FromAssembly(typeof(ProductService).Assembly)
                .If(s => s.Name.EndsWith("Service"))
                .WithService.FirstInterface()
                );

            container.Register(
                AllTypes
                .Pick().FromAssembly(typeof(ProductRepository).Assembly)
                .If(s => s.Name.EndsWith("Repository"))
                .WithService.FirstInterface()
                );
            container.Register(Component.For <IDataContext>().ImplementedBy <MyOrmDataContext>());
        }
Example #23
0
 public IWindsorContainer Create()
 {
     if (null == container)
     {
         container = new WindsorContainer();
         container.Register(
             AllTypes
             .Pick()
             .FromAssembly(GetType().Assembly)
             .WithService
             .FirstInterface()
             .Unless(criteriaToSatisfy.IsSatisfiedBy)
             .Configure(
                 delegate(ComponentRegistration registration) {
             this.LogInformational("{1}-{0}", registration.Implementation, registration.ServiceType.Name);
             if (registration.Implementation.GetInterfaces().Length == 0)
             {
                 registration.For(registration.Implementation);
             }
         })
             );
     }
     return(container);
 }
Example #24
0
 private static void AddCustomRepositoriesTo(IWindsorContainer container)
 {
     container.Register(
         AllTypes.Pick().FromAssemblyNamed("Northwind.Infrastructure").WithService.DefaultInterface());
 }