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


C# Query.ToString方法代码示例

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


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

示例1: Query

 public List<Result> Query(Query query)
 {
     List<Result> results = new List<Result>();
     string tweetMessage = query.ToString().Remove(0, 2);
     results.Add(new Result()
     {
         
         Title = "Tweet: " + tweetMessage,
         IcoPath = "Image\\twitter.png",
         Action = context =>
         {
             postTweet(tweetMessage);
             return true;
         }
     });
     return results;
 }
开发者ID:takeru0911,项目名称:Wox.Plugin.Twitter,代码行数:17,代码来源:TwitterPlugin.cs

示例2: ComputeCacheKey

        /// <summary>
        /// 拼装CacheKey
        /// </summary>
        /// <param name="customPrefix"></param>
        /// <param name="query"></param>
        /// <returns></returns>
        public static string ComputeCacheKey(string customPrefix, Query query)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(customPrefix);
            if (query != null)
            {
                sb.Append(FilterParams(query.ToString()));

                if (query.Params != null)
                {
                    foreach (QueryParam obj in query.Params)
                    {
                        sb.Append(obj.ToString());
                    }
                }
            }
            return sb.ToString();
        }
开发者ID:dalinhuang,项目名称:myxx,代码行数:24,代码来源:CacheHelper.cs

示例3: btnSave_Click

 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
     Category category;
     int parentId = 0;
     int categoryId = 0;
     int.TryParse(lblCategoryId.Text, out categoryId);
     if(categoryId > 0) {
       category = new Category(categoryId);
     }
     else {
       category = new Category();
       category.CategoryGuid = Guid.NewGuid();
     }
     category.Name = txtName.Text.Trim();
     int.TryParse(ddlParentCategory.SelectedValue, out parentId);
     //if((category.CategoryId == 0 || category.ParentId != parentId) && parentId != category.CategoryId) {//add it to the end of the new parent category
       object sortOrder = new Query(Category.Schema).WHERE(Category.Columns.ParentId, Comparison.Equals, parentId).GetMax(Category.Columns.SortOrder);
       category.SortOrder = string.IsNullOrEmpty(sortOrder.ToString()) ? 1 : (int)sortOrder + 1;
     //}
     category.ParentId = parentId;
     category.ImageFile = txtImageFile.Text.Trim();
     category.Description = txtDescription.Text.Trim();
     category.Save(WebUtility.GetUserName());
     RefreshCache(categoryId);
     Reset();
     GetCategoryDataSet();
     LoadTreeView(ds);
     LoadChildren(category.ParentId);
     LoadParentCategoryDropDown(ds);
     Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblProductCategorySaved"));
       }
       catch(Exception ex) {
     Logger.Error(typeof(categoryedit).Name + ".btnSave_Click", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
开发者ID:dashcommerce,项目名称:dashcommerce-3,代码行数:42,代码来源:categoryedit.aspx.cs

示例4: btnSave_Click

 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
     Content.Page page;
     int parentId = 0;
     int pageId = 0;
     int.TryParse(lblPageId.Text, out pageId);
     if(pageId > 0) {
       page = new Content.Page(pageId);
     }
     else {
       page = new Content.Page();
       page.PageGuid = Guid.NewGuid();
     }
     int.TryParse(ddlParentPage.SelectedValue, out parentId);
     //if(parentId != page.PageId) {//add it to the end of the new parent category
       object sortOrder = new Query(Content.Page.Schema).WHERE(Content.Page.Columns.ParentId, Comparison.Equals, parentId).GetMax(Content.Page.Columns.SortOrder);
       page.SortOrder = string.IsNullOrEmpty(sortOrder.ToString()) ? 1 : (int)sortOrder + 1;
     //}
     page.ParentId = parentId;
     page.Title = txtTitle.Text;
     page.MenuTitle = txtMenuTitle.Text;
     page.Keywords = txtKeywords.Text;
     page.Description = txtDescription.Text;
     int templateId = 1; //default to 3 column
     int.TryParse(ddlPageTemplate.SelectedValue, out templateId);
     page.TemplateId = templateId;
     //page.Content = HttpUtility.HtmlEncode(txtContent.Value);
     page.Save(WebUtility.GetUserName());
     //Remove from cache will make it reload on the next request.
     PageCache.RemovePageByID(pageId);
     PageMenuCache.RefreshMenuPageCollection();
     Reset();
     GetPageDataSet();
     LoadTreeView(ds);
     LoadChildren(page.ParentId);
     LoadParentPageDropDown(ds);
     Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblPageSaved"));
       }
       catch(Exception ex) {
     Logger.Error(typeof(contentedit).Name + ".btnSave_Click", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
开发者ID:qinzhijun,项目名称:MyDash,代码行数:49,代码来源:contentedit.aspx.cs

示例5: WhereParameter

 /// <summary>
 /// 查询条件(带复杂关系)
 /// </summary>
 /// <param name="parameterName">参数名(如果是多表请注明字段所属的表名称)</param>
 /// <param name="query">运算符号</param>
 /// <param name="value">值</param>
 /// <param name="orquery">与后一条件的关系</param>
 /// <param name="kuohao">关系括号</param>
 public WhereParameter(string ParameterName, Query AndQuery, object Value, OrAnd OrAndQuery, Kuohao kuohao)
 {
     this.ParameterName = ParameterName;
     this.Value = Value;
     this.AndQuery = (string)AndQuery.ToString();
     this.OrAndQuery = (string)OrAndQuery.ToString();
     this.kuohao = (string)kuohao.ToString();
 }
开发者ID:wangyi3330,项目名称:wpfTest,代码行数:16,代码来源:WhereParameter.cs

示例6: TestConstantScoreMultiTermQuery

        public void TestConstantScoreMultiTermQuery()
        {

            numHighlights = 0;

            query = new WildcardQuery(new Term(FIELD_NAME, "ken*"));
            ((WildcardQuery) query).RewriteMethod = MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE;
            searcher = new IndexSearcher(ramDir, true);
            // can't rewrite ConstantScore if you want to highlight it -
            // it rewrites to ConstantScoreQuery which cannot be highlighted
            // query = unReWrittenQuery.Rewrite(reader);
            Console.WriteLine("Searching for: " + query.ToString(FIELD_NAME));
            hits = searcher.Search(query, null, 1000);

            for (int i = 0; i < hits.TotalHits; i++)
            {
                String text = searcher.Doc(hits.ScoreDocs[i].Doc).Get(HighlighterTest.FIELD_NAME);
                int maxNumFragmentsRequired = 2;
                String fragmentSeparator = "...";
                QueryScorer scorer = null;
                TokenStream tokenStream = null;

                tokenStream = analyzer.TokenStream(FIELD_NAME, new StringReader(text));

                scorer = new QueryScorer(query, FIELD_NAME);

                Highlighter highlighter = new Highlighter(this, scorer);

                highlighter.TextFragmenter = new SimpleFragmenter(20);

                String result = highlighter.GetBestFragments(tokenStream, text, maxNumFragmentsRequired,
                                                             fragmentSeparator);
                Console.WriteLine("\t" + result);
            }
            Assert.IsTrue(numHighlights == 5, "Failed to find correct number of highlights " + numHighlights + " found");

            // try null field

            hits = searcher.Search(query, null, 1000);

            numHighlights = 0;

            for (int i = 0; i < hits.TotalHits; i++)
            {
                String text = searcher.Doc(hits.ScoreDocs[i].Doc).Get(HighlighterTest.FIELD_NAME);
                int maxNumFragmentsRequired = 2;
                String fragmentSeparator = "...";
                QueryScorer scorer = null;
                TokenStream tokenStream = null;

                tokenStream = analyzer.TokenStream(HighlighterTest.FIELD_NAME, new StringReader(text));

                scorer = new QueryScorer(query, null);

                Highlighter highlighter = new Highlighter(this, scorer);

                highlighter.TextFragmenter = new SimpleFragmenter(20);

                String result = highlighter.GetBestFragments(tokenStream, text, maxNumFragmentsRequired,
                                                             fragmentSeparator);
                Console.WriteLine("\t" + result);
            }
            Assert.IsTrue(numHighlights == 5, "Failed to find correct number of highlights " + numHighlights + " found");

            // try default field

            hits = searcher.Search(query, null, 1000);

            numHighlights = 0;

            for (int i = 0; i < hits.TotalHits; i++)
            {
                String text = searcher.Doc(hits.ScoreDocs[i].Doc).Get(HighlighterTest.FIELD_NAME);
                int maxNumFragmentsRequired = 2;
                String fragmentSeparator = "...";
                QueryScorer scorer = null;
                TokenStream tokenStream = null;

                tokenStream = analyzer.TokenStream(HighlighterTest.FIELD_NAME, new StringReader(text));

                scorer = new QueryScorer(query, "random_field", HighlighterTest.FIELD_NAME);

                Highlighter highlighter = new Highlighter(this, scorer);

                highlighter.TextFragmenter = new SimpleFragmenter(20);

                String result = highlighter.GetBestFragments(tokenStream, text, maxNumFragmentsRequired,
                                                             fragmentSeparator);
                Console.WriteLine("\t" + result);
            }
            Assert.IsTrue(numHighlights == 5, "Failed to find correct number of highlights " + numHighlights + " found");
        }
开发者ID:hanabi1224,项目名称:lucene.net,代码行数:92,代码来源:HighlighterTest.cs

示例7: DoSearching

 public void DoSearching(Query unReWrittenQuery)
 {
     searcher = new IndexSearcher(ramDir, true);
     // for any multi-term queries to work (prefix, wildcard, range,fuzzy etc)
     // you must use a rewritten query!
     query = unReWrittenQuery.Rewrite(reader);
     Console.WriteLine("Searching for: " + query.ToString(FIELD_NAME));
     hits = searcher.Search(query, null, 1000);
 }
开发者ID:hanabi1224,项目名称:lucene.net,代码行数:9,代码来源:HighlighterTest.cs

示例8: TestMultiSearcher

        public void TestMultiSearcher()
        {
            // setup index 1
            RAMDirectory ramDir1 = new RAMDirectory();
            IndexWriter writer1 = new IndexWriter(ramDir1, new StandardAnalyzer(TEST_VERSION), true,
                                                  IndexWriter.MaxFieldLength.UNLIMITED);
            Document d = new Document();
            Field f = new Field(FIELD_NAME, "multiOne", Field.Store.YES, Field.Index.ANALYZED);
            d.Add(f);
            writer1.AddDocument(d);
            writer1.Optimize();
            writer1.Close();
            IndexReader reader1 = IndexReader.Open(ramDir1, true);

            // setup index 2
            RAMDirectory ramDir2 = new RAMDirectory();
            IndexWriter writer2 = new IndexWriter(ramDir2, new StandardAnalyzer(TEST_VERSION), true,
                                                  IndexWriter.MaxFieldLength.UNLIMITED);
            d = new Document();
            f = new Field(FIELD_NAME, "multiTwo", Field.Store.YES, Field.Index.ANALYZED);
            d.Add(f);
            writer2.AddDocument(d);
            writer2.Optimize();
            writer2.Close();
            IndexReader reader2 = IndexReader.Open(ramDir2, true);

            var searchers = new IndexSearcher[2];
            searchers[0] = new IndexSearcher(ramDir1, true);
            searchers[1] = new IndexSearcher(ramDir2, true);
            MultiSearcher multiSearcher = new MultiSearcher(searchers);
            QueryParser parser = new QueryParser(TEST_VERSION, FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
            parser.MultiTermRewriteMethod = MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE;
            query = parser.Parse("multi*");
            Console.WriteLine("Searching for: " + query.ToString(FIELD_NAME));
            // at this point the multisearcher calls combine(query[])
            hits = multiSearcher.Search(query, null, 1000);

            // query = QueryParser.Parse("multi*", FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
            Query[] expandedQueries = new Query[2];
            expandedQueries[0] = query.Rewrite(reader1);
            expandedQueries[1] = query.Rewrite(reader2);
            query = query.Combine(expandedQueries);

            // create an instance of the highlighter with the tags used to surround
            // highlighted text
            Highlighter highlighter = new Highlighter(this, new QueryTermScorer(query));

            for (int i = 0; i < hits.TotalHits; i++)
            {
                String text = multiSearcher.Doc(hits.ScoreDocs[i].Doc).Get(FIELD_NAME);
                TokenStream tokenStream = analyzer.TokenStream(FIELD_NAME, new StringReader(text));
                String highlightedText = highlighter.GetBestFragment(tokenStream, text);
                Console.WriteLine(highlightedText);
            }
            Assert.IsTrue(numHighlights == 2, "Failed to find correct number of highlights " + numHighlights + " found");

        }
开发者ID:hanabi1224,项目名称:lucene.net,代码行数:57,代码来源:HighlighterTest.cs

示例9: ToString

        public override string ToString()
        {
            Query cookie = new Query();
              cookie.Prefix = "";
              cookie.SubPrefix = ";";

              cookie.Table.Add(name, value);

              if (path != null) {
            cookie.Table.Add("Path", path);
              }

              if (domain != null) {
            cookie.Table.Add("Domain", domain);
              }

              if (expires != DateTime.MaxValue) {
            cookie.Table.Add("Expires", expires.ToString());
              }

              if (isSecure) {
            cookie.Table.Add("Secure", "");
              }

              if (isHttpOnly) {
            cookie.Table.Add("HttpOnly", "");
              }

              return cookie.ToString();
        }
开发者ID:notrubp,项目名称:Platformer,代码行数:30,代码来源:Cookie.cs

示例10: GetCamlQueryRoot

        /// <summary>
        /// Used to get the query of a view.
        /// </summary>
        /// <param name="query">Specify the type of Query.</param>
        /// <param name="isLookupId">Explicitly specify whether the field referenced in the logical test query condition is a look up field.</param>
        /// <returns>A constructed query root element.</returns>
        protected CamlQueryRoot GetCamlQueryRoot(Query query, bool isLookupId)
        {
            CamlQueryRoot camlQueryRoot = null;
            switch (query)
            {
                case Query.AvailableQueryInfo:
                    camlQueryRoot = this.GetCamlQueryRootForWhere(isLookupId);
                    break;

                case Query.EmptyQueryInfo:
                    camlQueryRoot = new CamlQueryRoot();
                    break;

                case Query.IsCollapse:
                    camlQueryRoot = this.GetCamlQueryRootForGroupBy(true);
                    break;

                case Query.IsNotCollapse:
                    camlQueryRoot = this.GetCamlQueryRootForGroupBy(false);
                    break;

                default:
                    Site.Debug.Fail("Not supported Query type {0}", query.ToString());
                    break;
            }

            return camlQueryRoot;
        }
开发者ID:OfficeDev,项目名称:Interop-TestSuites,代码行数:34,代码来源:TestSuiteBase.cs

示例11: Load

        public void Load(Query q)
        {
            string url = "http://www.google.com/finance?&gl=us&hl=en&output=json&start=0&num=10000&noIL=1&restype=company&q=" + q.ToString();
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            jss.MaxJsonLength = 80000000;
            string json = FetchFile(url);

            RawGoogle g = jss.Deserialize<RawGoogle>(json.Replace("\n", "").Replace("\\", ""));
            foreach (System.Reflection.PropertyInfo p in g.GetType().GetProperties())
            {
                this.GetType().GetProperty(p.Name).SetValue(this, p.GetValue(g, null), null);
            }
        }
开发者ID:eulalie367,项目名称:littleapps,代码行数:13,代码来源:Google.cs


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