当前位置: 首页>>代码示例>>C#>>正文


C# IKernel.HasComponent方法代码示例

本文整理汇总了C#中IKernel.HasComponent方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.HasComponent方法的具体用法?C# IKernel.HasComponent怎么用?C# IKernel.HasComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IKernel的用法示例。


在下文中一共展示了IKernel.HasComponent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public void Init(IKernel kernel, Castle.Core.Configuration.IConfiguration facilityConfig)
        {
            Kernel = kernel;

            if (Kernel.HasComponent(typeof(ViewAccessor<>)) == false)
                Kernel.Register(Component.For(typeof(ViewAccessor<>)).LifeStyle.Singleton);

            if (Kernel.HasComponent(typeof(ControllerAccessor<,>)) == false)
                Kernel.Register(Component.For(typeof(ControllerAccessor<,>)).LifeStyle.Singleton);

            if (Kernel.HasComponent<IActionInvoker>() == false)
                Kernel.Register(Component.For<IActionInvoker>().ImplementedBy<DefaultActionInvoker>().LifeStyle.Singleton);

            if (Kernel.HasComponent<ICommandProvider>() == false)
                Kernel.Register(Component.For<ICommandProvider>().ImplementedBy<DefaultCommandProvider>().LifeStyle.Singleton);

            if (Kernel.HasComponent<IControllerAdapter>() == false)
                Kernel.Register(Component.For<IControllerAdapter>().ImplementedBy<DefaultControllerAdapter>().LifeStyle.Singleton);

            if (Kernel.HasComponent<IControllerLifecycleManager>() == false)
                Kernel.Register(Component.For<IControllerLifecycleManager>().ImplementedBy<MicroKernelControllerLifecycleManager>().LifeStyle.Singleton);

            if (Kernel.HasComponent<IAutoRegistration>() == false)
                Kernel.Register(Component.For<IAutoRegistration>().ImplementedBy<MicroKernelAutoRegistration>().LifeStyle.Singleton);

            Kernel.ComponentModelCreated += new ComponentModelDelegate(Kernel_ComponentModelCreated);
            Kernel.ComponentRegistered += new ComponentDataDelegate(Kernel_ComponentRegistered);
            Kernel.ComponentCreated += new ComponentInstanceDelegate(Kernel_ComponentCreated);
        }
开发者ID:mmorton,项目名称:Flux,代码行数:29,代码来源:FluxFacility.cs

示例2: Resolve

		/// <summary>
		///   Resolves the component(s) from given kernel.
		/// </summary>
		/// <param name = "kernel"></param>
		/// <returns>Resolved component(s).</returns>
		public virtual object Resolve(IKernel kernel)
		{
			if (string.IsNullOrEmpty(ComponentName) == false && kernel.HasComponent(ComponentName))
			{
				if (ComponentType == null)
				{
					return kernel.Resolve(ComponentName, AdditionalArguments);
				}

				return kernel.Resolve(ComponentName, ComponentType, AdditionalArguments);
			}

			return kernel.Resolve(ComponentType, AdditionalArguments);
		}
开发者ID:7digital,项目名称:Castle.Windsor,代码行数:19,代码来源:TypedFactoryComponent.cs

示例3: Init

		public override void Init(IComponentActivator componentActivator, IKernel kernel, ComponentModel model)
		{
			base.Init(componentActivator, kernel, model);

			// check ILoggerFactory is registered (logging is enabled)
			if (kernel.HasComponent(typeof(ILoggerFactory))) 
			{
				// get logger factory instance
				ILoggerFactory loggerFactory = kernel.Resolve<ILoggerFactory>();
				// create logger
				_Logger = loggerFactory.Create(GetType());
			}
			else
				_Logger = NullLogger.Instance;
		}
开发者ID:hammett,项目名称:Castle.Transactions,代码行数:15,代码来源:PerTransactionLifestyleManagerBase.cs

示例4: ProcessModel

		public override void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (model.Service is IBehaviorStore)
			{
				foreach (var node in kernel.GraphNodes.OfType<ComponentModel>())
				{
					SetProxyInformation(node, kernel.Resolve<IBehaviorConfigurator>());
				}
				return;
			}

			if (!kernel.HasComponent(typeof (IBehaviorStore))) return;
			var behaviorToProxyResolver = kernel.Resolve<IBehaviorConfigurator>();

			//Get the proxy info
			SetProxyInformation(model, behaviorToProxyResolver);
		}
开发者ID:Mrding,项目名称:Ribbon,代码行数:17,代码来源:BehaviorInspector.cs

示例5: InjectProperties

        public static void InjectProperties(IKernel kernel, object target)
        {
            var type = target.GetType();

            foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (property.CanWrite && kernel.HasComponent(property.PropertyType))
                {
                    var value = kernel.Resolve(property.PropertyType);
                    try
                    {
                        property.SetValue(target, value, null);
                    }
                    catch (Exception ex)
                    {
                        var message = string.Format("Error setting property {0} on type {1}, See inner exception for more information.", property.Name, type.FullName);
                        throw new ComponentActivatorException(message, ex, null);
                    }
                }
            }
        }
开发者ID:dlidstrom,项目名称:Snittlistan,代码行数:21,代码来源:InjectingActionInvoker.cs

示例6: foreach

		void IRegistration.Register(IKernel kernel)
		{
			foreach (IWcfClientModel channel in channels)
			{
				var registration = Component.For(channel.Contract);
				registration.DependsOn(Property.ForKey("channel").Eq(channel));

				if (configurer != null)
				{
					configurer(registration);
				}

				if (String.IsNullOrEmpty(registration.Name))
				{
					registration.Named(Guid.NewGuid().ToString());
				}

				if (!kernel.HasComponent(registration.Name))
				{
					kernel.Register(registration);
				}
			}
		}
开发者ID:ralescano,项目名称:castle,代码行数:23,代码来源:WcfClientDescriptor.cs

示例7: Resolve

 public override object Resolve(IKernel kernel)
 {
     return kernel.HasComponent(ComponentName) ? base.Resolve(kernel) : new DefaultModelBinder();
 }
开发者ID:antgerasim,项目名称:RealWorldMvc,代码行数:4,代码来源:ModelBinderFactoryComponent.cs


注:本文中的IKernel.HasComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。