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


C# IInterceptor.Where方法代码示例

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


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

示例1: SelectInterceptors

 public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
 {
     if (method.IsAddMethod()) return interceptors.Where(x => x is ListAddInterceptor).ToArray();
     if (method.IsSetMethod()) return interceptors.Where(x => x is ListSetInterceptor).ToArray();
     if (method.IsRemoveMethod()) return interceptors.Where(x => x is ListRemoveInterceptor).ToArray();
     return new IInterceptor[0];
 }
开发者ID:DemgelOpenSource,项目名称:DemgelRedis,代码行数:7,代码来源:ListSelector.cs

示例2: SelectInterceptors

        /// <summary>Select interceptors which must be applied to the method.</summary>
        /// <param name="type">The type.</param>
        /// <param name="method">The method.</param>
        /// <param name="interceptors">The interceptors.</param>
        /// <returns>The interceptors after filtering.</returns>
        public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
        {
            if (method.IsGetter())
            {
                var propertyInfo = type.GetProperty(method);
                if (propertyInfo.IsPropertyWithSelectorAttribute())
                {
                    return typeof(BaseHtmlElement).IsAssignableFrom(method.ReturnType) 
                        ? interceptors.Where(x => x is PropertyInterceptor).ToArray() 
                        : interceptors.Where(x => x is CollectionPropertyInterceptor).ToArray();
                }
            }

            if (method.IsSetter())
            {
                var propertyInfo = type.GetProperty(method);
                if (propertyInfo.IsPropertyWithSelectorAttribute())
                {
                    return interceptors.Where(x => x is InvalidWriteOperationInterceptor).ToArray();
                }
            }

            return interceptors.Where(x => !(x is PropertyInterceptor) 
                && !(x is CollectionPropertyInterceptor)
                && !(x is InvalidWriteOperationInterceptor)).ToArray();
        }
开发者ID:pbakshy,项目名称:Selenol,代码行数:31,代码来源:InterceptorSelector.cs

示例3: SelectInterceptors

 public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
 {
     if (method.IsAddMethod()) return interceptors.Where(x => x is DictionaryAddInterceptor).ToArray();
     if (method.IsSetMethod()) return interceptors.Where(x => x is DictionarySetInterceptor).ToArray();
     if (method.IsRemoveMethod()) return interceptors.Where(x => x is DictionaryRemoveInterceptor).ToArray();
     if (method.IsGetMethod() && !method.Name.StartsWith("get_Count", StringComparison.Ordinal)) return interceptors.Where(x => x is DictionaryGetInterceptor).ToArray();
     if (method.IsTryGetValueMethod()) return interceptors.Where(x => x is DictionaryGetInterceptor).ToArray();
     return new IInterceptor[0];
 }
开发者ID:DemgelOpenSource,项目名称:DemgelRedis,代码行数:9,代码来源:DictionarySelector.cs

示例4: SelectInterceptors

        public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
        {
            var methodName = method.Name;

            if (methodName.Equals("GetFilters")) return interceptors.Where(i => i is GetFiltersInterceptor).ToArray();
            if (methodName.Equals("InvokeActionMethod")) return interceptors.Where(i => i is InvokeActionMethodInterceptor).ToArray();
            if (methodName.Equals("InvokeActionResult")) return interceptors.Where(i => i is InvokeActionResultInterceptor).ToArray();

            return null;
        }
开发者ID:jeffsheldon,项目名称:Glimpse,代码行数:10,代码来源:ActionInvokerInterceptorSelector.cs

示例5: SelectInterceptors

        /// <summary>
        ///     The select interceptors.
        /// </summary>
        /// <param name="type">
        ///     The type.
        /// </param>
        /// <param name="method">
        ///     The method.
        /// </param>
        /// <param name="interceptors">
        ///     The interceptors.
        /// </param>
        /// <returns>
        ///     The <see cref="IInterceptor[]" />.
        /// </returns>
        public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
        {
            string name = method.Name;
            if (method.IsSpecialName)
            {
                if (name.StartsWith(AopConstants.PropertyGetter, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.PropertyGetter.Length);

                if (name.StartsWith(AopConstants.PropertySetter, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.PropertySetter.Length);

                if (name.StartsWith(AopConstants.EventAdder, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.EventAdder.Length);

                if (name.StartsWith(AopConstants.EventRemover, StringComparison.Ordinal)) name = name.Remove(0, AopConstants.EventRemover.Length);
            }

            return interceptors.Where(
                inter =>
                {
                    var sinter = inter as ISpecificInterceptor;
                    if (sinter != null)
                    {
                        return sinter.Name == name ||
                               sinter.Name == AopConstants.InternalUniversalInterceptorName;
                    }

                    return true;
                }).OrderBy(
                    inter =>
                    {
                        var sinter = inter as ISpecificInterceptor;
                        return sinter == null ? 0 : sinter.Order;
                    }).ToArray();
        }
开发者ID:Tauron1990,项目名称:Tauron-Application-Common,代码行数:47,代码来源:InternalInterceptorSelector.cs

示例6: SelectInterceptors

 /// <summary>
 /// Selects the interceptors that should intercept calls to the given <paramref name="method" />.
 /// </summary>
 /// <param name="type">The type declaring the method to intercept.</param>
 /// <param name="method">The method that will be intercepted.</param>
 /// <param name="interceptors">All interceptors registered with the proxy.</param>
 /// <returns>
 /// An array of interceptors to invoke upon calling the <paramref name="method" />.
 /// </returns>
 /// <remarks>
 /// This method is called only once per proxy instance, upon the first call to the
 /// <paramref name="method" />. Either an empty array or null are valid return values to indicate
 /// that no interceptor should intercept calls to the method. Although it is not advised, it is
 /// legal to return other <see cref="T:Castle.DynamicProxy.IInterceptor" /> implementations than these provided in
 /// <paramref name="interceptors" />.
 /// </remarks>
 public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
 {
     return interceptors.Where(i =>
                                   {
                                       var ai = i as AlternateTypeToCastleInterceptorAdapter;
                                       return ai != null && ai.MethodToImplement == method;
                                   }).ToArray();
 }
开发者ID:GitObjects,项目名称:Glimpse,代码行数:24,代码来源:AlternateTypeSelector.cs

示例7: SelectInterceptors

        public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
        {
            var allowNullActuals = method.GetCustomAttributes(typeof (AllowNullActualAttribute), true).Length > 0;

            if (!allowNullActuals)
            {
                return interceptors;
            }

            return interceptors.Where(i => !(i is NullActualInterceptorBase)).ToArray();
        }
开发者ID:benjamin-bader,项目名称:ExpectBetter,代码行数:11,代码来源:MatcherInterceptorSelector.cs

示例8: SelectInterceptors

        public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
        {
            if (method.DeclaringType == typeof(IMockInstance))
                return interceptors
                    .Where(x => (x is MockInterceptor))
                    .ToArray();

            if (method.DeclaringType == typeof(IMockExpectationContainer))
                return interceptors
                    .Where(x => (x is MockInterceptor))
                    .ToArray();

            if (method.DeclaringType == typeof(object))
                return interceptors
                    .Where(x => (x is ObjectInterceptor))
                    .ToArray();

            return interceptors
                .Where(x => (x is ProxyInterceptor))
                .ToArray();
        }
开发者ID:bytedreamer,项目名称:rhino-mocks,代码行数:21,代码来源:RhinoSelector.cs

示例9: SelectInterceptors

        public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
        {
            Logger.Trace(m => m("Called interceptor selector for method {0}.{1} and interceptors {2}",
                                type.FullName,
                                method.Name,
                                interceptors
                                    .Select(i => i.GetType().Name)
                                    .Aggregate((s1, s2) => s1 + " " + s2)));

            var applicableMappings = GetInterceptorsApplicableTo(type, method);
            var applicableInterceptors = interceptors.Where(x => applicableMappings.Any(m => m.InterceptorType == x.GetType())).ToArray();

            Logger.TraceFormat("Applying {0} interceptors[{1}] to method {2}.{3}...",
                               applicableInterceptors.Length,
                               string.Join(", ", applicableInterceptors.Select(x => x.GetType().Name).ToArray()),
                               type.FullName, method.Name);

            return applicableInterceptors;
        }
开发者ID:bdevic,项目名称:castle-windsor-interceptors,代码行数:19,代码来源:InterceptorSelector.cs

示例10: SelectInterceptors

		/// <summary>
		/// 
		/// </summary>
		/// <param name="type"></param>
		/// <param name="method"></param>
		/// <param name="interceptors"></param>W
		/// <returns></returns>
		public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
		{
			if (!metaInfo.Contains(method))
			{
				if (IsInterfaceMappingCandidate(type, method))
				{
					var map = type.GetInterfaceMap(method.DeclaringType);
					var index = Array.IndexOf(map.InterfaceMethods, method);
					if (index >= 0 && metaInfo.Contains(map.TargetMethods[index]))
						return interceptors;
				}

				interceptors = interceptors.Where(i => i is SynchronizeInterceptor == false).ToArray();
			}

			if (existingSelector != null)
			{
				interceptors = existingSelector.SelectInterceptors(type, method, interceptors);
			}

			return interceptors;
		}
开发者ID:vbedegi,项目名称:Castle.InversionOfControl,代码行数:29,代码来源:SynchronizeInterceptorSelector.cs

示例11: SelectInterceptors

		public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
		{
			return interceptors.Where(i => i.GetType() == interceptorType).ToArray();
		}
开发者ID:AGiorgetti,项目名称:Castle.InversionOfControl,代码行数:4,代码来源:ComponentRegistrationTestCase.cs

示例12: SelectInterceptors

 public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
 {
     return method.IsSetMethod() ? interceptors.Where(i => i is RedisObjectSetInterceptor).ToArray()
         : interceptors.Where(i => i is GeneralGetInterceptor).ToArray();
 }
开发者ID:DemgelOpenSource,项目名称:DemgelRedis,代码行数:5,代码来源:RedisObjectSelector.cs


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