Exemple #1
0
        public IWindsorContainer AddComponent <T>()
        {
            var t = typeof(T);

            AddComponent(ComponentName.DefaultNameFor(t), t);
            return(this);
        }
Exemple #2
0
        public IWindsorContainer AddComponentLifeStyle <I, T>(LifestyleType lifestyle) where T : class
        {
            var t = typeof(T);

            AddComponentLifeStyle(ComponentName.DefaultNameFor(t), typeof(I), t, lifestyle);
            return(this);
        }
Exemple #3
0
        public IWindsorContainer AddComponentWithProperties <T>(IDictionary extendedProperties)
        {
            var t = typeof(T);

            AddComponentWithProperties(ComponentName.DefaultNameFor(t), t, extendedProperties);
            return(this);
        }
Exemple #4
0
        public IWindsorContainer AddComponent <I, T>() where T : class
        {
            var t = typeof(T);

            AddComponent(ComponentName.DefaultNameFor(t), typeof(I), t);
            return(this);
        }
Exemple #5
0
 /// <summary>
 ///   Builds a service override using other component registered with given <paramref name = "componentImplementation" /> and no explicit name, as value for dependency with given <see
 ///    cref = "Key" />.
 /// </summary>
 /// <returns></returns>
 public ServiceOverride Is(Type componentImplementation)
 {
     if (componentImplementation == null)
     {
         throw new ArgumentNullException(nameof(componentImplementation));
     }
     return(GetServiceOverrideKey().Eq(ComponentName.DefaultNameFor(componentImplementation)));
 }
Exemple #6
0
        protected string GetName(Type service)
        {
            var defaultName = ComponentName.DefaultNameFor(service);

            if (string.IsNullOrEmpty(defaultName))
            {
                return("auto-factory: " + Guid.NewGuid());
            }
            return("auto-factory: " + defaultName);
        }
Exemple #7
0
        private static void DeserializeComponent(XmlNode node, IConfigurationStore store, IConversionManager converter)
        {
            var config = XmlConfigurationDeserializer.GetDeserializedNode(node);
            var id     = config.Attributes["id"];

            if (string.IsNullOrEmpty(id))
            {
                var type = converter.PerformConversion <Type>(config.Attributes["type"]);
                id = ComponentName.DefaultNameFor(type);
                config.Attributes["id"] = id;
                config.Attributes.Add("id-automatic", bool.TrueString);
            }
            AddComponentConfig(id, config, store);
        }
        public void Picks_component_implemented_by_that_type_with_default_name_if_multiple()
        {
            Container.Register(Component.For <CommonServiceUser>()
                               .DependsOn(Dependency.OnComponent <ICommon, CommonImpl2>()),
                               Component.For <ICommon>().ImplementedBy <CommonImpl1>(),
                               Component.For <ICommon>().ImplementedBy <CommonImpl2>().Named("something"),
                               Component.For <ICommon>().ImplementedBy <CommonImpl2>());

            var item = Container.Resolve <CommonServiceUser>();

            Assert.IsInstanceOf <CommonImpl2>(item.CommonService);

            var default2 = Container.Resolve <ICommon>(ComponentName.DefaultNameFor(typeof(CommonImpl2)));

            Assert.AreSame(default2, item.CommonService);
        }
 private void Apply(ComponentModel model, Object dependencyKey, Object dependencyValue, ServiceOverride @override)
 {
     if (dependencyValue is String)
     {
         ApplySimpleReference(model, dependencyKey, (String)dependencyValue);
     }
     else if (dependencyValue is IEnumerable <String> )
     {
         ApplyReferenceList(model, dependencyKey, (IEnumerable <String>)dependencyValue, @override);
     }
     else if (dependencyValue is Type)
     {
         ApplySimpleReference(model, dependencyKey, ComponentName.DefaultNameFor((Type)dependencyValue));
     }
     else if (dependencyValue is IEnumerable <Type> )
     {
         ApplyReferenceList(model, dependencyKey, ((IEnumerable <Type>)dependencyValue).Select(ComponentName.DefaultNameFor), @override);
     }
 }
Exemple #10
0
        public void AddComponent <T>(Type serviceType)
        {
            var classType = typeof(T);

            AddComponent(ComponentName.DefaultNameFor(classType), serviceType, classType);
        }
Exemple #11
0
        public void AddComponent <T>()
        {
            var classType = typeof(T);

            AddComponent(ComponentName.DefaultNameFor(classType), classType);
        }
Exemple #12
0
        public void AddComponent <T>(LifestyleType lifestyle)
        {
            var classType = typeof(T);

            AddComponent(ComponentName.DefaultNameFor(classType), classType, lifestyle);
        }
Exemple #13
0
 public EventSubscribers To <TSubscriber>()
 {
     return(To(ComponentName.DefaultNameFor(typeof(TSubscriber))));
 }
 /// <summary>
 ///   Creates a new instance of <see cref = "ComponentReference{T}" /> referencing default component implemented by <paramref
 ///    name = "componentType" />
 /// </summary>
 /// <param name = "componentType"></param>
 public ComponentReference(Type componentType)
 {
     referencedComponentName = ComponentName.DefaultNameFor(componentType);
     referencedComponentType = componentType;
 }
 private string GetServiceName(Type serviceType, string serviceName)
 {
     return(ComponentName.DefaultNameFor(serviceType) + (string.IsNullOrEmpty(serviceName) ? null : '.' + serviceName));
 }
Exemple #16
0
        public void AddComponent <T>(Type serviceType, LifestyleType lifestyle, bool overwriteLifestyle)
        {
            var classType = typeof(T);

            AddComponent(ComponentName.DefaultNameFor(classType), serviceType, classType, lifestyle, overwriteLifestyle);
        }
Exemple #17
0
 public EventSubscribers To <TSubscriber>(string methodHandler)
 {
     return(To(ComponentName.DefaultNameFor(typeof(TSubscriber)), methodHandler));
 }
Exemple #18
0
        public void AddComponentInstance <T>(Type serviceType, object instance)
        {
            var classType = typeof(T);

            AddComponentInstance(ComponentName.DefaultNameFor(classType), serviceType, classType, instance);
        }
Exemple #19
0
 public EventSubscribers To <TSubscriber>(Expression <Action <TSubscriber> > methodHandler)
 {
     return(To(ComponentName.DefaultNameFor(typeof(TSubscriber)), methodHandler));
 }