Esempio 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())));
            }
        }
Esempio n. 2
0
 public void RemoveAllInterceptors()
 {
     InterceptorTypes.Clear();
 }
Esempio n. 3
0
 public InterceptorOptions RemoveInterceptor <TInterceptor>() where TInterceptor : IInterceptor
 {
     InterceptorTypes.Remove(typeof(TInterceptor));
     return(new InterceptorOptions(this));
 }
Esempio n. 4
0
 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;
 }
Esempio n. 6
0
 public GrpcHostBuilder UseInterceptor <TInterceptor>() where TInterceptor : ServerInterceptor
 {
     InterceptorTypes.Add(typeof(TInterceptor));
     return(this);
 }