Esempio n. 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            InterceptorHandler.Init().RegisterInterceptors(new InterceptorRegisteration());

            GlobalFilters.Filters.Add(new InterceptorActionFilter());
        }
 public static object InstantiateProxy(Type interfaceType, InterceptorHandler interceptor)
 {
     if (interfaceType == null)
     {
         throw new ArgumentNullException(nameof(interfaceType));
     }
     return(activatorCache.GetOrAdd(interfaceType, _ =>
     {
         var classType = RetrieveProxyType(interfaceType);
         var ctor = classType.GetConstructor(new Type[] { typeof(InterceptorHandler) });
         var handlerParam = Expression.Parameter(typeof(InterceptorHandler), nameof(interceptor));
         var createInst = Expression.New(ctor, handlerParam);
         var expr = Expression.Lambda(typeof(Func <InterceptorHandler, object>), createInst, handlerParam);
         return (Func <InterceptorHandler, object>)expr.Compile();
     })(interceptor));
 }
Esempio n. 3
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="ih">Interceptを行うデリゲート</param>
 public DelegateInterceptor(InterceptorHandler ih)
 {
     interceptorHandler = ih;
 }
 public static TInterface InstantiateProxy <TInterface>(InterceptorHandler interceptor) => (TInterface)InstantiateProxy(typeof(TInterface), interceptor);