Ejemplo n.º 1
0
        private List <CodeResult> Search(SiteDb sitedb, string keyword)
        {
            List <CodeResult> results = new List <CodeResult>();

            List <IRepository> ReposToCheck = new List <IRepository>();


            foreach (var Repo in SiteRepositoryContainer.Repos)
            {
                var currentRepo = sitedb.GetSiteRepository(Repo.Value);
                if (currentRepo != null)
                {
                    if (Lib.Reflection.TypeHelper.HasInterface(currentRepo.ModelType, typeof(ITextObject)))
                    {
                        ReposToCheck.Add(currentRepo);
                    }
                }
            }

            foreach (var repo in ReposToCheck)
            {
                var items = repo.All();
                foreach (var item in items)
                {
                    var TextItem = item as ITextObject;

                    if (TextItem != null)
                    {
                        var text       = TextItem.Body;
                        var FindResult = Lib.Helper.StringHelper.FindText(text, keyword);
                        if (FindResult != null && FindResult.Any())
                        {
                            var info = GetDisplayInfo(FindResult, sitedb, item);
                            results.Add(info);
                        }
                    }
                }
            }


            return(results);
        }