Пример #1
0
 /// <summary>Initializes a new instance of the <see cref="WindsorComponentProvider"/> class.</summary>
 public WindsorComponentProvider()
 {
     _container = new WindsorContainer();
     _container.Kernel.Resolver.AddSubResolver(new AutoClosingCollectionResolver(_container.Kernel));
     _container.Kernel.Resolver.AddSubResolver(new CollectionResolver(_container.Kernel, true));
     _container.Register(Component.For <WindsorComponentProvider>().Instance(this));
     _genericImplementationMatchingStrategy = new DefaultGenericImplementationMatchingStrategy(this);
 }
Пример #2
0
        /// <summary>
        ///   Sets the concrete type that implements the service to <paramref name = "type" />.
        ///   <para />
        ///   If not set, the class service type or first registered interface will be used as the implementation for this component.
        /// </summary>
        /// <param name = "type">The type that is the implementation for the service.</param>
        /// <param name = "genericImplementationMatchingStrategy">Provides ability to close open generic service. Ignored when registering closed or non-generic component.</param>
        /// <returns></returns>
        public ComponentRegistration <TService> ImplementedBy(Type type, IGenericImplementationMatchingStrategy genericImplementationMatchingStrategy)
        {
            if (implementation != null && implementation != typeof(LateBoundComponent))
            {
                var message = String.Format("This component has already been assigned implementation {0}",
                                            implementation.FullName);
                throw new ComponentRegistrationException(message);
            }

            implementation = type;
            if (genericImplementationMatchingStrategy == null)
            {
                return(this);
            }
            return(ExtendedProperties(Property.ForKey(ComponentModel.GenericImplementationMatchingStrategy).Eq(genericImplementationMatchingStrategy)));
        }
Пример #3
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "DefaultGenericHandler" /> class.
 /// </summary>
 /// <param name = "model"></param>
 /// <param name = "implementationMatchingStrategy"></param>
 public DefaultGenericHandler(ComponentModel model, IGenericImplementationMatchingStrategy implementationMatchingStrategy) : base(model)
 {
     this.implementationMatchingStrategy = implementationMatchingStrategy;
 }
Пример #4
0
		/// <summary>
		///   Initializes a new instance of the <see cref = "DefaultGenericHandler" /> class.
		/// </summary>
		/// <param name = "model"></param>
		/// <param name = "implementationMatchingStrategy"></param>
		public DefaultGenericHandler(ComponentModel model, IGenericImplementationMatchingStrategy implementationMatchingStrategy) : base(model)
		{
			this.implementationMatchingStrategy = implementationMatchingStrategy;
		}
 public CloseConversionPatternContributor(IGenericImplementationMatchingStrategy implemenetationMatchingStrategy, IGenericServiceStrategy genericServiceStrategy)
 {
     this.implemenetationMatchingStrategy = implemenetationMatchingStrategy;
     this.genericServiceStrategy = genericServiceStrategy;
 }