• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Core.ComponentModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Castle.Core.ComponentModel的典型用法代码示例。如果您正苦于以下问题:C# ComponentModel类的具体用法?C# ComponentModel怎么用?C# ComponentModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ComponentModel类属于Castle.Core命名空间,在下文中一共展示了ComponentModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetMismatch

		private IEnumerable<LifestyleDependency> GetMismatch(LifestyleDependency parent, ComponentModel component,
		                                                     Dictionary<ComponentModel, IHandler> model2Handler)
		{
			if (parent.Handler.ComponentModel == component)
			{
				yield break;
			}

			var handler = model2Handler[component];
			var item = new LifestyleDependency(handler, parent);
			if (item.Mismatched())
			{
				yield return item;
			}
			else
			{
				foreach (ComponentModel dependent in handler.ComponentModel.Dependents)
				{
					foreach (var mismatch in GetMismatch(item, dependent, model2Handler))
					{
						yield return mismatch;
					}
				}
			}
		}
开发者ID:oleksii-mdr,项目名称:Castle.Windsor,代码行数:25,代码来源:PotentialLifestyleMismatches.cs


示例2: SetOnBehalfAware

 protected static void SetOnBehalfAware(IOnBehalfAware onBehalfAware, ComponentModel target)
 {
     if (onBehalfAware != null)
     {
         onBehalfAware.SetInterceptedComponentModel(target);
     }
 }
开发者ID:janv8000,项目名称:Windsor,代码行数:7,代码来源:AbstractProxyFactory.cs


示例3: Resolve

 public object Resolve(CreationContext context,
     ISubDependencyResolver parentResolver,
     ComponentModel model,
     DependencyModel dependency)
 {
     return _kernel.ResolveAll(dependency.TargetType.GetElementType(), null);
 }
开发者ID:agross,项目名称:fizzbuzz,代码行数:7,代码来源:ArraySubDependencyResolver.cs


示例4: ProcessModel

		public void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (model.Configuration == null)
			{
				return;
			}

			var remoteserverAttValue = model.Configuration.Attributes["remoteserver"];
			var remoteclientAttValue = model.Configuration.Attributes["remoteclient"];

			var server = RemotingStrategy.None;
			var client = RemotingStrategy.None;

			if (remoteserverAttValue == null && remoteclientAttValue == null)
			{
				return;
			}

			if (remoteserverAttValue != null)
			{
				server = converter.PerformConversion<RemotingStrategy>(remoteserverAttValue);
			}

			if (remoteclientAttValue != null)
			{
				client = converter.PerformConversion<RemotingStrategy>(remoteclientAttValue);
			}

			DoSemanticCheck(server, model, client);

			ConfigureServerComponent(server, model.Implementation, model);

			ConfigureClientComponent(client, model.Services.Single(), model);
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:34,代码来源:RemotingInspector.cs


示例5: UpdateActivator

		private void UpdateActivator(ComponentModel model)
		{
			if (model.CustomComponentActivator == null)
			{
				model.CustomComponentActivator = typeof(WcfBehaviorActivator);
			}
		}
开发者ID:AdamChang,项目名称:Castle.Facilities.Wcf-READONLY,代码行数:7,代码来源:WcfBehaviorInspector.cs


示例6: ProcessModel

		public void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (model.Configuration == null)
			{
				return;
			}

			var mixins = model.Configuration.Children["mixins"];
			if (mixins == null)
			{
				return;
			}

			var mixinReferences = new List<ComponentReference<object>>();
			foreach (var mixin in mixins.Children)
			{
				var value = mixin.Value;

				var mixinComponent = ReferenceExpressionUtil.ExtractComponentKey(value);
				if (mixinComponent == null)
				{
					throw new Exception(
						String.Format("The value for the mixin must be a reference to a component (Currently {0})", value));
				}

				mixinReferences.Add(new ComponentReference<object>("mixin-" + mixinComponent, mixinComponent));
			}
			if (mixinReferences.Count == 0)
			{
				return;
			}
			var options = ProxyUtil.ObtainProxyOptions(model, true);
			mixinReferences.ForEach(options.AddMixinReference);
		}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:34,代码来源:MixinInspector.cs


示例7: AbstractComponentActivator

		/// <summary>
		///   Constructs an AbstractComponentActivator
		/// </summary>
		protected AbstractComponentActivator(ComponentModel model, IKernel kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction)
		{
			this.model = model;
			this.kernel = kernel;
			this.onCreation = onCreation;
			this.onDestruction = onDestruction;
		}
开发者ID:martinernst,项目名称:Castle.Windsor,代码行数:10,代码来源:AbstractComponentActivator.cs


示例8: CanResolve

		/// <summary>
		///   Returns true if the resolver is able to satisfy the specified dependency.
		/// </summary>
		/// <param name = "context">Creation context, which is a resolver itself</param>
		/// <param name = "contextHandlerResolver">Parent resolver</param>
		/// <param name = "model">Model of the component that is requesting the dependency</param>
		/// <param name = "dependency">The dependency model</param>
		/// <returns>
		///   <c>true</c>
		///   if the dependency can be satisfied</returns>
		public bool CanResolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency)
		{
			// 1 - check for the dependency on CreationContext, if present
			if (CanResolveFromContext(context, contextHandlerResolver, model, dependency))
			{
				return true;
			}

			// 2 - check with the model's handler, if not the same as the parent resolver
			if (CanResolveFromHandler(context, contextHandlerResolver, model, dependency))
			{
				return true;
			}

			// 3 - check within parent resolver, if present
			if (CanResolveFromContextHandlerResolver(context, contextHandlerResolver, model, dependency))
			{
				return true;
			}

			// 4 - check within subresolvers
			if (CanResolveFromSubResolvers(context, contextHandlerResolver, model, dependency))
			{
				return true;
			}

			// 5 - normal flow, checking against the kernel
			return CanResolveFromKernel(context, model, dependency);
		}
开发者ID:jmuralimohanbabu,项目名称:Castle.Windsor,代码行数:39,代码来源:DefaultDependencyResolver.cs


示例9: Kernel_ComponentCreated

 private void Kernel_ComponentCreated(ComponentModel model, object instance)
 {
     if (instance is IListener)
     {
         _eventPublisher.AddListener((IListener) instance);
     }
 }
开发者ID:henryjwr,项目名称:Windows-Forms-MVP,代码行数:7,代码来源:EventPublisherFacility.cs


示例10: CreateTransactionConfig

		private TransactionConfig CreateTransactionConfig(ComponentModel model)
		{
			TransactionConfig config = new TransactionConfig();
			GatherTransactionAttributes(config, model.Implementation);
			GatherTransactionConfiguration(config, model);
			return config;
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:TransactionFacility.cs


示例11: SelectInterceptors

		public InterceptorReference[] SelectInterceptors(ComponentModel model, InterceptorReference[] interceptors)
		{
			return new[]
			{
				new InterceptorReference(interceptorType),
			};
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:7,代码来源:ByTypeInterceptorSelector.cs


示例12: Kernel_ComponentModelCreated

        private void Kernel_ComponentModelCreated(ComponentModel model)
        {
            IEnumerable <Type> services = model.Services;
            bool isView = services.Any(x => x.GetInterface("IView") != null);

            //		   if (!services.Select(service => typeof (IView).IsAssignableFrom(service)).Any(isView => isView))
            //		   {
            //		      return;
            //		   }
            //
            //		   if (model.CustomComponentActivator == null)
            //		   {
            //		      model.CustomComponentActivator = typeof (WpfWindowActivator);
            //		   }

            //         bool isView = model
            //
            if ( !isView )
            {
                return;
            }

            if ( model.CustomComponentActivator == null )
            {
                model.CustomComponentActivator = typeof( WpfWindowActivator );
            }
        }
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:27,代码来源:ViewActivatorFacility.cs


示例13: Resolve

			public object Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model,
			                      DependencyModel dependency)
			{
				return contextHandlerResolver.Resolve(context, contextHandlerResolver, model,
				                                      new DependencyModel(DependencyType.Service, typeof(IBookStore).FullName,
				                                                          typeof(IBookStore), false));
			}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:SubResolversShouldNotBeTrustedToBeCorrect.cs


示例14: NoResolvableConstructorFoundException

		public NoResolvableConstructorFoundException(Type type, ComponentModel componentModel)
			: base(
				string.Format("Could not find resolvable constructor for {0}. Make sure all required dependencies are provided.",
				              type.FullName), componentModel)
		{
			this.type = type;
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:7,代码来源:NoResolvableConstructorFoundException.cs


示例15: ProcessModel

		/// <summary>
		/// Queries the kernel's ConfigurationStore for a configuration
		/// associated with the component name.
		/// </summary>
		/// <param name="kernel"></param>
		/// <param name="model"></param>
		public virtual void ProcessModel(IKernel kernel, ComponentModel model)
		{
			IConfiguration config = kernel.ConfigurationStore.GetComponentConfiguration(model.Name) ??
									kernel.ConfigurationStore.GetBootstrapComponentConfiguration(model.Name);

			model.Configuration = config;
		}
开发者ID:ralescano,项目名称:castle,代码行数:13,代码来源:ConfigurationModelInspector.cs


示例16: Kernel_ComponentDestroyed

 private void Kernel_ComponentDestroyed(ComponentModel model, object instance)
 {
     if (instance is IListener)
     {
         _eventPublisher.RemoveListener((IListener) instance);
     }
 }
开发者ID:henryjwr,项目名称:Windows-Forms-MVP,代码行数:7,代码来源:EventPublisherFacility.cs


示例17: CollectFromConfiguration

		protected virtual void CollectFromConfiguration(ComponentModel model)
		{
			if (model.Configuration == null) return;

			IConfiguration interceptors = model.Configuration.Children["interceptors"];

			if (interceptors == null) return;

			foreach(IConfiguration interceptor in interceptors.Children)
			{
				String value = interceptor.Value;

				if (!ReferenceExpressionUtil.IsReference(value))
				{
					String message = String.Format(
						"The value for the interceptor must be a reference " + 
						"to a component (Currently {0})", 
						value);

					throw new ConfigurationErrorsException(message);
				}

				InterceptorReference interceptorRef = 
					new InterceptorReference( ReferenceExpressionUtil.ExtractComponentKey(value) );
				
				model.Interceptors.Add(interceptorRef);
				model.Dependencies.Add( CreateDependencyModel(interceptorRef) );
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:29,代码来源:InterceptorInspector.cs


示例18: OnComponentModelCreated

		private void OnComponentModelCreated(ComponentModel model)
		{
			var isController = typeof(IController).IsAssignableFrom(model.Implementation);
			var isViewComponent = typeof(ViewComponent).IsAssignableFrom(model.Implementation);

			if (!isController && !isViewComponent)
			{
				return;
			}

			// Ensure it's transient
			model.LifestyleType = LifestyleType.Transient;
			model.InspectionBehavior = PropertiesInspectionBehavior.DeclaredOnly;

			if (isController)
			{
				var descriptor = ControllerInspectionUtil.Inspect(model.Implementation);

				controllerTree.AddController(descriptor.Area, descriptor.Name, model.Implementation);
			}

			if (isViewComponent)
			{
				componentRegistry.AddViewComponent(model.Name, model.Implementation);
			}
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:26,代码来源:MonoRailFacility.cs


示例19: ConfigureServiceHost

		protected void ConfigureServiceHost(ServiceHost serviceHost, IWcfServiceModel serviceModel, ComponentModel model)
		{
			serviceHost.Description.Behaviors.Add(
				new WindsorDependencyInjectionServiceBehavior(kernel, model)
				);

			var burden = new WcfBurden(kernel);
			var contracts = new HashSet<ContractDescription>();
			Dictionary<IWcfEndpoint, ServiceEndpoint> endpoints = null;

			if (serviceModel != null && serviceModel.Endpoints.Count > 0)
			{
				endpoints = new Dictionary<IWcfEndpoint, ServiceEndpoint>();
				var builder = new ServiceEndpointBuilder(this, serviceHost);

				foreach (var endpoint in serviceModel.Endpoints)
				{
					endpoints.Add(endpoint, builder.AddServiceEndpoint(endpoint));
				}
			}

			var extensions = new ServiceHostExtensions(serviceHost, kernel)
				.Install(burden, new WcfServiceExtensions());

			if (serviceModel != null)
			{
				extensions.Install(serviceModel.Extensions, burden);
			}

			extensions.Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Services));

			if (endpoints != null)
			{
				foreach (var endpoint in endpoints)
				{
					var addContract = contracts.Add(endpoint.Value.Contract);
					new ServiceEndpointExtensions(endpoint.Value, addContract, kernel)
						.Install(endpoint.Key.Extensions, burden);
				}
			}

			if (serviceHost is IWcfServiceHost)
			{
				var wcfServiceHost = (IWcfServiceHost)serviceHost;

				wcfServiceHost.EndpointCreated += (_, e) =>
				{
					var addContract = contracts.Add(e.Endpoint.Contract);
					var endpointExtensions = new ServiceEndpointExtensions(e.Endpoint, addContract, kernel)
						.Install(burden, new WcfEndpointExtensions(WcfExtensionScope.Services));

					if (serviceModel != null)
					{
						endpointExtensions.Install(serviceModel.Extensions, burden);
					}
				};
			}

			serviceHost.Extensions.Add(new WcfBurdenExtension<ServiceHostBase>(burden));
		}
开发者ID:codereflection,项目名称:Castle.Facilities.Wcf,代码行数:60,代码来源:AbstractServiceHostBuilder.cs


示例20: ProcessModel

		public void ProcessModel(IKernel kernel, ComponentModel model)
		{
			if (model.Implementation.IsDefined(typeof (UsesAutomaticSessionCreationAttribute), true))
			{
				model.Interceptors.Add(new InterceptorReference(typeof (AutomaticSessionInterceptor)));
			}
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:7,代码来源:AutomaticSessionInspector.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Core.DependencyModel类代码示例发布时间:2022-05-24
下一篇:
C# DictionaryAdapter.PropertyDescriptor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap