Exemplo n.º 1
0
 /// <summary>
 /// (search.merge)
 /// </summary>
 /// <param name="query"></param>
 /// <returns>catalogs contains song, album, artist</returns>
 public async override Task <CatalogContent> GetCatalogAsync(string query, int pageNumber = 1, int?pageSize = default(int?))
 {
     return(await this.GetResponse(new CatalogContent(), SearchMethod.Merge(query, pageNumber, pageSize), (o) =>
     {
         ContentConverter.Convert(o, (merge)JsonConvert.DeserializeObject(o.Value, typeof(merge)));
     }));
 }
Exemplo n.º 2
0
        private Type GetRawSearchTypeForSearchMethod(SearchMethod searchMethod)
        {
            switch (searchMethod)
            {
            case SearchMethod.TrialAndError:
                return(typeof(TrialAndError <>));

            case SearchMethod.HillClimbing:
                return(typeof(HillClimbing <>));

            case SearchMethod.BreadthFirstSearch:
                return(typeof(BreadthFirstSearch <>));

            case SearchMethod.DepthFirstSearch:
                return(typeof(DepthFirstSearch <>));

            case SearchMethod.BackTrack:
                return(typeof(BackTrack <>));

            case SearchMethod.OptimalSearch:
                return(typeof(OptimalSearch <>));

            case SearchMethod.AStar:
                return(typeof(AStar <>));
            }

            return(null);
        }
 /// <summary>
 ///   支持对IQueryable通过字符串指定属性的查询
 /// </summary>
 /// <typeparam name = "TEntity"></typeparam>
 /// <param name = "table">IQueryable的查询对象</param>
 /// <param name = "field">属性名</param>
 /// <param name = "method">判断谓词</param>
 /// <param name = "value">值</param>
 /// <returns></returns>
 public static IQueryable <TEntity> Where <TEntity>(this IQueryable <TEntity> table, string field,
                                                    SearchMethod method, object value)
 {
     return(table.Where(new SearchItem {
         Field = field, Method = method, Value = value
     }));
 }
Exemplo n.º 4
0
        public IList <Benday.EasyAuthDemo.Api.DomainModels.Person> Search(
            SearchMethod searchTypeFirstName      = SearchMethod.Contains,
            string searchValueFirstName           = null,
            SearchMethod searchTypeLastName       = SearchMethod.Contains,
            string searchValueLastName            = null,
            SearchMethod searchTypePhoneNumber    = SearchMethod.Contains,
            string searchValuePhoneNumber         = null,
            SearchMethod searchTypeEmailAddress   = SearchMethod.Contains,
            string searchValueEmailAddress        = null,
            SearchMethod searchTypeStatus         = SearchMethod.Contains,
            string searchValueStatus              = null,
            SearchMethod searchTypeCreatedBy      = SearchMethod.Contains,
            string searchValueCreatedBy           = null,
            SearchMethod searchTypeLastModifiedBy = SearchMethod.Contains,
            string searchValueLastModifiedBy      = null,

            SearchMethod searchTypeThingy = SearchMethod.Contains,
            string searchValueThingy      = null,

            string sortBy          = null, string sortByDirection = null,
            int maxNumberOfResults = 100)
        {
            WasSearchUsingParametersCalled = true;

            return(SearchUsingParametersReturnValue);
        }
Exemplo n.º 5
0
 public void ManualSolve(int card1, int card2, int card3, int card4)
 {
     solver = new DFS();
     solver.acceptInput(new Cards(card1 + "", card2 + "", card3 + "", card4 + ""));
     solver.search();
     PrintOutput(solver.receiveOutput());
 }
Exemplo n.º 6
0
        private IEnumerable <SearchDataDto> GetUser(SearchMethod methodResult, string searchTerm)
        {
            var dataQuery = this.usersRepository.AllAsNoTracking().AsQueryable();

            if (methodResult == SearchMethod.Id)
            {
                dataQuery = dataQuery
                            .Where(a => a.Id == searchTerm)
                            .AsQueryable();
            }
            else if (methodResult == SearchMethod.Username || methodResult == SearchMethod.Title)
            {
                dataQuery = dataQuery
                            .Where(a => a.UserName == searchTerm)
                            .AsQueryable();
            }

            return(dataQuery
                   .Select(d => new SearchDataDto
            {
                Id = d.Id,
                Title = d.Email,
                Content = $"{d.FirstName} {d.LastName}",
                Username = d.UserName,
            })
                   .ToList());
        }
Exemplo n.º 7
0
        private IEnumerable <SearchDataDto> GetReview(SearchMethod methodResult, string searchTerm)
        {
            var dataQuery = this.customersReviesRepository.AllAsNoTracking().AsQueryable();

            if (methodResult == SearchMethod.Id)
            {
                if (int.TryParse(searchTerm, out int id))
                {
                    dataQuery = dataQuery
                                .Where(a => a.Id == id)
                                .AsQueryable();
                }
                else
                {
                    return(null);
                }
            }
            else if (methodResult == SearchMethod.Username || methodResult == SearchMethod.Title)
            {
                dataQuery = dataQuery
                            .Where(a => a.User.UserName == searchTerm)
                            .AsQueryable();
            }

            return(dataQuery
                   .Select(d => new SearchDataDto
            {
                Id = d.Id.ToString(),
                Title = d.Appraiser.UserName,
                Content = d.Comment,
                Username = d.User.UserName,
            })
                   .ToList());
        }
Exemplo n.º 8
0
        private void Check(SearchMethod Mode = SearchMethod.Static)
        {
            if (LP != DaCamera.transform.position || LR != DaCamera.transform.rotation)
            {
                LP = DaCamera.transform.position; LR = DaCamera.transform.rotation;

                if (Mode == SearchMethod.Normal)
                {
                    Populate(ControlTag);
                }

                VisibleObjects = 0;
                foreach (GameObject GO in SFCO)
                {
                    Plane[] planes = GeometryUtility.CalculateFrustumPlanes(DaCamera);
                    OS = GeometryUtility.TestPlanesAABB(planes, GO.GetComponent <Renderer>().bounds);

                    VisibleObjects += OS ? 1 : 0;

                    if (GO.GetComponent <Renderer>().enabled != OS)
                    {
                        GO.GetComponent <Renderer>().enabled = OS;
                    }
                }
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// (search.catalogSug)
 /// </summary>
 /// <param name="query"></param>
 /// <returns>suggestion contain song, album, artist</returns>
 public async override Task <CatalogSuggestionContent> GetCatalogSuggestionAsync(string query)
 {
     return(await this.GetResponse(new CatalogSuggestionContent(), SearchMethod.CatalogSug(query), (o) =>
     {
         catalogSug catalogSug = (catalogSug)JsonConvert.DeserializeObject(o.Value, typeof(catalogSug));
     }));
 }
Exemplo n.º 10
0
        private static ISearch GetSearch <T>(SearchMethod searchMethod, Problem <T> problem) where T : class, IState
        {
            switch (searchMethod)
            {
            case SearchMethod.BreadthFirstSearch:
                return(new BreadthFirstSearch <T>(problem));

            case SearchMethod.DepthFirstSearch:
                return(new DepthFirstSearch <T>(problem));

            case SearchMethod.BackTrack:
                return(new BackTrack <T>(problem));

            case SearchMethod.OptimalSearch:
                return(new OptimalSearch <T>(problem));

            case SearchMethod.AStar:
                return(new AStar <T>(problem));

            case SearchMethod.TrialAndError:
                return(new TrialAndError <T>(problem));

            case SearchMethod.HillClimbing:
                return(new HillClimbing <T>(problem));
            }

            return(null);
        }
Exemplo n.º 11
0
        async Task <SearchResponse <T> > RunSearch <T>(HttpClient httpClient, SearchMethod method, string url, IDictionary <string, string> parameters)
        {
            var info = new SearchInfo(url, parameters);

            var request = method == SearchMethod.Post ?
                          httpClient.PostAsync(url, new FormUrlEncodedContent(parameters)) :
                          httpClient.GetAsync(MakeGetUrl(url, parameters));

            using (var httpResponse = await request.ConfigureAwait(false))
            {
                using (var content = await httpResponse.Content.ReadAsStreamAsync().ConfigureAwait(false))
                    using (var streamReader = new StreamReader(content, Encoding.UTF8))
                        using (var jsonReader = new JsonTextReader(streamReader))
                        {
                            if (!httpResponse.IsSuccessStatusCode)
                            {
                                throw HandleSearchError(httpResponse, jsonReader, info);
                            }

                            var response = _responseDeserializer.Deserialize <SearchResponse <T> >(jsonReader);
                            response.Request = info;
                            return(response);
                        }
            }
        }
Exemplo n.º 12
0
        // Popis: Pomocí zvolené vyhledávací metody se pokusí najít blok obsahující interval hodnot,
        //        do které spadá hledaná hodnota. Při prohledávání bloků načítá pouze jejich hlavičky.
        //        Ve chvíli, kdy najde správný blokc, celý ho načt a uloží do paměti. Nad jeho daty
        //        následně provádí opěd zvolenou metodu vyhledávání dat, tentokrát již na poli hodnot.
        /// <summary>
        /// Find item in binary data
        /// </summary>
        /// <param name="key">Searching key</param>
        /// <param name="method">Searching method</param>
        /// <returns>Found key or null</returns>
        public T Find(string key, SearchMethod method = SearchMethod.Interpolation)
        {
            // Get searched hash
            int        keyHash = GetHash(key);
            FileStream file    = GetFileStream(FileMode.Open);

            FileMeta metadata;
            int      headerLength;

            {
                // Read file meta block
                (int offset, FileMeta data)header = ReadMetaHeader(file);
                metadata     = header.data;
                headerLength = header.offset;
            }

            // Find block data with valid range
            DataItem[] values = FindBlockData(file, metadata, keyHash, headerLength, method).blockData;
            T          value  = default;

            if (values != null && values.Length > 0)
            {
                // Find value in block data
                value = SearchInBlock(values, keyHash, key, method);
            }

            file.Close();
            return(value);
        }
Exemplo n.º 13
0
Arquivo: Solver.cs Projeto: MOAAS/IART
        public List <ZhedStep> Solve(SearchMethod searchMethod)
        {
            Func <ZhedBoard, int> heuristic = Heuristic5;

            PriorityQueue <Node> queue = new PriorityQueue <Node>();

            queue.Enqueue(new Node(this.board, null, null, 1), 1);

            DFSPriority = int.MaxValue;
            int visitedNodes = 0;

            while (queue.Count > 0)
            {
                visitedNodes++;
                Node nextNode = queue.Dequeue();

                //  Console.WriteLine("Visit number {0}", visitedNodes); nextNode.board.PrintBoard();
                //  Console.WriteLine("Value of board: {0}" , nextNode.board.getBoardMaxValue());

                if (nextNode.board.isOver)
                {
                    Console.WriteLine("Visited {0} nodes", visitedNodes);
                    return(GetPath(nextNode));
                }
                List <Node> children = GetNextGeneration(nextNode, heuristic);
                foreach (Node node in children)
                {
                    queue.Enqueue(node, NodePriority(searchMethod, node));
                }
            }
            return(null);
        }
Exemplo n.º 14
0
        public DossierSearchBoxPopup(SearchField searchField)
        {
            InitializeComponent();
            this.ArchiveField              = searchField.Field;
            comboBoxExtendedAndOr.Visible  = searchField.Relation != SearchField.Relations.None;
            comboBoxExtendedAndOr.Location = new Point(lblField.Location.X + lblField.Width + 5, comboBoxExtendedAndOr.Location.Y);
            this.Width = comboBoxExtendedAndOr.Location.X + comboBoxExtendedAndOr.Width + 50;
            if (comboBoxExtendedAndOr.Visible == false)
            {
                this.Width -= comboBoxExtendedAndOr.Width;
            }
            contextMenuStripSelect.Enabled       = false;
            searchMethodBindingSource.DataSource = SearchMethod.GetAllSearchMethods();
            switch (searchField.Relation)
            {
            case SearchField.Relations.None:
                break;

            case SearchField.Relations.And:
                comboBoxExtendedAndOr.SelectedIndex = 0;
                break;

            case SearchField.Relations.Or:
                comboBoxExtendedAndOr.SelectedIndex = 1;
                break;
            }
            comboBoxExtendedMethod.SelectedValue = searchField.Method.Code;
            textBoxExtendedValue.Text            = searchField.Value;
            btnAdd.Text = "ثبت";
        }
Exemplo n.º 15
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is SearchMethod)
            {
                SearchMethod searchMethod = (SearchMethod)value;
                switch (searchMethod)
                {
                case SearchMethod.HillClimbing:
                    return("Hegymászó módszer");

                case SearchMethod.TrialAndError:
                    return("Próba-hiba módszer");

                case SearchMethod.BackTrack:
                    return("BackTrack");

                case SearchMethod.BreadthFirstSearch:
                    return("Szélességi kereső");

                case SearchMethod.DepthFirstSearch:
                    return("Mélységi kereső");

                case SearchMethod.OptimalSearch:
                    return("Optimális kereső");

                case SearchMethod.AStar:
                    return("A* kereső");
                }
            }

            return(value);
        }
Exemplo n.º 16
0
 /// <summary>
 /// (search.common)
 /// </summary>
 /// <param name="query"></param>
 /// <returns>only songs</returns>
 public async override Task <SongContent> GetSongsAsync(string query, int pageNumber = 1, int?pageSize = default(int?))
 {
     return(await this.GetResponse(new SongContent(), SearchMethod.Common(query, pageNumber, pageSize), (o) =>
     {
         common common = (common)JsonConvert.DeserializeObject(o.Value, typeof(common));
     }));
 }
Exemplo n.º 17
0
        public async Task <IActionResult> List(string name, [FromQuery] SearchMethod method = SearchMethod.Simple, [FromQuery] string query = null, [FromQuery] bool desc = true, [FromQuery] string skipToken = null, [FromQuery] int limit = 20, [FromQuery] RenderStyle style = RenderStyle.Default)
        {
            var collection = await _settings.FindCollectionAsync(name);

            var items = method == SearchMethod.Simple
                        ? await _data.SearchAsync(name, query, skipToken, limit, desc)
                        : await _data.QueryAsync(name, query, skipToken, limit, desc);

            if (!desc)
            {
                items = items.Reverse();
            }

            var model = new CollectionViewModel
            {
                SearchMethod   = method,
                SeachQuery     = query,
                TitlePath      = collection.TitlePath,
                Items          = items,
                CollectionName = name,
                DisplayName    = collection.DisplayName,
                Procedures     = collection.Procedures ?? new ProcedureInfo[0],
                Limit          = limit
            };

            if (style == RenderStyle.NoBlade)
            {
                return(View("ListNoBlade", model));
            }

            return(View(model));
        }
Exemplo n.º 18
0
        //This is horribly inefficient. Should only be used when absolutely necessary, like finding a troll
        public IEnumerable<ContentObject> DeepSearch(IEnumerable<string> terms, SearchMethod method = SearchMethod.OR)
        {
            IEnumerable<ContentObject> results = null;
            foreach (string term in terms)
                results = combineResults(results, DeepSearch(term), method);

            return results;
        }
Exemplo n.º 19
0
        public ISearch CreateSearch(SearchMethod searchMethod)
        {
            Type    rawSearchType  = GetRawSearchTypeForSearchMethod(searchMethod);
            Type    searchType     = rawSearchType.MakeGenericType(this.stateType);
            ISearch searchInstance = Activator.CreateInstance(searchType, problem) as ISearch;

            return(searchInstance);
        }
Exemplo n.º 20
0
 public void AddArgument(
     string propertyName,
     SearchMethod method,
     string value,
     SearchOperator combineWithOtherArgumentsAs = SearchOperator.And)
 {
     Arguments.Add(
         new SearchArgument(propertyName, method, value, combineWithOtherArgumentsAs));
 }
Exemplo n.º 21
0
 private void comboBoxExtendedMethod_SelectedValueChanged(object sender, EventArgs e)
 {
     Njit.Program.Controls.ComboBoxExtended c = sender as Njit.Program.Controls.ComboBoxExtended;
     if (c.SelectedItem != null)
     {
         SearchMethod method = c.SelectedItem as SearchMethod;
         textBoxExtendedValue_Advance.Enabled = textBoxExtendedValue_Simple.Enabled = method.RequiredValue;
     }
 }
Exemplo n.º 22
0
 private static List <SearchField> LoadSearchFields(Model.Archive.ArchiveDataClassesDataContext dc, Model.Archive.ReportDetail reportDetail, List <SearchField> searchFields)
 {
     foreach (var item in dc.ReportDetails.Where(t => t.ParentID == reportDetail.ID))
     {
         List <SearchField> innerSearchFields = new List <SearchField>();
         LoadSearchFields(dc, item, innerSearchFields);
         searchFields.Add(new SearchField(item.ArchiveField, SearchMethod.GetAllSearchMethods().Where(t => t.Code == item.MethodCode).Single(), item.Value, (SearchField.Relations)item.RelationCode, innerSearchFields));
     }
     return(searchFields);
 }
 public SearchArgument(
     string propertyName,
     SearchMethod method,
     string searchValue,
     SearchOperator addAsOperator = SearchOperator.And)
 {
     PropertyName = propertyName ?? throw new ArgumentNullException(nameof(propertyName));
     Method       = method;
     SearchValue  = searchValue ?? throw new ArgumentNullException(nameof(searchValue));
     Operator     = addAsOperator;
 }
Exemplo n.º 24
0
        protected async void Search(object source, ElapsedEventArgs e)
        {
            isSearching          = true;
            isShowingSuggestions = false;
            await InvokeAsync(StateHasChanged);

            Suggestions          = (await SearchMethod.Invoke(searchText)).ToArray();
            isSearching          = false;
            isShowingSuggestions = true;
            await InvokeAsync(StateHasChanged);
        }
Exemplo n.º 25
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (this.DesignMode)
     {
         return;
     }
     this.archiveTabBindingSource.DataSource = Controller.Archive.ArchiveTabController.GetActiveDossierTabs();
     searchMethodBindingSource.DataSource    = SearchMethod.GetAllSearchMethods();
     this.tabControl1.SelectedTab            = tabPage3;
 }
Exemplo n.º 26
0
        //This is horribly inefficient. Should only be used when absolutely necessary, like finding a troll
        public IEnumerable <ContentObject> DeepSearch(IEnumerable <string> terms, SearchMethod method = SearchMethod.OR)
        {
            IEnumerable <ContentObject> results = null;

            foreach (string term in terms)
            {
                results = combineResults(results, DeepSearch(term), method);
            }

            return(results);
        }
Exemplo n.º 27
0
 /// <summary>
 /// Найти элемент
 /// </summary>
 /// <param name="webElement">Веб-элемент</param>
 /// <param name="searchMethod">Метод поиска</param>
 /// <param name="attribute">Атрибут, по которому осуществляется поиск</param>
 /// <returns>Элемент</returns>
 public static IWebElement FindElement(this IWebElement webElement, SearchMethod searchMethod, string attribute)
 {
     return(searchMethod switch
     {
         SearchMethod.Tag => webElement.FindElement(By.TagName(attribute)),
         SearchMethod.ClassName => webElement.FindElement(By.ClassName(attribute)),
         SearchMethod.Id => webElement.FindElement(By.Id(attribute)),
         SearchMethod.XPath => webElement.FindElement(By.XPath(attribute)),
         SearchMethod.Selector => webElement.FindElement(By.CssSelector(attribute)),
         _ => null,
     });
Exemplo n.º 28
0
        private void OnTagSearchRequested(TagBase source, string searchText)
        {
            Console.WriteLine("Search requested from " + this.tagPanel.Children.IndexOf(source));

            SearchSource = source;
            if (SearchMethod == null)
            {
                throw new InvalidOperationException("The tagbox is missing and Action<string> delegate for the SearchMethod");
            }

            SearchMethod.Invoke(searchText.Trim());
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            School school = new School();
            SearchMethod <People> search = new SearchMethod <People>();

            SearchModel <string, People> search1 = new SearchModel <string, People>()
            {
                Class = "Teacher"
            };
            SearchModel <string, People> search2 = new SearchModel <string, People>()
            {
                Class = "Teacher", Property = "Name", Value = "Barna"
            };
            SearchModel <string, People> search3 = new SearchModel <string, People>()
            {
                Property = "Status", Value = "student"
            };
            SearchModel <int, People> search4 = new SearchModel <int, People>()
            {
                Property = "Age", Value = 12
            };
            SearchModel <bool, People> search5 = new SearchModel <bool, People> {
                Property = "Clever", Value = true
            };

            string qsearch1 = "?Status=teacher";
            string qsearch2 = "?Status=student&&Name=Barna";
            string qsearch3 = "?Age=12";
            string qsearch4 = "?Age=12&&Status=student&&Clever=false";

            //Console.WriteLine("Original list:");
            //Printer(school.SchoolMembers);
            //Console.WriteLine("Filtered for class:");
            //Printer(search1.Filter(school.SchoolMembers));
            //Console.WriteLine("Filtered for class & property:");
            //Printer(search2.Filter(school.SchoolMembers));
            //Console.WriteLine("Filtered for just property:");
            //Printer(search3.Filter(school.SchoolMembers));
            //Console.WriteLine("Filtered for age property");
            //Printer(search4.Filter(school.SchoolMembers));
            //Console.WriteLine("Filtered for clever property");
            //Printer(search5.Filter(school.SchoolMembers));
            Console.WriteLine("query1");
            Printer(search.SearchFromQuery(qsearch1, school.SchoolMembers));
            Console.WriteLine("query2");
            Printer(search.SearchFromQuery(qsearch2, school.SchoolMembers));
            Console.WriteLine("query3");
            Printer(search.SearchFromQuery(qsearch3, school.SchoolMembers));
            Console.WriteLine("query4");
            Printer(search.SearchFromQuery(qsearch4, school.SchoolMembers));

            Console.ReadKey();
        }
Exemplo n.º 30
0
 /// <summary>
 /// suggestion
 /// </summary>
 /// <param name="query"></param>
 /// <returns>only song names</returns>
 public async override Task <SongSuggestionContent> GetSongSuggestionAsync(string query)
 {
     return(await this.GetResponse(new SongSuggestionContent(), SearchMethod.Suggestion(query), (o) =>
     {
         if (o.HasError)
         {
             return;
         }
         suggestion suggestion = (suggestion)JsonConvert.DeserializeObject(o.Value, typeof(suggestion));
         o.Query = suggestion.query;
         o.Items = suggestion.suggestion_list;
     }));
 }
Exemplo n.º 31
0
        public void SolveServer()
        {
            solver = new DFS();
            List <int> cards = communicator.GetCardsFromServer().ToList();
            string     c1    = cards[0] + "";
            string     c2    = cards[1] + "";
            string     c3    = cards[2] + "";
            string     c4    = cards[3] + "";

            solver.acceptInput(new Cards(c1, c2, c3, c4));
            solver.search();
            PrintOutput(solver.receiveOutput());
        }
        /// <summary>
        /// Public constructor for DistributedSearcher. A DistributedSearcher is defined
        /// in XML configuration and is loaded via a custom configuration handler.
        /// </summary>
        /// <param name="xSection">The Xml definition in the configuration file</param>
		public DistributedSearcher(XmlNode xSection)
		{
            
            XmlAttributeCollection attributeCollection = xSection.Attributes;
            if (attributeCollection == null)
                throw new ConfigurationErrorsException("xSection.Attributes invalid: " + Environment.NewLine + xSection.OuterXml);

            try
            {
                this._id = Convert.ToInt32(attributeCollection["id"].Value);
            }
            catch (Exception e)
            {
                throw new ConfigurationErrorsException("DistributedSearcher.id invalid: " + Environment.NewLine + xSection.OuterXml + Environment.NewLine + e.Message);
            }

            try
            {
                this._eSearchMethod = (SearchMethod)Enum.Parse(typeof(SearchMethod), attributeCollection["SearchMethod"].Value);
            }
            catch (Exception)
            {
                throw new ConfigurationErrorsException("DistributedSearcher.SearchMethod invalid: " + Environment.NewLine + xSection.OuterXml);
            }

            try
            {
                this._strLocation = attributeCollection["Location"].Value;
            }
            catch (Exception)
            {
                throw new ConfigurationErrorsException("DistributedSearcher.Location invalid: " + Environment.NewLine + xSection.OuterXml);
            }

            if (this.SearchMethod == SearchMethod.Local)
            {
                //check for file-system existence
                if (!Lucene.Net.Index.IndexReader.IndexExists(this.Location))
                    throw new ConfigurationErrorsException("DistributedSearcher.Location not an index: " + Environment.NewLine + this.Location);
            }
            else if (this.SearchMethod == SearchMethod.Distributed)
            {
                //exec ping check if needed
            }

		}
Exemplo n.º 33
0
    public TreeNode<StateConfig> findClosest(StateConfig config, SearchMethod search)
    {
        TreeNode<StateConfig> closestNode = nodeList[0];
        float closestDistance = closestNode.content.computeDistanceEuclidean(config);
        float thisDistance = -1;
        TreeNode<StateConfig> currentNode = null;
        for (int i = 0; i < nodeList.Count; i++) {
            currentNode = nodeList[i];
            if ((thisDistance = currentNode.content.computeDistanceEuclidean(config)) < closestDistance){
                closestNode = currentNode;
                closestDistance = thisDistance;
            }
        }

        //		if (search == SearchMethod.BFS){
        //			closestNode = findClosestBFS(config);
        //		} else {
        //			closestNode = findClosestDFS(config);
        //		}

        return closestNode;
    }
Exemplo n.º 34
0
 /// <summary>
 /// Cleanly combines two IEnumerables (possibly null) 
 /// </summary>
 /// <param name="co1">The existing ContentObjects result</param>
 /// <param name="co2">The new ContentObjects you would like to add to the result</param>
 /// <param name="method">The method by which to join the results (union or intersect)</param>
 /// <returns>An IEnumerable containing the combined inputs</returns>
 private IEnumerable<ContentObject> combineResults(IEnumerable<ContentObject> existing, IEnumerable<ContentObject> toAdd, SearchMethod method)
 {
     if (toAdd.Count() > 0)
     {
         if (existing == null)
             existing = toAdd;
         else
         {
             existing = (method == SearchMethod.OR)
                 ? existing.Union(toAdd, _compare)
                 : existing.Intersect(toAdd, _compare);
         }
     }
     return existing;
 }
Exemplo n.º 35
0
 private void SetSearchButtonsEnabled(SearchMethod method)
 {
     this.searchData1Button.Enabled = SearchMethod.Method_1 == method;
     this.searchData2Button.Enabled = SearchMethod.Method_2 == method;
     this.searchData3Button.Enabled = SearchMethod.Method_3 == method;
 }
Exemplo n.º 36
0
        public SearchResult[] Search(Color input, ColorSpace colorSpace, SearchMethod method)
        {
            Bitmap bmp = new Bitmap(265, 265, PixelFormat.Format32bppArgb);
            Graphics gBmp = Graphics.FromImage(bmp);
            gBmp.FillRectangle(new SolidBrush(input), 0, 0, 256, 256);

            if (colorSpace == ColorSpace.Rgb)
            {
                return SearchRgb(bmp.GetRgbHistogram(), method);
            }

            return SearchHsv(bmp.GetHsvHistogram(), method);
        }
Exemplo n.º 37
0
        private SearchResult[] Search(
            int[][] input, 
            Func<int[][], int[][], Func<int[], int[], int, double>, double> diff, 
            Func<Histogram, int[][]> getHistogram, 
            SearchMethod method)
        {
            Func<int[], int[], int, double> compareMethod = Histogram.ChiSquare;

            switch (method)
            {
                case SearchMethod.ChiSquare:
                    compareMethod = Histogram.ChiSquare;
                    break;

                case SearchMethod.ChiSquare2:
                    compareMethod = Histogram.ChiSquare2;
                    break;

                case SearchMethod.Correlation:
                    compareMethod = Histogram.Correlation;
                    break;
                case SearchMethod.Intersection:
                    compareMethod = Histogram.Intersection;
                    break;
            }

            var result = _db.Images
                .AsParallel()
                .Select(x => new SearchResult(diff(input, getHistogram(x.Histogram), compareMethod), x))
                ;

            if (method == SearchMethod.Correlation || method == SearchMethod.Intersection)
                return result.OrderByDescending(x => x.Distance).ToArray();

            return result.OrderBy(x => x.Distance).ToArray();
        }
Exemplo n.º 38
0
 /// <summary>
 /// Cycle through the search method to the next type
 /// </summary>
 public void NextSearchType()
 {
     searchMethod = (SearchMethod)(((int)searchMethod + 1) %
         (int)SearchMethod.Max);
 }
Exemplo n.º 39
0
 private SearchResult[] SearchHsv(int[][] input, SearchMethod method)
 {
     return Search(input, Histogram.HsvChiSquareDistance, x => x.HsvHistogram, method);
 }
Exemplo n.º 40
0
 private SearchResult[] SearchRgb(int[][] input, SearchMethod method)
 {
     return Search(input, Histogram.RgbDistance, x => x.RgbHistogram, method);
 }
Exemplo n.º 41
0
        private void AppendSearchMethod(ToolStripDropDownItem menuItem, SearchMethod value, string text)
        {
            var isChecked = Settings.Default.SearchMethods.HasFlag(value);
            var item = new ToolStripMenuItem
            {
                CheckState = isChecked ? CheckState.Checked : CheckState.Unchecked,
                Text = text,
                Tag = value,
                CheckOnClick = true
            };

            menuItem.DropDownItems.Add(item);
            item.CheckedChanged += SearchMethodCheckChanged;
        }
Exemplo n.º 42
0
        public IEnumerable<ContentObject> SearchByFields(NameValueCollection fields, SearchMethod method = SearchMethod.OR)
        {
            if (fields.Count < 1)
                return null;

            IEnumerable<ContentObject> results = null;
            for (int i = 0; i < fields.Count; i++)
                results = combineResults(results, SearchByField(fields.Keys[i], fields[fields.Keys[i]]), method);

            return results;
        }
Exemplo n.º 43
0
        public IEnumerable<ContentObject> QuickSearch(IEnumerable<string> terms, SearchMethod method = SearchMethod.OR)
        {
            if (terms.Count() < 1)
                return null;

            IEnumerable<ContentObject> results = null;
            foreach (string term in terms)
                results = combineResults(results, QuickSearch(term), method);

            return results;
        }