本文整理汇总了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];
}
示例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();
}
示例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];
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例11: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
return interceptors.Where(i => i.GetType() == interceptorType).ToArray();
}
示例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();
}