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


C# ComponentModel.ObtainProxyOptions方法代码示例

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


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

示例1: 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 = model.ObtainProxyOptions();
			mixinReferences.ForEach(options.AddMixinReference);
		}
开发者ID:prasadpp,项目名称:Castle.Windsor,代码行数:34,代码来源:MixinInspector.cs

示例2: Create

		public override object Create(IKernel kernel, object instance, ComponentModel model, 
									  CreationContext context, params object[] constructorArguments)
		{
			var channelHolder = instance as IWcfChannelHolder;

			if (channelHolder == null)
			{
				throw new ArgumentException(string.Format("Given instance is not an {0}", typeof(IWcfChannelHolder)), "instance");
			}

			if (channelHolder.RealProxy == null)
			{
				return channelHolder.Channel;
			}

			if (model.Services.Count() > 1)
			{
				throw new ArgumentException(string.Format(
					"Component {0}, which was designated as a WCF proxy exposes {1} services. The facility currently only supports single-service components.",
					model.Name, model.Services.Count()));
			}

			var isDuplex = IsDuplex(channelHolder.RealProxy);
			var proxyOptions = model.ObtainProxyOptions();
			var serviceContract = model.GetServiceContract();
			var generationOptions = CreateProxyGenerationOptions(serviceContract, proxyOptions, kernel, context);
			var additionalInterfaces = GetInterfaces(model.Services, proxyOptions, isDuplex);
			var interceptors = GetInterceptors(kernel, model, serviceContract, channelHolder, context);

			return generator.CreateInterfaceProxyWithTarget(typeof(IWcfChannelHolder),
				additionalInterfaces, channelHolder, generationOptions, interceptors);
		}
开发者ID:AdamChang,项目名称:Castle.Facilities.Wcf-READONLY,代码行数:32,代码来源:WcfProxyFactory.cs

示例3: BuildComponentModel

		public void BuildComponentModel(IKernel kernel, ComponentModel model)
		{
			if (!mixIns.Any())
			{
				return;
			}
			var options = model.ObtainProxyOptions();
			foreach (var mixIn in mixIns)
			{
				options.AddMixinReference(mixIn);
			}
		}
开发者ID:dohansen,项目名称:Windsor,代码行数:12,代码来源:ProxyMixInsDescriptor.cs

示例4: AddTypedFactoryEntry

		public void AddTypedFactoryEntry(FactoryEntry entry)
		{
			var model = new ComponentModel(new ComponentName(entry.Id, true), new[] { entry.FactoryInterface }, typeof(Empty),
			                               new Arguments().Insert("typed.fac.entry", entry))
			{ LifestyleType = LifestyleType.Singleton };

			model.Interceptors.Add(new InterceptorReference(typeof(FactoryInterceptor)));

			var proxyOptions = model.ObtainProxyOptions();
			proxyOptions.OmitTarget = true;

			((IKernelInternal)Kernel).AddCustomComponent(model);
		}
开发者ID:prasadpp,项目名称:Castle.Windsor,代码行数:13,代码来源:TypedFactoryFacility.cs

示例5: Create

		public override object Create(IProxyFactoryExtension customFactory, IKernel kernel, ComponentModel model, CreationContext context,
		                              params object[] constructorArguments)
		{
			var interceptors = ObtainInterceptors(kernel, model, context);
			var proxyOptions = model.ObtainProxyOptions();
			var proxyGenOptions = CreateProxyGenerationOptionsFrom(proxyOptions, kernel, context, model);

			CustomizeOptions(proxyGenOptions, kernel, model, constructorArguments);
			var builder = generator.ProxyBuilder;
			var proxy = customFactory.Generate(builder, proxyGenOptions, interceptors, model, context);

			CustomizeProxy(proxy, proxyGenOptions, kernel, model);
			ReleaseHook(proxyGenOptions, kernel);
			return proxy;
		}
开发者ID:janv8000,项目名称:Windsor,代码行数:15,代码来源:DefaultProxyFactory.cs

示例6: CollectFromConfiguration

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

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

			CollectInterceptors(model, interceptors);
			var options = model.ObtainProxyOptions();
			CollectSelector(interceptors, options);
			CollectHook(interceptors, options);
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:18,代码来源:InterceptorInspector.cs

示例7: ShouldCreateProxy

        public bool ShouldCreateProxy(ComponentModel model)
        {
            if (model.HasInterceptors)
            {
                return true;
            }

            var options = model.ObtainProxyOptions(false);
            if (options != null && options.RequiresProxy)
            {
                return true;
            }
            if (selectors != null && selectors.Any(s => s.HasInterceptors(model)))
            {
                return true;
            }

            return false;
        }
开发者ID:janv8000,项目名称:Windsor,代码行数:19,代码来源:AbstractProxyFactory.cs

示例8: Create

		public override object Create(IKernel kernel, object instance, ComponentModel model, 
									  CreationContext context, params object[] constructorArguments)
		{
			var channelHolder = instance as IWcfChannelHolder;

			if (channelHolder == null)
			{
				throw new ArgumentException(string.Format("Given instance is not an {0}", typeof(IWcfChannelHolder)), "instance");
			}

			var isDuplex = IsDuplex(channelHolder.RealProxy);
			var proxyOptions = model.ObtainProxyOptions();
			var serviceContract = model.GetServiceContract();
			var remainingServices = model.Services.Except(new[] { serviceContract });
			var generationOptions = CreateProxyGenerationOptions(serviceContract, proxyOptions, kernel, context);
			generationOptions.AddMixinInstance(channelHolder);
			var additionalInterfaces = GetInterfaces(remainingServices, proxyOptions, isDuplex);
			var interceptors = GetInterceptors(kernel, model, serviceContract, channelHolder, context);

			return generator.CreateInterfaceProxyWithTargetInterface(serviceContract,
				additionalInterfaces, channelHolder.Channel, generationOptions, interceptors);
		}
开发者ID:rtr0mdrn,项目名称:Windsor,代码行数:22,代码来源:WcfProxyFactory.cs

示例9: ApplySynchronization

		/// <summary>
		///   Applies the synchronization support to the model.
		/// </summary>
		/// <param name = "model">The model.</param>
		/// <param name = "kernel">The kernel.</param>
		private void ApplySynchronization(ComponentModel model, IKernel kernel)
		{
			var options = model.ObtainProxyOptions();

			model.Interceptors.Add(new InterceptorReference(typeof(SynchronizeInterceptor)));

			var metaInfo = metaStore.GetMetaFor(model.Implementation);

			if (metaInfo != null)
			{
				IInterceptorSelector userSelector = null;
				if (options.Selector != null)
				{
					userSelector = options.Selector.Resolve(kernel, CreationContext.CreateEmpty());
				}

				options.Selector = new InstanceReference<IInterceptorSelector>(new SynchronizeInterceptorSelector(metaInfo, userSelector));

				foreach (var reference in metaInfo.GetUniqueSynchContextReferences())
				{
					model.Dependencies.Add(new DependencyModel(reference.ComponentKey, reference.ServiceType, false));
				}
			}
		}
开发者ID:prasadpp,项目名称:Castle.Windsor,代码行数:29,代码来源:SynchronizeComponentInspector.cs

示例10: BuildComponentModel

		public void BuildComponentModel(IKernel kernel, ComponentModel model)
		{
			var options = model.ObtainProxyOptions();
			options.Selector = selector;
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:5,代码来源:InterceptorSelectorDescriptor.cs

示例11: BuildComponentModel

		public void BuildComponentModel(IKernel kernel, ComponentModel model)
		{
			var options = model.ObtainProxyOptions();
			options.AddAdditionalInterfaces(interfaces);
		}
开发者ID:RookieX,项目名称:Windsor,代码行数:5,代码来源:ProxyInterfacesDescriptor.cs

示例12: ConfigureProxyOptions

		private void ConfigureProxyOptions(ComponentModel model)
		{
			if (controlProxyHook == null)
			{
				return;
			}
			var proxyOptions = model.ObtainProxyOptions();
			proxyOptions.Hook = controlProxyHook;
		}
开发者ID:castleproject,项目名称:Windsor,代码行数:9,代码来源:CreateOnUIThreadInspector.cs

示例13: RequiresTargetInstance

		/// <summary>
		///   Determines if the component requires a target instance for proxying.
		/// </summary>
		/// <param name="kernel"> The kernel. </param>
		/// <param name="model"> The model. </param>
		/// <returns> true if an instance is required. </returns>
		public override bool RequiresTargetInstance(IKernel kernel, ComponentModel model)
		{
			var proxyOptions = model.ObtainProxyOptions();

			return model.HasClassServices == false &&
			       proxyOptions.OmitTarget == false;
		}
开发者ID:janv8000,项目名称:Windsor,代码行数:13,代码来源:DefaultProxyFactory.cs

示例14: ApplyProxyBehavior

		private static void ApplyProxyBehavior(ComponentProxyBehaviorAttribute behavior, ComponentModel model)
		{
			var options = model.ObtainProxyOptions();
#if !SILVERLIGHT
			if (behavior.UseMarshalByRefProxy)
			{
				EnsureComponentRegisteredWithInterface(model);
			}
			options.UseMarshalByRefAsBaseClass = behavior.UseMarshalByRefProxy;
#endif
			options.AddAdditionalInterfaces(behavior.AdditionalInterfaces);
			if(model.Implementation.IsInterface)
			{
				options.OmitTarget = true;
			}
		}
开发者ID:dohansen,项目名称:Windsor,代码行数:16,代码来源:ComponentProxyInspector.cs

示例15: BuildComponentModel

		public void BuildComponentModel(IKernel kernel, ComponentModel model)
		{
			var options = model.ObtainProxyOptions();
			options.Hook = hook;
		}
开发者ID:RookieX,项目名称:Windsor,代码行数:5,代码来源:ProxyHookDescriptor.cs


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