public void OnEntry(IMethodContextAdapter methodContext, string role)
 {
     Console.WriteLine("[Auth] Checking if user is in {0} role", role);
     if (UserIsInRole(role))
     {
         Console.WriteLine("[Auth] User IS authorized");
         return;
     }
     Console.WriteLine("[Auth] User is NOT authorized");
     methodContext.AbortMethod();
     UnauthorizedAccess();
 }
Ejemplo n.º 2
0
 public void OnEntry(IMethodContextAdapter methodContext, string role)
 {
     Console.WriteLine("[Auth] Checking if user is in {0} role", role);
     if (UserIsInRole(role))
     {
         Console.WriteLine("[Auth] User IS authorized");
         return;
     }
     Console.WriteLine("[Auth] User is NOT authorized");
     methodContext.AbortMethod();
     UnauthorizedAccess();
 }
Ejemplo n.º 3
0
 public void OnEntry(IMethodContextAdapter methodContext)
 {
     var cacheKey = BuildCacheKey(methodContext);
     if (!_cache.ContainsKey(cacheKey))
     {
         Console.WriteLine("[Cache] MISS for {0}", cacheKey);
         methodContext.Tag = cacheKey;
         return;
     }
     Console.WriteLine("[Cache] HIT for {0}", cacheKey);
     methodContext.ReturnValue = _cache[cacheKey];
     methodContext.AbortMethod();
 }
Ejemplo n.º 4
0
        public void OnEntry(IMethodContextAdapter methodContext)
        {
            var cacheKey = BuildCacheKey(methodContext);

            if (!_cache.ContainsKey(cacheKey))
            {
                Console.WriteLine("[Cache] MISS for {0}", cacheKey);
                methodContext.Tag = cacheKey;
                return;
            }
            Console.WriteLine("[Cache] HIT for {0}", cacheKey);
            methodContext.ReturnValue = _cache[cacheKey];
            methodContext.AbortMethod();
        }