Example #1
0
        /// <summary>
        /// Query the index from <see cref="IBitmapEndpointStorage"/>
        /// </summary>
        /// <param name="storage"></param>
        /// <param name="context">request context</param>
        /// <returns></returns>
        public static int GetIndex(this IBitmapEndpointStorage storage, HttpContext context)
        {
            if (context == null)
            {
                return(-1);
            }

            var path = string.Empty;

            var endpoint = context.GetEndpoint();

            if (endpoint is RouteEndpoint)
            {
                var routeEndpoint = (RouteEndpoint)endpoint;
                path = routeEndpoint.RoutePattern.RawText;
                foreach (var kv in routeEndpoint.RoutePattern.RequiredValues)
                {
                    path = path.Replace($"{{{kv.Key}}}", kv.Value?.ToString(), StringComparison.OrdinalIgnoreCase);
                }
            }
            else
            {
                path = endpoint.DisplayName;
            }
            return(storage.GetIndex(path, context.Request.Method));
        }
Example #2
0
 public BitmapAuthorizationHandler(IHttpContextAccessor httpContextAccessor,
                                   IBitmapEndpointStorage bitmapEndpointStorage,
                                   IBitmapAuthorization bitmapAuthorization)
 {
     this._httpContextAccessor   = httpContextAccessor;
     this._bitmapEndpointStorage = bitmapEndpointStorage;
     this._bitmapAuthorization   = bitmapAuthorization;
 }
 public AccountController(IBitmapEndpointStorage bitmapEndpointStorage,
                          IBitmapAuthorization bitmapAuthorization,
                          IOptions <SystemOptions> options)
 {
     this._bitmapEndpointStorage = bitmapEndpointStorage;
     this._bitmapAuthorization   = bitmapAuthorization;
     this._options = options;
 }