当前位置: 首页>>代码示例>>C#>>正文


C# SearchParameters.Add方法代码示例

本文整理汇总了C#中SearchParameters.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SearchParameters.Add方法的具体用法?C# SearchParameters.Add怎么用?C# SearchParameters.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SearchParameters的用法示例。


在下文中一共展示了SearchParameters.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoSimpleSearch

        private void DoSimpleSearch(string searchText)
        {
            SearchParameters searchParams = new SearchParameters();
            searchParams.Add(new SearchOptions(SearchType.Theme, searchText) { FindAll = true });
            searchParams.Location = "All Themes";

            Stopwatch time = Stopwatch.StartNew();
            IEnumerable<TmNode> nodes = 
                themesTreeView.RootNodes.SelectMany(n => n.Recurse(node => node.Children)
                                  .Where(x => x.Matches(searchParams))
                                  );
            DisplaySearchResults(searchParams, nodes);
            time.Stop(); Trace.TraceInformation("Time for simple search: {0}ms", time.Elapsed.Milliseconds);
        }
开发者ID:regan-sarwas,项目名称:ThemeManager3.1,代码行数:14,代码来源:MainForm.cs

示例2: BuildSearchParameters

        private SearchParameters BuildSearchParameters()
        {
            var sp = new SearchParameters
                         {
                             MatchAll = (andOrButton1.Text == Resources.SearchForm_AndOrButtons_And),
                             SearchThemes = searchThemesCheckBox.Checked,
                             SearchCategories = searchCategoriesCheckBox.Checked
                         };

            SearchOptions so;
            if (HaveThemeSearch)
            {
                if (themeNameCheckBox.Checked &&
                    themeDescriptionCheckBox.Checked &&
                    themeSummaryCheckBox.Checked &&
                    themeKeywordsCheckBox.Checked)
                {
                    so = new SearchOptions(SearchType.Theme, themeNameTextBox.Text) { FindAll = allThemeNamesRadioButton.Checked };
                    sp.Add(so);
                }
                else
                {
                    if (themeNameCheckBox.Checked)
                    {
                        so = new SearchOptions(SearchType.ThemeName, themeNameTextBox.Text) { FindAll = allThemeNamesRadioButton.Checked };
                        sp.Add(so);
                    }
                    if (themeDescriptionCheckBox.Checked)
                    {
                        so = new SearchOptions(SearchType.ThemeDescription, themeNameTextBox.Text) { FindAll = allThemeNamesRadioButton.Checked };
                        sp.Add(so);
                    }
                    if (themeSummaryCheckBox.Checked)
                    {
                        so = new SearchOptions(SearchType.ThemeSummary, themeNameTextBox.Text) { FindAll = allThemeNamesRadioButton.Checked };
                        sp.Add(so);
                    }
                    if (themeKeywordsCheckBox.Checked)
                    {
                        so = new SearchOptions(SearchType.ThemeTags, themeNameTextBox.Text) { FindAll = allThemeNamesRadioButton.Checked };
                        sp.Add(so);
                    }
                }
            }

            if (HaveMetaSearch)
            {
                if (MetadataAllSectionsCheckBox.Checked)
                    sp.Add(MetaSearch("")); // search the whole document
                else
                {
                    if (metadataAbstactsCheckBox.Checked)
                        sp.Add(MetaSearch("abstract")); // /metadata/idinfo/descript/abstract
                    if (metadataPlaceKeywordsCheckBox.Checked)
                        sp.Add(MetaSearch("placekey"));// /metadata/idinfo/keywords/place/placekey
                    if (metadataThemeKeywordsCheckBox.Checked)
                        sp.Add(MetaSearch("themekey")); // /metadata/idinfo/keywords/theme/themekey
                    
                }
            }
            if (HaveDateSearch)
            {
                so = new SearchOptions(SearchType.PubDate, null);
                if (pubDateAfter.Checked)
                    so.MaxDaysSinceEdit = (DateTime.Now - pubDateAfter.Value).Days;
                if (pubDateBefore.Checked)
                {
                    so.MinDaysSinceEdit = (DateTime.Now - pubDateBefore.Value).Days;
                    if (so.MinDaysSinceEdit < 0)
                        so.MinDaysSinceEdit = 0;
                }
                sp.Add(so);
            }

            if (HaveParkCode)
            {
                // Xpath in FGDC Metadata: /metadata/NPS_Info/NPS_Unit/UnitCode
                so = new SearchOptions(SearchType.Metadata, parkUnitCodeTextBox.Text) {XmlElement = "UnitCode"};
                sp.Add(so);
            }
            return sp;
        }
开发者ID:regan-sarwas,项目名称:ThemeManager3.0,代码行数:82,代码来源:SearchForm.cs


注:本文中的SearchParameters.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。