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


C# NameValueCollection.Clear方法代码示例

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


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

示例1: DateTimeBind

		public void DateTimeBind()
		{
			var args = new NameValueCollection();

			args.Add("person.DOBday", 1.ToString());
			args.Add("person.DOBmonth", 12.ToString());
			args.Add("person.DOByear", 2005.ToString());

			object instance = binder.BindObject(typeof (Person), "person", builder.BuildSourceNode(args));

			Assert.IsNotNull(instance);
			var p = (Person) instance;
			Assert.AreEqual(new DateTime(2005, 12, 1), p.DOB);

			args.Clear();
			args.Add("person.DOBday", 2.ToString());
			args.Add("person.DOBmonth", 1.ToString());
			args.Add("person.DOByear", 2005.ToString());

			instance = binder.BindObject(typeof (Person), "person", builder.BuildSourceNode(args));

			Assert.IsNotNull(instance);
			p = (Person) instance;
			Assert.AreEqual(new DateTime(2005, 1, 2), p.DOB);
		}
开发者ID:rambo-returns,项目名称:MonoRail,代码行数:25,代码来源:DataBinderTestCase.cs

示例2: OnScrape

        protected override string OnScrape(string url, HtmlNode elem)
        {
            var id = SelectItem(elem, "[name=id]").Attributes["value"].Value;
            var fname = SelectItem(elem, "[name=fname]").Attributes["value"].Value;
            var data = new NameValueCollection();
            data.Add("op", "download1");
            data.Add("usr_login", "");
            data.Add("id", id);
            data.Add("fname", fname);
            data.Add("method_free", "Proceed to Video");
            elem = Post(url, data);

            var rand = SelectItem(elem, "[name=rand]").Attributes["value"].Value;
            data.Clear();
            data.Add("op", "download2");
            data.Add("rand", rand);
            data.Add("id", id);
            data.Add("fname", fname);
            data.Add("method_free", "Proceed to Video");
            data.Add("method_premium", "");
            Thread.Sleep(45000);
            elem = Post(url, data);
            url = new Uri(SelectItem(elem, "#lnk_download").Attributes["href"].Value).AbsoluteUri;

            return url;
        }
开发者ID:huoxudong125,项目名称:VideoSearch,代码行数:26,代码来源:MuchShare.cs

示例3: InitServerList

 private static WmsServerInfo[] InitServerList()
 {
     SetSearchPath();
     XmlDocument serverDoc = ServerDoc();
     XmlNodeList serverNodes = serverDoc.DocumentElement.SelectNodes("Server");
     ArrayList serverList = new ArrayList();
     NameValueCollection userDefinedParameters = new NameValueCollection();
     foreach (XmlNode serverNode in serverNodes)
     {
         XmlNode userDefinedParametersNode = serverNode.SelectSingleNode("UserDefinedParameters");
         if (null != userDefinedParametersNode)
         {
             foreach (XmlAttribute xmlAttribute in userDefinedParametersNode.Attributes)
             {
                 userDefinedParameters.Add(xmlAttribute.Name, xmlAttribute.Value);
             }
         }
         serverList.Add(new WmsServerInfo(serverNode.SelectSingleNode("Description").InnerText, serverNode.SelectSingleNode("HTTP").InnerText, userDefinedParameters.Count > 0 ? new NameValueCollection(userDefinedParameters) : null));
         userDefinedParameters.Clear();
     }
     XmlNode defaultServerNode = serverDoc.DocumentElement.SelectSingleNode("Server/Default");
     _defaultServer = defaultServerNode.ParentNode.SelectSingleNode("Description").InnerText;
     serverList.Sort();
     return serverList.ToArray(typeof(WmsServerInfo)) as WmsServerInfo[];
 }
开发者ID:rupeshkumar399,项目名称:seemapcell,代码行数:25,代码来源:ServerList.cs

示例4: Submit

        private List<string> Submit(string url, NameValueCollection require, List<KeyValuePair<string, string>> datas)
        {                        
            var sentvalues = new NameValueCollection();
            List<string> Results = new List<string>();
                        
            for(int i =0;i<datas.Count; i++) 
            {
                KeyValuePair<string, string> data = datas[i];
                sentvalues.Add(data.Key, data.Value);                
                
                if (i % BlukSize == 0 || i == datas.Count -1)
                {
                    if(require != null)
                        sentvalues.Add(require);

                    sentvalues.Add("secret", secret);
                    System.IO.StreamWriter writer = new System.IO.StreamWriter(string.Format("{0}.txt", i));
                    var response = client.UploadValues(url, sentvalues);
                    var resstring = Encoding.UTF8.GetString(response);
                    writer.Write(resstring);
                    writer.Close();
                    foreach (var res in resstring.Split(','))
                        Results.Add(res);
                    
                    sentvalues.Clear();                    
                }
            }
            return Results;
        }
开发者ID:Prashant-Jonny,项目名称:phever,代码行数:29,代码来源:FClient.cs

示例5: GenericReloadUrl

        string GenericReloadUrl(NameValueCollection queryStrings)
        {
            if ((queryStrings == null) || (queryStrings.Count == 0))
            {
                return Request.Url.AbsolutePath;
            }

            StringBuilder builder = new StringBuilder();

            builder.Append(Request.Url.AbsolutePath).Append("?");

            string str = "";

            foreach (string key in queryStrings.Keys)
            {

                 str = queryStrings[key].Trim().Replace("'", "");

                if (!string.IsNullOrEmpty(str) && (str.Length > 0))
                {
                    builder.Append(key).Append("=").Append(Server.UrlEncode(str)).Append("&");
                }

            }
            queryStrings.Clear();

            builder.Remove(builder.Length - 1, 1);

            return builder.ToString();
        }
开发者ID:davinx,项目名称:himedi,代码行数:30,代码来源:DistributorPage.cs

示例6: ContinuePayment

        public ActionResult ContinuePayment(string url)
        {
            HtmlDocument doc = null;
            try {
                var web = new HtmlWeb();
                doc = web.Load(url);

                var form = doc.DocumentNode.Descendants("FORM").Single();
                var action = form.Attributes["ACTION"].Value;

                var formData = new NameValueCollection();
                foreach (var input in doc.DocumentNode.SelectNodes("//input")) {
                    formData.Add(input.Attributes["NAME"].Value, input.Attributes["VALUE"].Value);
                }

                var post = new PaymentWebClient();
                var bytes = post.UploadValues(action, formData);
                using (var ms = new MemoryStream(bytes))
                    doc.Load(ms);

                form = doc.DocumentNode.Descendants("FORM").First();
                action = form.Attributes["ACTION"].Value;

                formData.Clear();
                var skipNames = new string[] { "payment", "alias", "aliasoperation", "cancel" };
                foreach (var input in doc.DocumentNode.SelectNodes("//input")) {
                    var name = input.Attributes["NAME"];
                    if (name == null) continue;
                    if (skipNames.Contains(name.Value)) continue;
                    var valueAtt = input.Attributes["VALUE"];
                    var value = string.Empty;
                    if (valueAtt != null) value = valueAtt.Value;

                    formData[name.Value] = value;
                }
                formData["Ecom_Payment_Card_Name"] = "autotest";
                formData["Ecom_Payment_Card_Number"] = "4111 1111 1111 1111";
                formData["Ecom_Payment_Card_ExpDate_Month"] = "01";
                formData["Ecom_Payment_Card_ExpDate_Year"] = "2015";
                formData["Comp_Expirydate"] = "201501";
                formData["Ecom_Payment_Card_Verification"] = "123";

                post = new PaymentWebClient();
                //action = HttpUtility.UrlDecode(action); does not do the trick?
                action = action.Replace("&#58;", ":");
                bytes = post.UploadValues(action, formData);
                using (var ms = new MemoryStream(bytes))
                    doc.Load(ms);

                var uri = post.ResponseUri;
                return Redirect(Url.Action("Index", "Delivery") + uri.Query);
            }
            catch (Exception ex) {
                return View("BadPayment", new BadPaymentModel(ex, doc));
            }
        }
开发者ID:kvw,项目名称:MobileData,代码行数:56,代码来源:TestController.cs

示例7: WriteShortcutTo

 public override void WriteShortcutTo(ViewShortcut currentShortcut, NameValueCollection queryString) {
     base.WriteShortcutTo(currentShortcut, queryString);
     if (!IsNewObjectView(currentShortcut)) {
         queryString.Clear();
         var modelView = (IModelViewFriendlyUrl)WebApplication.Instance.Model.Views[currentShortcut.ViewId];
         var objectKey = ObjectKey(currentShortcut, modelView);
         var friendlyUrl = EditModeFriendlyUrl(currentShortcut, modelView.FriendlyUrl, modelView as IModelDetailViewFriendlyUrl);
         queryString.Add(friendlyUrl, objectKey);
     }
 }
开发者ID:paulute,项目名称:eXpand,代码行数:10,代码来源:XpandHttpRequestManager.cs

示例8: WriteShortcutTo

 public void WriteShortcutTo(ViewShortcut currentShortcut, NameValueCollection queryString) {
     if (WebApplication.Instance.SupportsFriendlyUrl()) {
         if (!IsNewObjectView(currentShortcut)){
             var windowId = queryString["WindowId"];
             queryString.Clear();
             var modelView = (IModelViewFriendlyUrl)WebApplication.Instance.Model.Views[currentShortcut.ViewId];
             var objectKey = ObjectKey(currentShortcut, modelView);
             var friendlyUrl = EditModeFriendlyUrl(currentShortcut, modelView.FriendlyUrl, modelView as IModelDetailViewFriendlyUrl);
             queryString.Add(friendlyUrl, objectKey);
             if (!string.IsNullOrEmpty(windowId))
                 queryString.Add("WindowId",windowId);
         }
     }
 }
开发者ID:aries544,项目名称:eXpand,代码行数:14,代码来源:FriendlyUrlHelper.cs

示例9: Configure

        /// <summary>
        /// Configures the <see cref="DataProtectionCryptographyService"/> using the
        /// specified settings collection.
        /// </summary>
        /// <param name="settings">A <see cref="NameValueCollection"/> with the setting to use to configure the service.</param>
        public void Configure(NameValueCollection settings)
        {
            Guard.ArgumentNotNull(settings, "settings");

            if (!String.IsNullOrEmpty(settings["Entropy"]))
            {
                entropy = Convert.FromBase64String(settings["Entropy"]);
            }
            if (!String.IsNullOrEmpty(settings["Scope"]))
            {
                scope = (DataProtectionScope) Enum.Parse(typeof (DataProtectionScope), settings["Scope"]);
            }

            // Remove values from setting for security.
            settings.Clear();
        }
开发者ID:wuyingyou,项目名称:uniframework,代码行数:21,代码来源:DataProtectionCryptographyService.cs

示例10: ProcessCollection

        private static void ProcessCollection(NameValueCollection collection)
        {
            var copy = new NameValueCollection();

            foreach (string key in collection.AllKeys)
            {
                Array.ForEach(
                    collection.GetValues(key),
                    v => copy.Add(key, ForbiddenWord.Filter(v)));
            }

            s_isReadOnlyPropertyInfo.SetValue(collection, false, null);

            collection.Clear();
            collection.Add(copy);

            s_isReadOnlyPropertyInfo.SetValue(collection, true, null);
        }
开发者ID:Benguan,项目名称:Code,代码行数:18,代码来源:FilterForbiddenWordMobule.cs

示例11: CreateWebRequest

        /// <summary>
        /// This method creates secure/non secure web
        /// request based on the parameters passed.
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="collHeader">This parameter of type
        ///    NameValueCollection may contain any extra header
        ///    elements to be included in this request      </param>
        /// <param name="RequestMethod">Value can POST OR GET</param>
        /// <param name="NwCred">In case of secure request this would be true</param>
        /// <returns></returns>
        public virtual HttpWebRequest CreateWebRequest(string uri,
          NameValueCollection collHeader,
          string RequestMethod, bool NwCred)
        {
            HttpWebRequest webrequest =
             (HttpWebRequest)WebRequest.Create(uri);
            webrequest.KeepAlive = false;
            webrequest.Method = RequestMethod;

            int iCount = collHeader.Count;
            string key;
            string keyvalue;

            for (int i = 0; i < iCount; i++)
            {
                key = collHeader.Keys[i];
                keyvalue = collHeader[i];
                webrequest.Headers.Add(key, keyvalue);
            }

            webrequest.ContentType = "text/html";
            //"application/x-www-form-urlencoded";

            if (ProxyServer.Length > 0)
            {
                webrequest.Proxy = new
                 WebProxy(ProxyServer, ProxyPort);
            }
            webrequest.AllowAutoRedirect = false;

            if (NwCred)
            {
                CredentialCache wrCache =
                        new CredentialCache();
                wrCache.Add(new Uri(uri), "Basic",
                  new NetworkCredential(UserName, UserPwd));
                webrequest.Credentials = wrCache;
            }
            //Remove collection elements
            collHeader.Clear();
            return webrequest;
        }//End of secure CreateWebRequest
开发者ID:amosbatista,项目名称:MensageriaTwitterAPI_Lib,代码行数:53,代码来源:HttpBaseClass.cs

示例12: Test01


//.........这里部分代码省略.........
                if (String.Compare(nvc[i], values[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, returned: \"{1}\", expected \"{2}\"", i, nvc[i], values[i]));
                }
            }


            //
            // Intl strings
            // [] get Item() on collection filled with Intl strings
            //

            string[] intlValues = new string[len * 2];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                    val = intl.GetRandomString(MAX_LEN);
                intlValues[i] = val;
            }


            Boolean caseInsensitive = false;
            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLowerInvariant() == intlValues[i].ToUpperInvariant())
                    caseInsensitive = true;
            }


            nvc.Clear();
            for (int i = 0; i < len; i++)
            {
                nvc.Add(intlValues[i + len], intlValues[i]);
            }
            if (nvc.Count != (len))
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, len));
            }

            for (int i = 0; i < len; i++)
            {
                //
                if (String.Compare(nvc[i], intlValues[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, returned \"{1}\" instead of \"{2}\"", i, nvc[i], intlValues[i]));
                }
            }


            //
            // [] Case sensitivity
            //

            string[] intlValuesLower = new string[len * 2];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpperInvariant();
            }
开发者ID:noahfalk,项目名称:corefx,代码行数:66,代码来源:GetItemIntTests.cs

示例13: ReadSectionValues

        public void ReadSectionValues(string Section, NameValueCollection Values)
        {
            StringCollection KeyList = new StringCollection();
            ReadSection(Section, KeyList);
            Values.Clear();
            foreach (string key in KeyList)
            {
                Values.Add(key, ReadString(Section, key, ""));

            }
        }
开发者ID:Mradxz,项目名称:XLoader,代码行数:11,代码来源:IniFileOp.cs

示例14: Test01


//.........这里部分代码省略.........
                }
                if (String.Compare(vls[0], values[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, returned: \"{1}\", expected \"{2}\"", i, vls[0], values[i]));
                }
            }


            //
            // Intl strings
            // [] GetValues() on collection filled with Intl strings
            //

            string[] intlValues = new string[len * 2];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2; i++)
            {
                string val = intl.GetRandomString(MAX_LEN);
                while (Array.IndexOf(intlValues, val) != -1)
                    val = intl.GetRandomString(MAX_LEN);
                intlValues[i] = val;
            }

            Boolean caseInsensitive = false;
            for (int i = 0; i < len * 2; i++)
            {
                if (intlValues[i].Length != 0 && intlValues[i].ToLowerInvariant() == intlValues[i].ToUpperInvariant())
                    caseInsensitive = true;
            }


            nvc.Clear();
            for (int i = 0; i < len; i++)
            {
                nvc.Add(intlValues[i + len], intlValues[i]);
            }
            if (nvc.Count != (len))
            {
                Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, len));
            }

            for (int i = 0; i < len; i++)
            {
                //
                vls = nvc.GetValues(intlValues[i + len]);
                if (vls.Length != 1)
                {
                    Assert.False(true, string.Format("Error, returned number of strings {1} instead of 1", i, vls.Length));
                }
                if (String.Compare(vls[0], intlValues[i]) != 0)
                {
                    Assert.False(true, string.Format("Error, returned \"{1}\" instead of \"{2}\"", i, vls[0], intlValues[i]));
                }
            }


            //
            // [] Case sensitivity
            //

            string[] intlValuesLower = new string[len * 2];

            // fill array with unique strings
            //
开发者ID:SGuyGe,项目名称:corefx,代码行数:67,代码来源:GetValuesStrTests.cs

示例15: Test01


//.........这里部分代码省略.........
                //
                cnt = nvc.Count;
                nvc.Remove(intlValues[i + len]);
                if (nvc.Count != cnt - 1)
                {
                    Assert.False(true, string.Format("Error, returned: failed to remove item", i));
                }
                ks = nvc.AllKeys;
                if (Array.IndexOf(ks, intlValues[i + len]) > -1)
                {
                    Assert.False(true, string.Format("Error, removed wrong item", i));
                }
            }


            //
            // [] Case sensitivity
            //

            string[] intlValuesLower = new string[len * 2];

            // fill array with unique strings
            //
            for (int i = 0; i < len * 2; i++)
            {
                intlValues[i] = intlValues[i].ToUpperInvariant();
            }

            for (int i = 0; i < len * 2; i++)
            {
                intlValuesLower[i] = intlValues[i].ToLowerInvariant();
            }

            nvc.Clear();
            //
            // will use first half of array as values and second half as keys
            //
            for (int i = 0; i < len; i++)
            {
                nvc.Add(intlValues[i + len], intlValues[i]);     // adding uppercase strings
            }

            //
            for (int i = 0; i < len; i++)
            {
                // uppercase key

                cnt = nvc.Count;
                nvc.Remove(intlValues[i + len]);
                if (nvc.Count != cnt - 1)
                {
                    Assert.False(true, string.Format("Error, returned: failed to remove item", i));
                }
                ks = nvc.AllKeys;
                if (Array.IndexOf(ks, intlValues[i + len]) > -1)
                {
                    Assert.False(true, string.Format("Error, removed wrong item", i));
                }
            }

            nvc.Clear();
            //
            // will use first half of array as values and second half as keys
            //
            for (int i = 0; i < len; i++)
            {
开发者ID:SGuyGe,项目名称:corefx,代码行数:67,代码来源:RemoveStrTests.cs


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