src/Newdtek.Master.Core/Web/WebContentFolderHelper.cs
(完整代码) 1KBusing System;
using System.IO;
using System.Linq;
using Abp.Reflection.Extensions;
namespace Newdtek.Master.Web
{
/// <summary>
/// This class is used to find root path of the web project in;
/// unit tests (to find views) and entity framework core command line commands (to find conn string).
/// </summary>
public static class WebContentDirectoryFinder
{
public static string CalculateContentRootFolder()
{
var coreAssemblyDirectoryPath = Path.GetDirectoryName(typeof(MasterCoreModule).GetAssembly().Location);
if (coreAssemblyDirectoryPath == null)
{
throw new Exception("Could not find location of Newdtek.Master.Core assembly!");
}
var directoryInfo = new DirectoryInfo(coreAssemblyDirectoryPath);
while (!DirectoryContains(directoryInfo.FullName, "Newdtek.Master.sln"))
{
if (directoryInfo.Parent == null)
{
throw new Exception("Could not find content root folder!");
}
directoryInfo = directoryInfo.Parent;
}
var webMvcFolder = Path.Combine(directoryInfo.FullName, "src", "Newdtek.Master.Web.Mvc");
if (Directory.Exists(webMvcFolder))
{
return webMvcFolder;
}
var webHostFolder = Path.Combine(directoryInfo.FullName, "src", "Newdtek.Master.Web.Host");
if (Directory.Exists(webHostFolder))
{
return webHostFolder;
}
throw new Exception("Could not find root folder of the web project!");
}
private static bool DirectoryContains(string directory, string fileName)
{
return Directory.GetFiles(directory).Any(filePath => string.Equals(Path.GetFileName(filePath), fileName));
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。