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


C# Query.ConstructQuery方法代码示例

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


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

示例1: ConstructingQueryWithSpecifiedQueryAndAdditionalQueryPhraseShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndAdditionalQueryPhraseShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.AdditionalQueryPhrase = "phrase";

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&as_epq=phrase", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:10,代码来源:SearchTests.cs

示例2: ConstructingQueryWithSpecifiedQueryAndAddedSearchTermShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndAddedSearchTermShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.AddedSearchTerm = "added";

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&as_q=added", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:10,代码来源:SearchTests.cs

示例3: MetaDataFieldsShouldBeCorrectlyEncoded

        public void MetaDataFieldsShouldBeCorrectlyEncoded()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "Meta";
            q.RequiredFields = new List<MetaDataField>();

            StringAssert.Contains("?q=Meta", q.ConstructQuery());
            StringAssert.DoesNotContain("&requiredfields=", q.ConstructQuery());

            q.RequiredFields.Add(new MetaDataField { Key = "department", Value = "Human Resources", MetaDataSearchSpecification = MetaDataSearchSpecification.And });
            q.RequiredFields.Add(new MetaDataField { Key = "metakey2", Value = "metavalue2" });
            StringAssert.Contains("&requiredfields=department:Human%2520Resources.metakey2:metavalue2", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:14,代码来源:MetaDataFieldsTests.cs

示例4: PartialMetaDataSearchWithOrShouldYieldCorrectUrl

        public void PartialMetaDataSearchWithOrShouldYieldCorrectUrl()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "Meta";
            q.PartialFields = new List<MetaDataField>();

            StringAssert.Contains("?q=Meta", q.ConstructQuery());
            StringAssert.DoesNotContain("&partialfields=", q.ConstructQuery());

            q.PartialFields.Add(new MetaDataField { Key = "metakey", Value = "metavalue", MetaDataSearchSpecification = MetaDataSearchSpecification.Or });
            q.PartialFields.Add(new MetaDataField { Key = "metakey2", Value = "metavalue2" });
            StringAssert.Contains("&partialfields=metakey:metavalue|metakey2:metavalue2", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:14,代码来源:MetaDataFieldsTests.cs

示例5: ConstructingQueryWithoutSpecifyingAnyParametersShouldYieldCorrectQuery

        public void ConstructingQueryWithoutSpecifyingAnyParametersShouldYieldCorrectQuery()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;

            StringAssert.AreEqualIgnoringCase("http://google04.domain.se/search/?q=&ie=utf8&oe=utf8&output=xml_no_dtd", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:7,代码来源:SearchTests.cs

示例6: ConstructingQueryWithSpecifiedQueryAndAccessShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndAccessShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.Access = SearchAccess.Public;

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&access=p", q.ConstructQuery());

            q.Access = SearchAccess.Secure;
            StringAssert.Contains("&access=s", q.ConstructQuery());

            q.Access = SearchAccess.All;
            StringAssert.Contains("&access=a", q.ConstructQuery());

            q.Access = SearchAccess.Ignore;
            StringAssert.DoesNotContain("&access=", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:19,代码来源:SearchTests.cs

示例7: ConstructingQueryWithSpecifiedQueryAndSiteSearchModificationShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndSiteSearchModificationShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.SiteSearchModification = SiteSearchModification.Include;

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&ad_dt=i", q.ConstructQuery());

            q.SiteSearchModification = SiteSearchModification.Exclude;
            StringAssert.Contains("&ad_dt=e", q.ConstructQuery());

            q.SiteSearchModification = SiteSearchModification.Ignore;
            StringAssert.DoesNotContain("&ad_dt=", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:16,代码来源:SearchTests.cs

示例8: ConstructingQueryWithSpecifiedQueryAndSearchLocationShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndSearchLocationShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.SearchLocation = SearchLocation.Anywhere;

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&as_occt=any", q.ConstructQuery());

            q.SearchLocation = SearchLocation.Title;
            StringAssert.Contains("&as_occt=title", q.ConstructQuery());

            q.SearchLocation = SearchLocation.Url;
            StringAssert.Contains("&as_occt=url", q.ConstructQuery());

            q.SearchLocation = SearchLocation.Ignore;
            StringAssert.DoesNotContain("&as_occt=", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:19,代码来源:SearchTests.cs

示例9: ConstructingQueryWithSpecifiedQueryAndRestrictToLanguageShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndRestrictToLanguageShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.RestrictToLanguage = "lang";

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&lr=lang", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:10,代码来源:SearchTests.cs

示例10: ConstructingQueryWithSpecifiedQueryAndRelevanceScoringShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndRelevanceScoringShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.RelevanceScoring = RelevanceScoring.Advanced;

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&entsp=a", q.ConstructQuery());

            q.RelevanceScoring = RelevanceScoring.Standard;
            StringAssert.Contains("&entsp=0", q.ConstructQuery());

            q.RelevanceScoring = RelevanceScoring.Ignore;
            StringAssert.DoesNotContain("&entsp=", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:16,代码来源:SearchTests.cs

示例11: ConstructingQueryWithSpecifiedQueryAndAsSiteToSearchShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndAsSiteToSearchShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.AsSiteToSearch = "site";

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&as_sitesearch=site", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:10,代码来源:SearchTests.cs

示例12: ConstructingQueryWithSpecifiedQueryAndGetMetaFieldsShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndGetMetaFieldsShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.GetMetaFields = "meta";

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&getfields=meta", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:10,代码来源:SearchTests.cs

示例13: ConstructingQueryWithSpecifiedQueryAndFilterShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndFilterShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.Filter = QueryFilter.DirectoryOnly;

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&filter=s", q.ConstructQuery());

            q.Filter = QueryFilter.SnippetAndDirectory;
            StringAssert.Contains("&filter=1", q.ConstructQuery());

            q.Filter = QueryFilter.None;
            StringAssert.Contains("&filter=0", q.ConstructQuery());

            q.Filter = QueryFilter.SnippetOnly;
            StringAssert.Contains("&filter=p", q.ConstructQuery());

            q.Filter = QueryFilter.Ignore;
            StringAssert.DoesNotContain("&filter=", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:22,代码来源:SearchTests.cs

示例14: ConstructingQueryWithSpecifiedQueryAndCollectionsShouldYieldCorrectParameter

        public void ConstructingQueryWithSpecifiedQueryAndCollectionsShouldYieldCorrectParameter()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "apa";
            q.Collections = "samplecollection";

            StringAssert.Contains("?q=apa", q.ConstructQuery());
            StringAssert.Contains("&site=samplecollection", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:10,代码来源:SearchTests.cs

示例15: RequiredMetaDataSearchWithOrAndNotShouldYieldCorrectUrl

        public void RequiredMetaDataSearchWithOrAndNotShouldYieldCorrectUrl()
        {
            var q = new Query();
            q.GsaHostAddress = GsaHost;
            q.SearchTerm = "Meta";
            q.RequiredFields = new List<MetaDataField>();

            StringAssert.Contains("?q=Meta", q.ConstructQuery());
            StringAssert.DoesNotContain("&requiredfields=", q.ConstructQuery());

            q.RequiredFields.Add(new MetaDataField { Key = "metakey", Value = "metavalue", MetaDataSearchSpecification = MetaDataSearchSpecification.Or });
            q.RequiredFields.Add(new MetaDataField { Key = "metakey2", Value = "metavalue2", Negate = true});
            StringAssert.Contains("&requiredfields=metakey:metavalue|-metakey2:metavalue2", q.ConstructQuery());
        }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:14,代码来源:MetaDataFieldsTests.cs


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