Esempio n. 1
0
        /// <summary>
        /// 获取绝对路径
        /// </summary>
        /// <param name="virtualPath">虚拟路径</param>
        /// <returns></returns>
        public static string GetAbsolutePath(string virtualPath)
        {
            string path = virtualPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

            if (path[0] == '~')
            {
                path = path.Remove(0, 2);
            }
            string rootPath = AutofacHelper.GetService <IHostingEnvironment>().WebRootPath;

            return(Path.Combine(rootPath, path));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取Url
        /// </summary>
        /// <param name="virtualUrl">虚拟Url</param>
        /// <returns></returns>
        public static string GetUrl(string virtualUrl)
        {
            if (!virtualUrl.IsNullOrEmpty())
            {
                UrlHelper urlHelper = new UrlHelper(AutofacHelper.GetService <IActionContextAccessor>().ActionContext);

                return(urlHelper.Content(virtualUrl));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        static ConfigHelper()
        {
            IConfiguration config = AutofacHelper.GetService <IConfiguration>();

            if (config == null)
            {
                var builder = new ConfigurationBuilder()
                              .SetBasePath(AppContext.BaseDirectory)
                              .AddJsonFile("appsettings.json");

                config = builder.Build();
            }

            _config = config;
        }