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


C# NameValueCollection.GetKey方法代码示例

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


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

示例1: CustomSymmetricCryptoProviderNodeTest

        public void CustomSymmetricCryptoProviderNodeTest()
        {
            Type type = typeof(CustomSymmetricCryptoProviderNodeFixture);
            string name = "some name";
            NameValueCollection attributes = new NameValueCollection();
            attributes.Add("Test", "Value");

            CustomSymmetricCryptoProviderNode node = new CustomSymmetricCryptoProviderNode();
            ApplicationNode.AddNode(node);
            Assert.AreEqual("Custom Symmetric Cryptography Provider", node.Name);

            node.Name = name;
            node.Type = type;
            node.Attributes.Add(new EditableKeyValue(attributes.GetKey(0), attributes[attributes.GetKey(0)]));

            Assert.AreEqual(attributes[0], node.Attributes[0].Value);
            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.Type);

            CustomSymmetricCryptoProviderData data = (CustomSymmetricCryptoProviderData)node.SymmetricCryptoProviderData;
            Assert.AreEqual(name, data.Name);
            Assert.AreEqual(type, data.Type);
            Assert.AreEqual(attributes.AllKeys[0], data.Attributes.AllKeys[0]);
            Assert.AreEqual(attributes.Get(0), data.Attributes.Get(0));
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:25,代码来源:CustomSymmetricCryptoProviderNodeFixture.cs

示例2: CustomCacheStorageNodeTest

        public void CustomCacheStorageNodeTest()
        {
            string name = "testName1";
            Type type = typeof(CustomCacheStorageData);
            NameValueCollection attributes = new NameValueCollection();
            attributes.Add("test", "value");

            CustomCacheStorageNode node = new CustomCacheStorageNode();
            ApplicationNode.AddNode(node);
            Assert.AreEqual("Cache Storage", node.Name);

            node.Type = type;
            node.Name = name;
            node.Attributes.Add( new EditableKeyValue(attributes.GetKey(0), attributes[attributes.GetKey(0)]));

            Assert.AreEqual(attributes[0], node.Attributes[0].Value);
            Assert.AreEqual(type, node.Type);
            Assert.AreEqual(name, node.Name);

            CustomCacheStorageData nodeData = (CustomCacheStorageData)node.CacheStorageData;
            Assert.AreEqual(name, nodeData.Name);
            Assert.AreEqual(type, nodeData.Type);
            Assert.AreEqual(attributes.AllKeys[0], nodeData.Attributes.AllKeys[0]);
            Assert.AreEqual(attributes.Get(0), nodeData.Attributes.Get(0));

        }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:26,代码来源:CacheStorageNodeFixture.cs

示例3: CustomHashProviderDataTest

        public void CustomHashProviderDataTest()
        {
            try
            {
                string name = "testName2";
                Type type = typeof(CustomHashProviderNodeFixture);
                NameValueCollection attributes = new NameValueCollection();
                attributes.Add("test", "value");

                CustomHashProviderData data = new CustomHashProviderData();
                data.Name = name;
                data.Type = type;
                data.Attributes.Add(attributes.GetKey(0), attributes[attributes.GetKey(0)]);

                CustomHashProviderNode node = new CustomHashProviderNode(data);
                ApplicationNode.AddNode(node);
                Assert.AreEqual(name, node.Name);
                Assert.AreEqual(type, node.Type);

                Assert.AreEqual(attributes.AllKeys[0], node.Attributes[0].Key);
                Assert.AreEqual(attributes.Get(0), node.Attributes[0].Value);
            }
            finally
            {
                File.Delete("KeyedHashKey.file");
            }
        }
开发者ID:bnantz,项目名称:NCS-V2-0,代码行数:27,代码来源:CustomHashProviderNodeFixture.cs

示例4: ParseArgumentsAndConfigurations

        public static BootstrapperOptions ParseArgumentsAndConfigurations(IEnumerable<string> arguments, NameValueCollection appSettings, IDictionary envVariables)
        {
            var options = new BootstrapperOptions();

            var commandArgs = arguments.ToList();

            if (commandArgs.Contains(CommandArgs.PreferNuget) || appSettings.GetKey(AppSettingKeys.PreferNugetAppSettingsKey).ToLowerSafe() == "true")
            {
                options.PreferNuget = true;
                commandArgs.Remove(CommandArgs.PreferNuget);
            }
            if (commandArgs.Contains(CommandArgs.ForceNuget) || appSettings.GetKey(AppSettingKeys.ForceNugetAppSettingsKey).ToLowerSafe() == "true")
            {
                options.ForceNuget = true;
                commandArgs.Remove(CommandArgs.ForceNuget);
            }
            if (commandArgs.Contains(CommandArgs.Silent))
            {
                options.Silent = true;
                commandArgs.Remove(CommandArgs.Silent);
            }
            if (commandArgs.Contains(CommandArgs.Help))
            {
                options.ShowHelp = true;
                commandArgs.Remove(CommandArgs.Help);
            }

            commandArgs = EvaluateDownloadOptions(options.DownloadArguments, commandArgs, appSettings, envVariables).ToList();

            options.UnprocessedCommandArgs = commandArgs;
            return options;
        }
开发者ID:baronfel,项目名称:Paket,代码行数:32,代码来源:ArgumentParser.cs

示例5: CreateJavaScriptEventObject

        private static void CreateJavaScriptEventObject(StringBuilder scriptCode, NameValueCollection eventObjectProperties)
        {
            if (eventObjectProperties == null) return;

            for (var index = 0; index < eventObjectProperties.Count; index++)
            {
                if (eventObjectProperties.GetKey(index) == "charCode") continue;

                scriptCode.Append("newEvt.");
                scriptCode.Append(eventObjectProperties.GetKey(index));
                scriptCode.Append(" = ");
                scriptCode.Append(eventObjectProperties.GetValues(index)[0]);
                scriptCode.Append(";");
            }
        }
开发者ID:fschwiet,项目名称:watin_unbranched,代码行数:15,代码来源:IEFireEventHandler.cs

示例6: 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

示例7: CreateURI

        public static string CreateURI(string strScheme, string strHost, string strPath, NameValueCollection queryColl)
        {
            bool bFirst = true;
             string strURI = strScheme + "://" + strHost + "/";
             if (!String.IsNullOrEmpty(strPath))
            strURI += strPath;

             string strQuery = String.Empty;
             if (queryColl != null)
             {
            for (int i = 0; i < queryColl.Count; i++)
            {
               if (!bFirst)
                  strQuery += "&";
               else
                  bFirst = false;

               strQuery += queryColl.GetKey(i) + "=" + HttpUtility.UrlEncode(queryColl.Get(i));
            }
             }

             if (strQuery != String.Empty)
            strURI += "?" + strQuery;

             return strURI;
        }
开发者ID:paladin74,项目名称:Dapple,代码行数:26,代码来源:URI.cs

示例8: SetUrlParams

 private void SetUrlParams(NameValueCollection getCollection)
 {
     if (this.rdSignView.Checked)
     {
         try
         {
             getCollection.Add(SecuritySignHelper.PartnerId, this.txtPartner.Text.Trim());
         }
         catch
         {
             getCollection[SecuritySignHelper.PartnerId] = this.txtPartner.Text.Trim();
         }
         try
         {
             getCollection.Add(SecuritySignHelper.ApiSign, this.txtSign.Text.Trim());
         }
         catch
         {
             getCollection[SecuritySignHelper.ApiSign] = this.txtSign.Text.Trim();
         }
     }
     StringBuilder tmp = new StringBuilder();
     for (int i = 0; i < getCollection.Count; i++)
     {
         tmp.Append('&');
         tmp.Append(getCollection.GetKey(i));
         tmp.Append('=');
         tmp.Append(getCollection[i]);
     }
     tmp.Remove(0, 1);
     this.txtUrlParams.Text = tmp.ToString();
 }
开发者ID:dingyzh,项目名称:Dingyzh.Demo,代码行数:32,代码来源:ViewForm.cs

示例9: DoHttpPost

        /// <summary>
        /// Posts the supplied data to specified url.
        /// </summary>
        /// <param name="url">The url to post to.</param>
        /// <param name="values">The values to post.</param>
        /// <returns>a string containing the result of the post.</returns>
        public static string DoHttpPost(string url, NameValueCollection values)
        {
            StringBuilder postData = new StringBuilder();
            for (int i = 0; i < values.Count; i++)
            {
                EncodeAndAddItem(ref postData, values.GetKey(i), values[i]);
            }
            HttpWebRequest request = null;
            Uri uri = new Uri(url);
            request = (HttpWebRequest) WebRequest.Create(uri);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = postData.Length;
            using (Stream writeStream = request.GetRequestStream())
            {
                UTF8Encoding encoding = new UTF8Encoding();
                byte[] bytes = encoding.GetBytes(postData.ToString());
                writeStream.Write(bytes, 0, bytes.Length);
            }

            string result = string.Empty;
            using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
            {
                using (Stream responseStream = response.GetResponseStream())
                {
                    using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
                    {
                        result = readStream.ReadToEnd();
                    }
                }
            }
            return result;
        }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:39,代码来源:HttpPost.cs

示例10: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "GenericServicesProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Generic Service Host Provider");
            }

            base.Initialize(name, config);

            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                {
                    throw new ProviderException("Unrecognized attribute: " + attr);
                }
            }
        }
开发者ID:Mickey-P,项目名称:SmallSharpToolsDotNet,代码行数:29,代码来源:GenericServicesProvider.cs

示例11: Initialize

        /// <summary>
        /// Initializes the provider with the property values specified in the application's configuration file. This method is not intended to be used directly from your code
        /// </summary>
        /// <param name="name">The name of the provider instance to initialize</param>
        /// <param name="config">A NameValueCollection that contains the names and values of configuration options for the provider.</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            base.Initialize(name, config);

            string connectionStringName = config["connectionStringName"];
            if (String.IsNullOrEmpty(connectionStringName))
                throw new ProviderException("Connection name not specified");
            this._sqlConnectionString = NopSqlDataHelper.GetConnectionString(connectionStringName);
            if ((this._sqlConnectionString == null) || (this._sqlConnectionString.Length < 1))
            {
                throw new ProviderException(string.Format("Connection string not found. {0}", connectionStringName));
            }
            config.Remove("connectionStringName");

            if (config.Count > 0)
            {
                string key = config.GetKey(0);
                if (!string.IsNullOrEmpty(key))
                {
                    throw new ProviderException(string.Format("Provider unrecognized attribute. {0}", new object[] { key }));
                }
            }
        }
开发者ID:juliakolesen,项目名称:voobrazi.by,代码行数:33,代码来源:SQLSearchLogProvider.cs

示例12: Main

 static void Main(string[] args)
 {
     // Create an empty NameValueCollection and add multiple values for each key.
     NameValueCollection nvCol = new NameValueCollection();
     nvCol.Add("Minnesota", "St. Paul");
     nvCol.Add("Minnesota", "Minneapolis");
     nvCol.Add("Minnesota", "Rochester");
     nvCol.Add("Florida", "Miami");
     nvCol.Add("Florida", "Orlando");
     nvCol.Add("Arizona", "Pheonix");
     nvCol.Add("Arizona", "Tucson");
     // Get the key at index position 0 (Minnesota).
     string key = nvCol.GetKey(0);
     Console.WriteLine("Key 0: {0}", key);
     // Remove the entry for Minnesota by its key.
     nvCol.Remove(key);
     // Get the values for Florida as a string array.
     foreach (string val in nvCol.GetValues("Florida"))
     {
         Console.WriteLine("A value for 'Florida': {0}", val);
     }
     // Iterate through the entries (Florida and Arizona) in the NameValueCollection.
     foreach (string k in nvCol)
     {
         // Get the values for an entry as a comma-separated list.
         Console.WriteLine("Key: {0} Values: {1}", k, nvCol.Get(k));
     }
 }
开发者ID:HotFury,项目名称:courses,代码行数:28,代码来源:Program.cs

示例13: AddSubmit

        public ActionResult AddSubmit(String ParentID)
        {
            if (BaoMat.ChoPhepLamViec(User.Identity.Name, "KT_TuDien", "Edit") == false)
            {
                return RedirectToAction("Index", "PermitionMessage");
            }
            NameValueCollection arrLoi = new NameValueCollection();
            String iID_MaTaiKhoanGoc = Convert.ToString(Request.Form[ParentID + "_iID_MaTaiKhoanGoc"]);
            if ((iID_MaTaiKhoanGoc == "" || iID_MaTaiKhoanGoc == Convert.ToString(Guid.Empty)))
            {
                arrLoi.Add("err_iID_MaTaiKhoan", "Bạn phải chọn tài khoản gốc");
            }
            if (arrLoi.Count > 0)
            {
                for (int i = 0; i <= arrLoi.Count - 1; i++)
                {
                    ModelState.AddModelError(ParentID + "_" + arrLoi.GetKey(i), arrLoi[i]);
                }

                return RedirectToAction("Index", "TuDien");
            }
            else
            {
                return RedirectToAction("Edit", "TuDien", new { iID_MaTaiKhoanGoc = iID_MaTaiKhoanGoc });
            }
        }
开发者ID:BMSProject2015,项目名称:BMS,代码行数:26,代码来源:TuDienController.cs

示例14: Initialize

        // MembershipProvider Methods
        public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
                throw new ArgumentNullException("config");

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
                name = "AtlassianMembershipProvider";

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Atlassian web service membership provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            using (IUnityContainer container = new UnityContainer()
                .LoadConfiguration())
            {
                service = container.Resolve<IProjectsService>();
            }

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized attribute: " + attr);
            }
        }
开发者ID:iinteractive,项目名称:IInteractive.Projects,代码行数:36,代码来源:AtlassianMembershipProvider.cs

示例15: Initialize

        public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
                throw new ArgumentNullException("config");

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
                name = "ClassroomProvider";

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "SQL Account provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);
         
            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException
                        ("Unrecognized attribute: " + attr);
            }
        }
开发者ID:IdeaFortune,项目名称:Monaco,代码行数:30,代码来源:SqlClassroomProvider.cs


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