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


C# IInterceptor类代码示例

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


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

示例1: SelectMethodInterceptors

		private IInterceptor[] SelectMethodInterceptors(IInterceptorSelector selector,
		                                                IInterceptor[] methodInterceptors,
		                                                Type targetType)
		{
			return methodInterceptors ??
			       selector.SelectInterceptors(targetType, Method, interceptors) ??
			       new IInterceptor[0];
		}
开发者ID:alexjamesbrown,项目名称:n2cms,代码行数:8,代码来源:AbstractInvocation.cs

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

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

示例4: Invocation

 protected Invocation(object proxy, MethodInfo proxiedMethod, object[] arguments, IInterceptor[] interceptors)
 {
     _proxy = proxy;
     _proxiedMethod = proxiedMethod;
     _arguments = arguments;
     _interceptors = interceptors ?? new IInterceptor[0];
 }
开发者ID:nikodemrafalski,项目名称:nr-cache,代码行数:7,代码来源:Invocation.cs

示例5: InterceptionContext

		public InterceptionContext(IInterceptor[] interceptors)
		{
            //if (interceptors != null)
            {
                _interceptors = new List<IInterceptor>(interceptors);
            }
		}
开发者ID:adwardliu,项目名称:vc-community,代码行数:7,代码来源:InterceptionContext.cs

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

示例7: MockingProxy

		public MockingProxy(MarshalByRefObject wrappedInstance, IInterceptor interceptor, IMockMixin mockMixin)
			: base(wrappedInstance.GetType())
		{
			this.WrappedInstance = wrappedInstance;
			this.interceptor = interceptor;
			this.mockMixin = mockMixin;
		}
开发者ID:somkidodd,项目名称:JustMockLite,代码行数:7,代码来源:MockingProxy.cs

示例8:

        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

示例9: SessionProvider

 public SessionProvider(IConfigurationBuilder builder, IInterceptor interceptor, IWebContext webContext)
 {
     nhSessionFactory = builder.BuildSessionFactory();
     Debug.WriteLine("Built Session Factory " + DateTime.Now);
     this.webContext = webContext;
     this.interceptor = interceptor;
 }
开发者ID:arp51,项目名称:n2cms,代码行数:7,代码来源:SessionProvider.cs

示例10: RegistrationActivating

        /// <summary>
        /// Registrations the activating.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="Autofac.Core.ActivatingEventArgs&lt;System.Object&gt;"/> instance containing the event data.</param>
        private static void RegistrationActivating(object sender, ActivatingEventArgs<object> e)
        {
            // Ignore AspectConfiguration and IInterceptor types since they're being referenced via the Autofac
            // registration context. Otherwise calling e.Context.Resolve<IInterceptor> will fail when
            // the code below executes.
            if (e.Instance.GetType() == typeof (MasterProxy) || e.Instance is IInterceptor)
            {
                return;
            }

            var proxy = (MasterProxy)e.Context.Resolve(typeof(MasterProxy));

            if (!e.Instance.IsDecorated(proxy.Configuration))
            {
                return;
            }

            var pseudoList = new IInterceptor[proxy.Configuration.Interceptors.Count];
            pseudoList[0] = proxy;

            for (var i = 1; i < pseudoList.Length; i++)
            {
                pseudoList[i] = new PseudoInterceptor();
            }

            var interfaceTypes = e.Instance.GetType().GetInterfaces();
            var targetInterface =
                interfaceTypes.FirstMatch(proxy.Configuration.Namespaces);

            e.Instance = new ProxyGenerator().CreateInterfaceProxyWithTargetInterface(targetInterface, e.Instance, pseudoList);
        }
开发者ID:JorgeGamba,项目名称:Snap,代码行数:36,代码来源:AutofacAspectModule.cs

示例11: PostProcess

        public void PostProcess(IServiceRequestResult result)
        {
            var instance = result.ActualResult;
            var instanceTypeName = instance.GetType().FullName;

            // Ignore any LinFu factories or Snap-specific instances.
            if (instanceTypeName.Contains("LinFu.") || instanceTypeName == "Snap.AspectConfiguration"
                || instanceTypeName == "Snap.IMasterProxy" || instanceTypeName == "Snap.MasterProxy")
            {
                return;
            }

            var proxy = result.Container.GetService<IMasterProxy>();

            if (!instance.IsDecorated(proxy.Configuration))
            {
                return;
            }

            var pseudoList = new IInterceptor[proxy.Configuration.Interceptors.Count];
            pseudoList[0] = proxy;

            for (var i = 1; i < pseudoList.Length; i++)
            {
                pseudoList[i] = new PseudoInterceptor();
            }

            var interfaceTypes = instance.GetType().GetInterfaces();
            var targetInterface =
                interfaceTypes.FirstMatch(proxy.Configuration.Namespaces);

            result.ActualResult = new ProxyGenerator().CreateInterfaceProxyWithTargetInterface(targetInterface, instance, pseudoList);
        }
开发者ID:grava,项目名称:Snap,代码行数:33,代码来源:AspectPostProcessor.cs

示例12: Add

        /// <summary>
        /// Add the interceptor in the argument as the first interceptor
        /// and set its next to the interceptor that we have. In the first
        /// execution it will be the TailInterceptor.
        /// </summary>
        /// <param name="interceptor"></param>
        public virtual void Add(IInterceptor interceptor)
        {
            AssertUtil.ArgumentNotNull(interceptor, "interceptor");

            interceptor.Next = m_interceptor;
            m_interceptor = interceptor;
        }
开发者ID:BackupTheBerlios,项目名称:dpml-svn,代码行数:13,代码来源:InterceptedComponent.cs

示例13: SelectInterceptors

 public IInterceptor[] SelectInterceptors(Type type, System.Reflection.MethodInfo method, IInterceptor[] interceptors)
 {
     if (method.Name == "FunA")
         return interceptors;
     return new IInterceptor[0];
     // ...
 }
开发者ID:RandyGong,项目名称:CastleTest,代码行数:7,代码来源:InterceptorSelector.cs

示例14: GetProxy

 public virtual object GetProxy(Type type, IInterceptor interceptor)
 {
     if (cache.ContainsKey(type))
         return cache[type];
     cache[type] = CreateProxy(interceptor, type);
     return cache[type];
 }
开发者ID:domik82,项目名称:bricks-toolkit,代码行数:7,代码来源:CachedDynamicProxyGenerator.cs

示例15: SelectInterceptors

        public IInterceptor[] SelectInterceptors( Type type, MethodInfo method, IInterceptor[] interceptors )
        {
            if( method.Name.StartsWith( "set_" ) )
                return interceptors;

            return null;
        }
开发者ID:RushPm,项目名称:Restful,代码行数:7,代码来源:EntityInterceptorSelector.cs


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