コード例 #1
0
        /// <summary>
        /// Create service
        /// Avoid generics with 'new' constraint for Activator.Create performance issue
        /// </summary>
        /// <param name="app">Application</param>
        /// <param name="user">Current user</param>
        /// <returns>Service</returns>
        public static VehicleService Create(IVMSApp app, ICurrentUser user)
        {
            var service = new VehicleService();

            service.Application = app;
            service.User        = user;
            return(service);
        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="app">Application</param>
        /// <param name="distributedCache">Distributed cache</param>
        /// <param name="httpContextAccessor">Http context accessor</param>
        public UserController(IVMSApp app, IDistributedCache distributedCache, IHttpContextAccessor httpContextAccessor)
        {
            // App
            App = app;

            // Cache
            Cache = distributedCache;
        }
コード例 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="app">Application</param>
        /// <param name="distributedCache">Distributed cache</param>
        /// <param name="httpContextAccessor">Http context accessor</param>
        public VehicleController(IVMSApp app, IDistributedCache distributedCache, IHttpContextAccessor httpContextAccessor)
        {
            // Define the user
            var user = CreateUser(httpContextAccessor.HttpContext.User, httpContextAccessor.HttpContext.Connection.RemoteIpAddress);

            // Service
            Service = VehicleService.Create(app, user);

            // Cache
            Cache = distributedCache;
        }