GetSearchTermForAssemblySearch() public method

public GetSearchTermForAssemblySearch ( ) : string
return string
Esempio n. 1
0
        public void FindAssemblies(Query query, bool defaultToAll = false)
        {
            string assemblyName = query.GetSearchTermForAssemblySearch();

            if (assemblyName == null)
            {
                if (defaultToAll)
                {
                    query.AddResultAssemblies(GetAllListedAssemblies());
                }

                return;
            }

            bool isQuoted = false;

            assemblyName = Query.StripQuotes(assemblyName, out isQuoted);

            var search = new SortedSearch(i => this.assemblies[i].AssemblyName, this.assemblies.Count);
            int low, high;

            search.FindBounds(assemblyName, out low, out high);
            if (high >= low)
            {
                var result = Enumerable
                             .Range(low, high - low + 1)
                             .Where(i => !isQuoted || assemblies[i].AssemblyName.Length == assemblyName.Length)
                             .Select(i => assemblies[i])
                             .Where(a => a.ProjectKey != -1)
                             .Take(MaxRawResults)
                             .ToList();
                query.AddResultAssemblies(result);
            }
        }
        private void WriteAssemblyResults(Index index = null)
        {
            if (query.ResultAssemblies == null || !query.ResultAssemblies.Any())
            {
                return;
            }

            WriteLine("<div class=\"resultGroup\">");
            WriteLine("<div class=\"resultGroupHeader\" onClick=\"toggle(this, '{0}');\">", "Assemblies");
            string count = query.ResultAssemblies.Count.ToString();

            if (count == Index.MaxRawResults.ToString())
            {
                count = "showing first " + Index.MaxRawResults.ToString();
            }

            string assemblySearchTerm = query.GetSearchTermForAssemblySearch() ?? "";

            if (!string.IsNullOrEmpty(assemblySearchTerm))
            {
                assemblySearchTerm = "that start with '" + assemblySearchTerm + "' ";
            }

            string assemblyHeader = "Assemblies " + assemblySearchTerm + "(" + count + ")";

            WriteLine("<div class=\"resultGroupAssemblyName\">{0}</div>", assemblyHeader);
            //WriteLine(sb, "<div class=\"resultGroupProjectPath\">{0}</div>", Markup.HtmlEscape(symbolsInAssembly.First().ProjectFilePath));
            WriteLine("</div>");
            WriteLine("<div id=\"{0}\">", "Assemblies");

            foreach (var assembly in query.ResultAssemblies)
            {
                var url = assembly;
                WriteLine("<a href=\"/#{0}\" target=\"_top\"><div class=\"resultItem\"><div class=\"resultLine\">{0}</div>", url.AssemblyName);
                var projectKey = url.ProjectKey;
                if (projectKey >= 0)
                {
                    WriteLine("<div class=\"resultDescription\">{0}</div></div></a>", index.projects[projectKey]);
                }
                else
                {
                    WriteLine("</div></a>");
                }
            }

            WriteLine("</div></div>");
        }
Esempio n. 3
0
        public void FindAssemblies(Query query, bool defaultToAll = false)
        {
            string assemblyName = query.GetSearchTermForAssemblySearch();
            if (assemblyName == null)
            {
                if (defaultToAll)
                {
                    query.AddResultAssemblies(GetAllListedAssemblies());
                }

                return;
            }

            bool isQuoted = false;
            assemblyName = Query.StripQuotes(assemblyName, out isQuoted);

            var search = new SortedSearch(i => this.assemblies[i].AssemblyName, this.assemblies.Count);
            int low, high;
            search.FindBounds(assemblyName, out low, out high);
            if (high >= low)
            {
                var result = Enumerable
                    .Range(low, high - low + 1)
                    .Where(i => !isQuoted || assemblies[i].AssemblyName.Length == assemblyName.Length)
                    .Select(i => assemblies[i])
                    .Where(a => a.ProjectKey != -1)
                    .Take(MaxRawResults)
                    .ToList();
                query.AddResultAssemblies(result);
            }
        }