Exemplo n.º 1
0
        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())));
            }
        }
Exemplo n.º 2
0
 public void RemoveAllInterceptors()
 {
     InterceptorTypes.Clear();
 }
Exemplo n.º 3
0
 public InterceptorOptions RemoveInterceptor <TInterceptor>() where TInterceptor : IInterceptor
 {
     InterceptorTypes.Remove(typeof(TInterceptor));
     return(new InterceptorOptions(this));
 }
Exemplo n.º 4
0
 public InterceptorOptions AddInterceptor <TInterceptor>() where TInterceptor : IInterceptor
 {
     InterceptorTypes.Add(typeof(TInterceptor));
     RecentlyAddedInterceptor = typeof(TInterceptor);
     return(new InterceptorOptions(this));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="type"></param>
 public InterceptorAttribute(InterceptorTypes type)
 {
     Type = type;
 }
Exemplo n.º 6
0
 public GrpcHostBuilder UseInterceptor <TInterceptor>() where TInterceptor : ServerInterceptor
 {
     InterceptorTypes.Add(typeof(TInterceptor));
     return(this);
 }