要开发一个搜索引擎。
我想知道我的DDD应该是什么样子。应该实现对记录进行排序,但我不希望我的视图知道我的数据库结构(按哪些列进行排序)。据我所知,排序信息应该来自基础架构层,来自存储库实现,所以必须有一个灵活的域。
它应该是什么样子的?
我希望它是强类型的。
有什么最佳实践吗?
对架构的建议?
发布于 2013-06-04 12:45:29
这是一个自定义搜索引擎的基础知识,它解析MVC视图目录,读取文件,并将提供的文本与正则表达式进行匹配。我的网站返回搜索结果的html链接。这段代码将导致创建一个列表。
List<string> results = new List<string>();
DirectoryInfo di = new DirectoryInfo (System.Configuration.ConfigurationManager.AppSettings["PathToSearchableViews"]);
//get all view directories except the shared
foreach (DirectoryInfo d in di.GetDirectories().Where(d=>d.Name != "Shared"))
{
//get all the .cshtml files
foreach (FileInfo fi in d.GetFiles().Where(e=>e.Extension == ".cshtml"))
{
//check if cshtml file and exclude partial pages
if (fi.Name.Substring(0,1) != "_")
{
MatchCollection matches;
bool foundMatch = false;
int matchCount = 0;
using (StreamReader sr = new StreamReader(fi.FullName))
{
string file = sr.ReadToEnd();
foreach (string word in terms)
{
Regex exp = new Regex("(?i)" + word.Trim() + "(?-i)");
matches = exp.Matches(file);
if (matches.Count > 0)
{
foundMatch = true;
matchCount = matches.Count;
}
}
//check match count and create links
//
//
}
}
}
}
return results;https://stackoverflow.com/questions/688908
复制相似问题