コード例 #1
0
        public IWindsorContainer AddComponent <T>()
        {
            var t = typeof(T);

            AddComponent(ComponentName.DefaultNameFor(t), t);
            return(this);
        }
コード例 #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);
        }
コード例 #3
0
        public IWindsorContainer AddComponentWithProperties <T>(IDictionary extendedProperties)
        {
            var t = typeof(T);

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

            AddComponent(ComponentName.DefaultNameFor(t), typeof(I), t);
            return(this);
        }
コード例 #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)));
 }
コード例 #6
0
ファイル: DelegateFactory.cs プロジェクト: vtml/Windsor
        protected string GetName(Type service)
        {
            var defaultName = ComponentName.DefaultNameFor(service);

            if (string.IsNullOrEmpty(defaultName))
            {
                return("auto-factory: " + Guid.NewGuid());
            }
            return("auto-factory: " + defaultName);
        }
コード例 #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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
 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);
     }
 }
コード例 #10
0
        public void AddComponent <T>(Type serviceType)
        {
            var classType = typeof(T);

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

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

            AddComponent(ComponentName.DefaultNameFor(classType), classType, lifestyle);
        }
コード例 #13
0
 public EventSubscribers To <TSubscriber>()
 {
     return(To(ComponentName.DefaultNameFor(typeof(TSubscriber))));
 }
コード例 #14
0
 /// <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;
 }
コード例 #15
0
 private string GetServiceName(Type serviceType, string serviceName)
 {
     return(ComponentName.DefaultNameFor(serviceType) + (string.IsNullOrEmpty(serviceName) ? null : '.' + serviceName));
 }
コード例 #16
0
        public void AddComponent <T>(Type serviceType, LifestyleType lifestyle, bool overwriteLifestyle)
        {
            var classType = typeof(T);

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

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