src/EasyFrameWork/Mvc/ApplicationContext.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using System;
using Easy.Models;
using Easy.Modules.User.Service;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Easy.Extend;
using Microsoft.AspNetCore.Authentication;
using Easy.Mvc.Authorize;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Easy.Mvc.StateProviders;
using System.Linq;

namespace Easy.Mvc
{
    public class ApplicationContext : IApplicationContext
    {
        private readonly ConcurrentDictionary<string, Func<object>> _stateResolvers;
        private static ConcurrentDictionary<string, Type> ContextStateProviders;
        static ApplicationContext()
        {
            ContextStateProviders = new ConcurrentDictionary<string, Type>();
        }
        public ApplicationContext(IHttpContextAccessor httpContextAccessor)
        {
            _stateResolvers = new ConcurrentDictionary<string, Func<object>>();
            HttpContextAccessor = httpContextAccessor;
        }
        public IHttpContextAccessor HttpContextAccessor
        {
            get;
        }
        public IUser CurrentUser
        {
            get
            {
                return Get<IUser>(nameof(CurrentUser));
            }
        }
        public IUser CurrentCustomer
        {
            get
            {
                return Get<IUser>(nameof(CurrentCustomer));
            }
        }
        public IWebHostEnvironment HostingEnvironment
        {
            get { return Get<IWebHostEnvironment>(nameof(HostingEnvironment)); }
        }
        public bool IsAuthenticated
        {
            get { return HttpContextAccessor.HttpContext.User.Identity.IsAuthenticated; }
        }
        public T As<T>() where T : class, IApplicationContext
后面还有 58 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。