Exemplo n.º 1
0
        public static string ToVirtualPath(string p)
        {
            Regex r = new Regex(Regex.Escape(ApiHelper.MapPath("~/")), RegexOptions.Compiled);

            p = r.Replace(p, "~/", 1).Replace("\\", "/");
            return(p);
        }
Exemplo n.º 2
0
 public static string ToVirtualPath(string p)
 {
     if (contentRootPathRegex == null)
     {
         contentRootPathRegex = new Regex(Regex.Escape(ApiHelper.MapPath("~/")), RegexOptions.Compiled);
     }
     p = contentRootPathRegex.Replace(p, "~/", 1).Replace("\\", "/");
     return(p);
 }
Exemplo n.º 3
0
        public List <FileInfo> Views(string[] excludePaths = null)
        {
            if (excludePaths == null)
            {
                excludePaths = new string[] { }
            }
            ;
            for (var i = 0; i < excludePaths.Length; i++)
            {
                excludePaths[i] = ApiHelper.MapPath(excludePaths[i]);
            }
            var templateDirPath = ApiHelper.MapPath("~/Views");
            var viewFiles       = new DirectoryInfo(templateDirPath).EnumerateFiles("*.cshtml", SearchOption.AllDirectories)
                                  .Where(x => !excludePaths.Any(y => x.FullName.ToLower().StartsWith(y.ToLower())))
                                  .ToList();

            return(viewFiles);
        }
Exemplo n.º 4
0
        public List <ConfigContainer> GetConfigs()
        {
            var result      = new List <ConfigContainer>();
            var rootDir     = new DirectoryInfo(ApiHelper.MapPath("~/"));
            var configFiles = rootDir.GetFiles().Where(x => x.Name.ToLower().StartsWith("appsettings.") && x.Name.ToLower().EndsWith(".json") && !x.Name.ToLower().Equals("appsettings.json"));

            foreach (var configFile in configFiles)
            {
                var configContainer = new ConfigContainer();
                configContainer.Config = new ConfigurationBuilder()
                                         .SetBasePath(ApiHelper.MapPath("~/"))
                                         .AddJsonFile(configFile.Name)
                                         .Build();
                configContainer.Name = configFile.Name;
                var ename = configFile.Name.Substring(configFile.Name.IndexOf(".") + 1);
                ename = ename.Substring(0, ename.IndexOf("."));
                configContainer.EnvironmentName = ename;
                result.Add(configContainer);
            }
            return(result);
        }