Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                // Step Two: Create TELog, and log the start of the application.
                //

                TELog.Log("Search application started");

                // Step Four: Instantiate a Search Domain
                //

                SearchDomain domain = new SearchDomain("data");
                TELog.Log(domain.ToString());

                // Step Six: Single word search
                //

                SearchEngine searchEngine = new SearchEngine(domain);
                searchEngine.IndexFiles();

                SearchAndPrintResults(searchEngine, "squirrel");
                SearchAndPrintResults(searchEngine, "Larry");
                // Step Seven: Multiple word search
                //

                SearchAndPrintResults(searchEngine, "telephone line");
            }
            catch (Exception ex)
            {
                Console.WriteLine("General exception occurred:\n" + ex.StackTrace);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                // Step Two: Create TELog, and log the start of the application.
                //
                TELog.Log("Search application started");


                // Step Four: Instantiate a Search Domain
                //
                SearchDomain sd = new SearchDomain("data");
                TELog.Log("Indexed files:\n" + sd.ToString());

                // Step Six: Single word search
                //



                // Step Seven: Multiple word search
                //
            }
            catch (Exception ex)
            {
                Console.WriteLine("General exception occurred:\n" + ex.StackTrace);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            try
            {
                // Step Two: Create TELog, and log the start of the application.
                //

                TELog.Log("Search application started");

                // Step Four: Instantiate a Search Domain
                //

                SearchDomain sd = new SearchDomain("data");
                TELog.Log(sd.ToString());

                // Step Six: Single word search
                //
                SearchEngine searchEngine = new SearchEngine(sd);

                searchEngine.IndexFiles();

                Console.WriteLine("Single Word Search Result (squrrel):");

                IList <string> filesWithSquirrel = searchEngine.Search("squirrel");

                PrintListContents(filesWithSquirrel);

                // Step Seven: Multiple word search
                //

                Console.WriteLine("Multi Word Search Result (telephone line):");

                IList <string> multiWordSearchResult = searchEngine.Search("telephone line");

                PrintListContents(multiWordSearchResult);
            }
            catch (Exception ex)
            {
                Console.WriteLine("General exception occurred:\n" + ex.StackTrace);
            }
        }
Пример #4
0
    private void DrawPropertyConfiguration(Action onValueChanged)
    {
        if (m_fieldValueType == null)
        {
            return;
        }

        if (m_matchingTypes == null)
        {
            m_matchingTypes = new List <Type> ();

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                var matchingTypes = assembly.GetTypes()
                                    .Where(t => !t.IsInterface)
                                    .Where(t => m_fieldValueElementType.IsAssignableFrom(t));

                foreach (var t in matchingTypes)
                {
                    if (!m_matchingTypes.Contains(t))
                    {
                        m_matchingTypes.Add(t);
                    }
                }
            }
        }

        var newSearchDomain = (SearchDomain)EditorGUILayout.EnumPopup("Search Domain", m_searchDomain);

        if (newSearchDomain != m_searchDomain)
        {
            m_searchDomain = newSearchDomain;
            onValueChanged();
        }

        var newTypeMatch = (TypeMatchPolicy)EditorGUILayout.EnumPopup("Type Match", m_typeMatchPolicy);

        if (newTypeMatch != m_typeMatchPolicy)
        {
            m_typeMatchPolicy = newTypeMatch;
            onValueChanged();
        }

        var newSearchName = EditorGUILayout.TextField("Name Pattern", m_searchingNamePattern);

        if (newSearchName != m_searchingNamePattern)
        {
            m_searchingNamePattern = newSearchName;
            onValueChanged();
        }

        using (new EditorGUI.DisabledScope(newTypeMatch != TypeMatchPolicy.SpecificTypes)) {
            string label = string.Empty;
            if (m_selectedMachingTypeNames.Count > 1)
            {
                label = "Mixed...";
            }
            else if (m_selectedMachingTypeNames.Count == 1)
            {
                if (m_niceTypeName == null)
                {
                    Type t = Type.GetType(m_selectedMachingTypeNames[0]);
                    m_niceTypeName = ObjectNames.NicifyVariableName(t.Name);
                }
                label = m_niceTypeName;
            }

            using (new GUILayout.HorizontalScope()) {
                GUILayout.Label("Maching Types");
                if (EditorGUILayout.DropdownButton(new GUIContent(label), FocusType.Passive))
                {
                    var menu = new GenericMenu();

                    foreach (var t in m_matchingTypes)
                    {
                        string name      = t.Name;
                        string aqn       = t.AssemblyQualifiedName;
                        var    isChecked = m_selectedMachingTypeNames.Contains(aqn);
                        menu.AddItem(new GUIContent(ObjectNames.NicifyVariableName(name)),
                                     isChecked,
                                     () => {
                            m_niceTypeName = null;
                            if (m_selectedMachingTypeNames.Contains(aqn))
                            {
                                m_selectedMachingTypeNames.Remove(aqn);
                            }
                            else
                            {
                                m_selectedMachingTypeNames.Add(aqn);
                            }
                            if (m_selectedMatchingTypes != null)
                            {
                                m_selectedMatchingTypes.Clear();
                            }
                        });
                    }

                    menu.ShowAsContext();
                }
            }
        }
    }
 public SearchController(SearchDomain domain)
 {
     SearchDomain = domain;
 }
        static void Main(string[] args)
        {
            try
            {
                // Step Two: Create TELog, and log the start of the application.
                //
                TELog.Log("Search application started");

                // Step Four: Instantiate a Search Domain
                //
                SearchDomain sd = new SearchDomain("data");
                TELog.Log("Indexed files:\n" + sd.ToString());

                //// Step Six: Single word search
                ////
                //SearchEngine se = new SearchEngine(sd);
                //se.IndexFiles();
                //IList<string> foundInFiles = se.Search("squirrel");
                //if (foundInFiles.Count > 0)
                //{
                //    foreach (string file in foundInFiles)
                //    {
                //        Console.WriteLine(file);
                //    }
                //}
                //else
                //{
                //    Console.WriteLine("The search term does not appear in any of the indexed files.");
                //}

                //foundInFiles = se.Search("Larry");
                //if (foundInFiles.Count > 0)
                //{
                //    foreach (string file in foundInFiles)
                //    {
                //        Console.WriteLine(file);
                //    }
                //}
                //else
                //{
                //    Console.WriteLine("The search term does not appear in any of the indexed files.");
                //}

                // Step Seven: Multiple word search
                //
                SearchEngine se = new SearchEngine(sd);
                se.IndexFiles();
                IList <string> foundInFiles = se.Search("telephone line");
                if (foundInFiles.Count > 0)
                {
                    foreach (string file in foundInFiles)
                    {
                        Console.WriteLine(file);
                    }
                }
                else
                {
                    Console.WriteLine("The search term does not appear in any of the indexed files.");
                }
            }
            catch (SearchDomainException ex)
            {
                TELog.Log("Search domain exception occurred:\n" + ex.StackTrace);
            }
            catch (Exception ex)
            {
                Console.WriteLine("General exception occurred:\n" + ex.StackTrace);
            }
        }