Exemplo n.º 1
0
        /// <summary>
        /// Replace with scanning Dependency Injection.
        /// </summary>
        /// <param name="services">Services.</param>
        public void ImplDI(IServiceCollection services)
        {
            //Enable AutoMapper with AutoMapperCongif Obj for configuration.
            var mapConfig = _mapperConfig;

            //Add TokenAuth Filter Globaly for all actions.
            services.AddMvc(options => options.Filters.Add(typeof(TokenAuthorizeFilter)));

            services.AddSingleton(mapConfig.GetMapperInstance());

            //Dependency Inject configuration obj to repositories.
            services.AddTransient <RepositoryPayload>(provider => new RepositoryPayload(_configuration));

            //Dependency Inject Token Manager Singleton.
            services.AddSingleton(TokenManagerSingleton.GetInstance(
                                      Convert.ToInt32(_configuration["TokenExpiration:Mins"]),
                                      Convert.ToInt32(_configuration["MaxUsers:Val"])));

            //Dependency Inject Business Services.
            services.AddTransient <IFoodCategoryService, FoodCategoryService>();
            services.AddTransient <IFoodMarkerService, FoodMarkerService>();
            services.AddTransient <IPhotoService, PhotoService>();
            services.AddTransient <IRestaurantService, RestaurantService>();
            services.AddTransient <IUserService, UserService>();
        }
Exemplo n.º 2
0
 public ClientKeyAuthorizeFilter(
     IOptions <ClientAuthConfigObj> config,
     TokenManagerSingleton tokenManager)
 {
     _config       = config.Value;
     _tokenManager = tokenManager;
 }
 public ClientKeyAuthMiddleware(RequestDelegate next,
                                IOptions <ClientAuthConfigObj> config,
                                TokenManagerSingleton tokenManager)
 {
     _next         = next;
     _config       = config.Value;
     _tokenManager = tokenManager;
 }
Exemplo n.º 4
0
 public static TokenManagerSingleton GetInstance(int timeSpanMinutes,
                                                 int maxActiveUsers)
 {
     if (_singleton == null)
     {
         _singleton = new TokenManagerSingleton(timeSpanMinutes,
                                                maxActiveUsers);
         return(_singleton);
     }
     return(_singleton);
 }