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


C# NameValueCollection.GetValues方法代码示例

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


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

示例1: GetParametersFromPath

        public static MoreLikeThisQuery GetParametersFromPath(string path, NameValueCollection query)
        {
            var results = new MoreLikeThisQuery
            {
                IndexName = query.Get("index"),
                Fields = query.GetValues("fields"),
                Boost = query.Get("boost").ToNullableBool(),
                BoostFactor = query.Get("boostFactor").ToNullableFloat(),
                MaximumNumberOfTokensParsed = query.Get("maxNumTokens").ToNullableInt(),
                MaximumQueryTerms = query.Get("maxQueryTerms").ToNullableInt(),
                MaximumWordLength = query.Get("maxWordLen").ToNullableInt(),
                MinimumDocumentFrequency = query.Get("minDocFreq").ToNullableInt(),
                MaximumDocumentFrequency = query.Get("maxDocFreq").ToNullableInt(),
                MaximumDocumentFrequencyPercentage = query.Get("maxDocFreqPct").ToNullableInt(),
                MinimumTermFrequency = query.Get("minTermFreq").ToNullableInt(),
                MinimumWordLength = query.Get("minWordLen").ToNullableInt(),
                StopWordsDocumentId = query.Get("stopWords"),
                AdditionalQuery= query.Get("query")
            };

            var keyValues = query.Get("docid").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var keyValue in keyValues)
            {
                var split = keyValue.IndexOf('=');

                if (split >= 0)
                    results.MapGroupFields.Add(keyValue.Substring(0, split), keyValue.Substring(split + 1));
                else
                    results.DocumentId = keyValue;
            }

            return results;
        }
开发者ID:IdanHaim,项目名称:ravendb,代码行数:33,代码来源:MoreLikeThisController.cs

示例2: Main

        static void Main(string[] args)
        {
            SortedList sl = new SortedList();
            sl.Add("Stack", "Represents a LIFO collection of objects.");
            sl.Add("Queue", "Represents a FIFO collection of objects.");
            sl.Add("SortedList", "Represents a collection of key/value pairs.");

            foreach (DictionaryEntry de in sl)
            {
                Console.WriteLine("{0,12}: {1}", de.Key, de.Value);
            }

            Console.WriteLine("\n" + sl["Queue"]);
            Console.WriteLine(sl.GetByIndex(1));

            Console.WriteLine("\nName Value Collection:");
            NameValueCollection nvc = new NameValueCollection();
            nvc.Add("Stack", "Represents a LIFO collection of objects.");
            nvc.Add("Stack", "A pile of pancakes.");
            nvc.Add("Queue", "Represents a FIFO collection of objects.");
            nvc.Add("Queue", "In England, a line.");
            nvc.Add("SortedList", "Represents a collection of key/value pairs.");

            foreach (string s in nvc.GetValues(0))
                Console.WriteLine(s);

            foreach (string s in nvc.GetValues("Queue"))
                Console.WriteLine(s);
        }
开发者ID:oblivious,项目名称:Oblivious,代码行数:29,代码来源:Program.cs

示例3: GetValues

		public void GetValues ()
		{
			NameValueCollection col = new NameValueCollection ();
			col.Add ("foo1", "bar1");
			Assertion.AssertEquals ("#1", null, col.GetValues (null));
			Assertion.AssertEquals ("#2", null, col.GetValues (""));
			Assertion.AssertEquals ("#3", null, col.GetValues ("NotExistent"));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:NameValueCollectionTest.cs

示例4: GetValues

		public void GetValues ()
		{
			NameValueCollection col = new NameValueCollection ();
			col.Add ("foo1", "bar1");
			Assert.AreEqual (null, col.GetValues (null), "#1");
			Assert.AreEqual (null, col.GetValues (""), "#2");
			Assert.AreEqual (null, col.GetValues ("NotExistent"), "#3");
			Assert.AreEqual (1, col.GetValues (0).Length, "#4");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:NameValueCollectionTest.cs

示例5: TestNameValueCollectionValuesAreNotUnique

        public void TestNameValueCollectionValuesAreNotUnique()
        {
            NameValueCollection nvc = new NameValueCollection();
            nvc.Add("a", "value a1");
            nvc.Add("a", "value a1"); //the same values again

            Assert.AreEqual(1, nvc.AllKeys.Count());
            Assert.AreEqual(2, nvc.GetValues("a").Count(), "If there was only 1 value, NameValueCollection would enforce uniqueness. Apparently it does not.");
            Assert.AreEqual(1, nvc.GetValues("a").Distinct().Count(), "If we apply a Distinct afterwards, I would expect to have only one value left.");
        }
开发者ID:TonyAbell,项目名称:spark,代码行数:10,代码来源:TestDotNetFeatures.cs

示例6: DumpNvc

 void DumpNvc(NameValueCollection nvc)
 {
     foreach (string key in nvc.Keys)
     {
         string[] values = nvc.GetValues(key);
         foreach (string value in nvc.GetValues(key))
         {
             AddDebug(string.Format("'{0}' : '{1}'", key, value));
         }
     }
 }
开发者ID:paynl,项目名称:csharp-sdk,代码行数:11,代码来源:Form1.cs

示例7: PostMethod

 public void PostMethod(string url, NameValueCollection prms)
 {
     string req = "";
     for (int i = 0; i < prms.Count; i++)
     {
         if (i == 0)
             req += prms.GetKey(i) + "=" + Utility.URLEncode(prms.GetValues(i).GetValue(0).ToString());
         else
             req += "&" + prms.GetKey(i) + "=" + Utility.URLEncode(prms.GetValues(i).GetValue(0).ToString());
     }
     if (authObject != null)
         this.Navigate(url, null, ASCIIEncoding.ASCII.GetBytes(req), (string)authObject);
     else
         this.Navigate(url, null, ASCIIEncoding.ASCII.GetBytes(req), null);
 }
开发者ID:nghoang,项目名称:CrawlerLib.NET,代码行数:15,代码来源:WebBrowserX.cs

示例8: Main

        /// <summary>
        ///     To register the app:
        ///     1) Go to appregnew.aspx to create the client ID and client secret
        ///     2) Copy the client ID and client secret to app.config
        ///     3) Go to appinv.aspx to lookup by client ID and add permission XML below
        ///     /*
        ///      <AppPermissionRequests AllowAppOnlyPolicy="true">
        ///        <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="Write" />
        ///      </AppPermissionRequests>
        ///     */
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            //Read site collections to apply policy to from app.config file
            configSites = (NameValueCollection)ConfigurationManager.GetSection("Sites");
            configContentTypeRetentionPolicyPeriods =
                (NameValueCollection)ConfigurationManager.GetSection("ContentTypeRetentionPolicyPeriod");

            //Iterate through site collections
            foreach (var key in configSites.Keys)
            {
                var siteUrls = configSites.GetValues(key as string);
                if (siteUrls != null)
                {
                    //Build ClientContext with AppOnly Token
                    var sitetUri = new Uri(siteUrls[0]);
                    var siteRealm = TokenHelper.GetRealmFromTargetUrl(sitetUri);
                    var tenantAccessToken = TokenHelper.GetAppOnlyAccessToken
                        (TokenHelper.SharePointPrincipal, sitetUri.Authority, siteRealm).AccessToken;

                    using (var clientContext = TokenHelper.GetClientContextWithAccessToken
                            (sitetUri.ToString(), tenantAccessToken))
                    {
                        //Retrieve root web.
                        var rootWeb = clientContext.Site.RootWeb;
                        clientContext.Load(rootWeb);
                        clientContext.ExecuteQueryWithExponentialRetry(5, 30000);

                        ProcessWebRecursively(clientContext, rootWeb);
                    }
                }
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:47,代码来源:Program.cs

示例9: DumpEnvironmentSettings

    private static void DumpEnvironmentSettings(NameValueCollection environment)
    {
      Debug.Print("Begin Dump environment settings:");
      Debug.Indent();

      foreach (var key in environment.AllKeys)
      {
        var values = environment.GetValues(key);
        if (values.Length == 0)
        {
          continue;
        }
        if (values.Length == 1)
        {
          Debug.Print("{0}: {1}", key, values[0]);
        }
        else
        {
          Debug.Print("{0}:", key);

          Debug.Indent();
          foreach (var value in values)
          {
            Debug.Print(value);
          }
          Debug.Unindent();
          Debug.Print(String.Empty);
        }
      }
      Debug.Unindent();
      Debug.Print("End Dump environment settings");
    }
开发者ID:alexrster,项目名称:QX.NodeParty,代码行数:32,代码来源:NodeHostSettings.cs

示例10: ToQueryString

        public static string ToQueryString(NameValueCollection collection, bool startWithQuestionMark = true)
        {
            if (collection == null || !collection.HasKeys())
                return String.Empty;

            var sb = new StringBuilder();
            if (startWithQuestionMark)
                sb.Append("?");

            var j = 0;
            var keys = collection.Keys;
            foreach (string key in keys)
            {
                var i = 0;
                var values = collection.GetValues(key);
                foreach (var value in values)
                {
                    sb.Append(key)
                        .Append("=")
                        .Append(value);

                    if (++i < values.Length)
                        sb.Append("&");
                }
                if (++j < keys.Count)
                    sb.Append("&");
            }
            return sb.ToString();
        }
开发者ID:rfavillejr,项目名称:Thinktecture.IdentityServer.v2,代码行数:29,代码来源:SFHelper.cs

示例11: GetValueFromAppSettings

 private static string GetValueFromAppSettings(NameValueCollection appSettings, string key, string defaultValue)
 {
     if (appSettings == null) return defaultValue;
     var values = appSettings.GetValues(key);
     if (values == null) return defaultValue;
     return values.FirstOrDefault() ?? defaultValue;
 }
开发者ID:Qobra,项目名称:Solr.Net,代码行数:7,代码来源:DefaultSolrConfiguration.cs

示例12: NameValueCollections

        public static bool NameValueCollections(NameValueCollection left, NameValueCollection right)
        {
            if(left == null)
                return right == null;
            if(right == null)
                return false;
            if(left.Count != right.Count)
                return false;

            foreach(var key in left.AllKeys) {
                IList<string> leftValues = left.GetValues(key);
                IList<string> rightValues = right.GetValues(key);

                if(leftValues == null)
                if(rightValues == null)
                    continue;
                else
                    return false;
                if(rightValues == null)
                    return false;

                if(!leftValues.All(rightValues.Contains) || !rightValues.All(leftValues.Contains))
                    return false;
            }
            return true;
        }
开发者ID:turbonaitis,项目名称:stubby4net,代码行数:26,代码来源:ComparisonUtils.cs

示例13: PopulateTree

		public void PopulateTree(CompositeNode root, NameValueCollection nameValueCollection)
		{
			foreach (String key in nameValueCollection.Keys)
			{
				if (key == null) continue;
				string singleKeyName = NormalizeKey(key);
				String[] values = nameValueCollection.GetValues(key);

				if (values == null) continue;

				if (values.Length == 1 && key.EndsWith("[]"))
				{
					if (values[0] == string.Empty)
					{
						ProcessNode(root, typeof (String[]), singleKeyName, new string[0]);
					}
					else
					{
						values = values[0].Split(',');
						ProcessNode(root, typeof (String[]), singleKeyName, values);
					}
				}
				else if (values.Length == 1)
				{
					ProcessNode(root, typeof (String), key, values[0]);
				}
				else
				{
					ProcessNode(root, typeof (String[]), singleKeyName, values);
				}
			}
		}
开发者ID:gitter-badger,项目名称:Core-8,代码行数:32,代码来源:TreeBuilder.cs

示例14: NvcToDictionary

        private static Dictionary<string, object> NvcToDictionary(NameValueCollection nvc, bool handleMultipleValuesPerKey)
        {
            var result = new Dictionary<string, object>();
            foreach (string key in nvc.Keys)
            {
                if (handleMultipleValuesPerKey)
                {
                    string[] values = nvc.GetValues(key);
                    if (values.Length == 1)
                    {
                        result.Add(key, values[0]);
                    }
                    else
                    {
                        result.Add(key, values);
                    }
                }
                else
                {
                    result.Add(key, nvc[key]);
                }
            }

            return result;
        }
开发者ID:BlockScore,项目名称:blockscore-csharp,代码行数:25,代码来源:Utils.cs

示例15: LocalReportAssemblyResourceLoader

        public LocalReportAssemblyResourceLoader(NameValueCollection queryString, bool isEncrypted)
        {
            var urlParam1 = queryString[UriParameters.ReportAssemblyName];
            AssemblyName = isEncrypted ? SecurityUtil.Decrypt(urlParam1) : urlParam1;

            var urlParam2 = queryString[UriParameters.ReportResourceName];
            MainReportResourceName = isEncrypted ? SecurityUtil.Decrypt(urlParam2) : urlParam2;

            var subReportValues = queryString.GetValues(UriParameters.SubReportResourceNames);

            if (subReportValues == null || !subReportValues.Any()) return;

            var subReportList = new List<SubReportResourceName>();

            foreach(var subReportResourceName in subReportValues)
            {
                var sr = subReportResourceName.Split(':');
                var reportName = sr[0];
                var resourceName = sr[1];

                subReportList.Add(new SubReportResourceName(reportName, resourceName));
            }

            SubReportResourceNames = subReportList;
        }
开发者ID:rungwiroon,项目名称:MvcReportViewer,代码行数:25,代码来源:ReportLoader.cs


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