本文整理汇总了C#中IInterceptor.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# IInterceptor.OfType方法的具体用法?C# IInterceptor.OfType怎么用?C# IInterceptor.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInterceptor
的用法示例。
在下文中一共展示了IInterceptor.OfType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
if (typeof (Task).IsAssignableFrom(method.ReturnType))
{
return interceptors.OfType<WampRpcClientAsyncInterceptor>().Cast<IInterceptor>().ToArray();
}
return interceptors.OfType<WampRpcClientSyncInterceptor>().Cast<IInterceptor>().ToArray();
}
示例2: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
var result = method.Name == "GetI"
? interceptors.OfType<AddOneInterceptor>().ToArray<IInterceptor>()
: interceptors.OfType<AddTenInterceptor>().ToArray<IInterceptor>();
if (result.Length == 0)
throw new InvalidOperationException("No interceptors for method " + method.Name);
return result;
}
示例3:
IInterceptor[] IInterceptorSelector.SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
if (interceptors.Length == 0)
return interceptors;
var markers = new List<MarkerBaseAttribute>();
if (type != null)
markers.AddRange(type.GetCustomAttributes(typeof(MarkerBaseAttribute), true).Cast<MarkerBaseAttribute>());
if (method != null)
markers.AddRange(method.GetCustomAttributes(typeof(MarkerBaseAttribute), true).Cast<MarkerBaseAttribute>());
if (markers.Count == 0) // no marker attributes found, no ordering required
return interceptors;
markers.Sort((a, b) => a.Order.CompareTo(b.Order));
var sorted = new List<IInterceptor>();
for (int i = 0; i < markers.Count; ++i)
{
var providers = interceptors.OfType<IInterceptorMarkerProvider>();
var markerType = markers[i].GetType();
var matchingInterceptor = providers.FirstOrDefault(x => x.MarkerType == markerType) as IInterceptor;
if (matchingInterceptor != null)
sorted.Add(matchingInterceptor);
}
return sorted.ToArray();
}
示例4: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
var filteringInterceptor = interceptors.OfType<FilteringInterceptor>().SingleOrDefault();
if(filteringInterceptor != null)
{
filteringInterceptor.PredicatesToSatisfy = _predicates;
}
return interceptors;
}
示例5: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
return method.Name == "GetVisitCount"
? interceptors.OfType<AddOneInterceptor>().ToArray<IInterceptor>()
: interceptors.OfType<AddTenInterceptor>().ToArray<IInterceptor>();
}
开发者ID:jango2015,项目名称:Autofac.Extras.DynamicProxy,代码行数:6,代码来源:InterceptorsChosenByMetadataWithOptionsFixture.cs
示例6: SelectInterceptors
public IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors)
{
return method.Name == "DoWork"
? interceptors.OfType<PrependInterceptor>().ToArray<IInterceptor>()
: interceptors.OfType<AppendInterceptor>().ToArray<IInterceptor>();
}
开发者ID:jango2015,项目名称:Autofac.Extras.DynamicProxy,代码行数:6,代码来源:InterceptTransparentProxyWithOptionsFixture.cs