public Interceptor(IAnnotatedType type, WeldComponentManager manager, bool allowPartialInterception) : base(type, manager) { AllowPartialInterception = allowPartialInterception; InterceptorBindings = Annotations.OfType <IInterceptorBinding>().Select(x => x.GetType()).ToArray(); InterceptorTypes = AllInterceptorTypes.Where(x => x.IsAssignableFrom(type.Type)).ToArray(); if (!InterceptorBindings.Any()) { throw new InvalidComponentException(type.Type, "Interceptor must have at least one interceptor-binding attribute"); } if (!InterceptorTypes.Any()) { throw new InvalidComponentException(type.Type, "Interceptor must implement " + string.Join(" or ", AllInterceptorTypes.Select(x => x.ToString()))); } }
public void RemoveAllInterceptors() { InterceptorTypes.Clear(); }
public InterceptorOptions RemoveInterceptor <TInterceptor>() where TInterceptor : IInterceptor { InterceptorTypes.Remove(typeof(TInterceptor)); return(new InterceptorOptions(this)); }
public InterceptorOptions AddInterceptor <TInterceptor>() where TInterceptor : IInterceptor { InterceptorTypes.Add(typeof(TInterceptor)); RecentlyAddedInterceptor = typeof(TInterceptor); return(new InterceptorOptions(this)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="type"></param> public InterceptorAttribute(InterceptorTypes type) { Type = type; }
public GrpcHostBuilder UseInterceptor <TInterceptor>() where TInterceptor : ServerInterceptor { InterceptorTypes.Add(typeof(TInterceptor)); return(this); }