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


C# IInterceptor.OfType方法代码示例

本文整理汇总了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();
        }
开发者ID:pacificIT,项目名称:WampSharp,代码行数:9,代码来源:WampRpcClientInterceptorSelector.cs

示例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;
            }
开发者ID:RoymanJing,项目名称:Autofac,代码行数:11,代码来源:ClassInterceptorsWithOptionsFixture.cs

示例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();
        }
开发者ID:bling,项目名称:AspectCastle,代码行数:28,代码来源:InterceptorSelector.cs

示例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;
 }
开发者ID:macpak,项目名称:OakenShield,代码行数:9,代码来源:FilteringInterceptorSelector.cs

示例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


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