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


C# System.Collections.Specialized.NameValueCollection.Add方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            using (WebClient client = new WebClient())
            {
                System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();
                reqparm.Add("username", "Matija");
                reqparm.Add("passwd", "1234");
                byte[] bytes = client.UploadValues("http://ates-test.algebra.hr/iis/testSubmit.aspx", "POST", reqparm);
                string body = Encoding.UTF8.GetString(bytes);
                Console.WriteLine(body);

                WebHeaderCollection wcHeaderCollection = client.ResponseHeaders;
                Console.WriteLine("\nHeaders:\n");

                for (int i = 0; i < wcHeaderCollection.Count; i++)
                {
                    Console.WriteLine(wcHeaderCollection.GetKey(i) + " = " + wcHeaderCollection.Get(i));
                }
            }
            Console.WriteLine();

            using (WebClient client = new WebClient())
            {
                string reply = client.DownloadString(@"http://ates-test.algebra.hr/iis/testSubmit.aspx?username=Matija&passwd=1234");
                Console.WriteLine(reply);
                WebHeaderCollection wcHeaderCollection = client.ResponseHeaders;
                Console.WriteLine("\nHeaders:\n");

                for (int i = 0; i < wcHeaderCollection.Count; i++)
                {
                    Console.WriteLine(wcHeaderCollection.GetKey(i) + " = " + wcHeaderCollection.Get(i));
                }
                Console.ReadKey();
            }
        }
开发者ID:humra,项目名称:Practice,代码行数:35,代码来源:Program.cs

示例2: UpdateDNSIP

        public bool UpdateDNSIP(string rec_id, string IP, string name, string service_mode, string ttl)
        {
            string url = "https://www.cloudflare.com/api_json.html";

            System.Net.WebClient wc = new System.Net.WebClient();
            //NameValueCollectionの作成
            System.Collections.Specialized.NameValueCollection ps = new System.Collections.Specialized.NameValueCollection();
            //送信するデータ(フィールド名と値の組み合わせ)を追加
            ps.Add("a", "rec_edit");
            ps.Add("tkn", KEY);
            ps.Add("id", rec_id);
            ps.Add("email", EMAIL);
            ps.Add("z", DOMAIN);
            ps.Add("type", "A");
            ps.Add("name", name);
            ps.Add("content", IP);
            ps.Add("service_mode", service_mode);
            ps.Add("ttl", ttl);

            //データを送信し、また受信する
            byte[] resData = wc.UploadValues(url, ps);
            wc.Dispose();
            string resText = System.Text.Encoding.UTF8.GetString(resData);
            Clipboard.SetText(resText);
            return false;
        }
开发者ID:SlaynationCoder,项目名称:CloudFlare-DNS-Updator,代码行数:26,代码来源:CFAPI.cs

示例3: Api

        public static string Api(string Temperature,string Humidity)
        {
            string url = (string)Properties.Settings.Default["ApiAddress"];
            string resText = "";
            try {
                System.Net.WebClient wc = new System.Net.WebClient();
                System.Collections.Specialized.NameValueCollection ps =
                    new System.Collections.Specialized.NameValueCollection();

                ps.Add("MachineName", (string)Properties.Settings.Default["MachineName"]);
                ps.Add("Temperature", Temperature);
                ps.Add("Humidity", Humidity);

                byte[] ResData = wc.UploadValues(url, ps);
                wc.Dispose();
                resText = System.Text.Encoding.UTF8.GetString(ResData);
                if (resText != "OK")
                {
                    return "APIエラー";
                }
            }
            catch (Exception ex){
                return ex.ToString();
            }

            return null;
        }
开发者ID:ichirowo,项目名称:Room-temperature_IoT,代码行数:27,代码来源:WebAccess.cs

示例4: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            // Authentication
            if ((textBox2.Text == "") || (textBox7.Text == "") || (textBox8.Text == ""))
            {
                MessageBox.Show("Check Parameters");
                return;
            }
            DOMAIN = textBox2.Text;
            ADMIN_USER = textBox7.Text;
            ADMIN_PWD = textBox8.Text;

            System.Collections.Specialized.NameValueCollection ps = new System.Collections.Specialized.NameValueCollection();
            ps.Add("accountType", "HOSTED");
            ps.Add("Email", ADMIN_USER + "@" + DOMAIN);
            ps.Add("Passwd", ADMIN_PWD);
            ps.Add("service", "apps");
            WebClient wc = new WebClient();
            try
            {
                byte[] resData = wc.UploadValues(@"https://www.google.com/accounts/ClientLogin", ps);
                wc.Dispose();
                string[] a = System.Text.Encoding.UTF8.GetString(resData).Split('\n');
                foreach (string str in a)
                {
                    if (str.StartsWith("Auth="))
                    {
                        label1.Text = str;
                        AuthNToken = str.Substring(5);
                    }
                }
                button4.Enabled = true;
                button5.Enabled = true;
                button6.Enabled = true;
                button7.Enabled = true;
                button8.Enabled = true;
                button9.Enabled = true;
                checkBox1.Enabled = true;
                checkBox2.Enabled = true;
                textBox1.Text = "operation completed";
                button1.Enabled = false;
            }
            catch (System.Net.WebException ex)
            {
                //HttpWebResponseを取得
                System.Net.HttpWebResponse errres =
                    (System.Net.HttpWebResponse)ex.Response;
                textBox1.Text =
                    errres.StatusCode.ToString() + ":" + errres.StatusDescription;

            }
            finally
            {
                wc.Dispose();
            }
        }
开发者ID:fujie,项目名称:GoogleApps-Control-GUI,代码行数:56,代码来源:Form1.cs

示例5: ibLogin_Click

        // 登录
        protected void ibLogin_Click(object sender, ImageClickEventArgs e)
        {
            // 记录其IP地址,下次登录时验证,IP为空则记录,IP不为空则验证
            string uname = this.tbUname.Value;
            string upwd = this.tbPwd.Value;
            string uid = new JumbotOA.BLL.UserBLL().Existslongin(uname, JumbotOA.Utils.MD5.Lower32(upwd));
            if (uid != "")
            {
                JumbotOA.Entity.UserEntity model = new JumbotOA.Entity.UserEntity();
                model = new JumbotOA.BLL.UserBLL().GetEntity(int.Parse(uid));
                if (model.Uipaddress != "")
                {
                    if (model.Uipaddress != Page.Request.UserHostAddress)
                    {
                        Response.Write("<script>alert('非法IP,请在本机登陆!');</script>");
                        Response.End();
                    }
                }
                int iExpires = 0;
                //设置Cookies
                System.Collections.Specialized.NameValueCollection myCol = new System.Collections.Specialized.NameValueCollection();
                myCol.Add("id", uid.ToString());
                myCol.Add("name", uname);
                myCol.Add("ip", Request.UserHostAddress);
                new BLL.UserBLL().UpdateTime(model.Uid);
                int pid = model.Pid;
                myCol.Add("Powerid",pid.ToString());
                JumbotOA.Utils.Cookie.SetObj("oa_user", 60 * 60 * 15 * iExpires, myCol, "", "/");

                switch (pid)
                {
                    case 1:
                        Response.Redirect("Home1.aspx");//管理员
                        break;
                    case 2:
                        Response.Redirect("Home2.aspx");//管理组织层
                        break;
                    case 3:
                        Response.Redirect("Home3.aspx");//网站编辑
                        break;
                    case 4:
                        Response.Redirect("Home4.aspx");//美工和程序员
                        break;
                }
            }
            else
            {
                this.tbUname.Value = "";
                this.tbPwd.Value = "";
                System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler;
                page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript", "<script language='javascript'>alert('请正确填写用户名和密码!');</script>");
            }
        }
开发者ID:huaminglee,项目名称:Cooperative--Office-Automation-System,代码行数:54,代码来源:Index.aspx.cs

示例6: GetWebContent

 public string GetWebContent(string Url, string pagenum, string cat)
 {
     string strResult = "";
     try
     {
         WebClient WebClientObj = new WebClient();
         System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection();
         PostVars.Add("Cat", cat);
         PostVars.Add("mnonly", "0");
         PostVars.Add("newproducts", "0");
         PostVars.Add("ColumnSort", "0");
         PostVars.Add("page", pagenum);
         PostVars.Add("stock", "0");
         PostVars.Add("pbfree", "0");
         PostVars.Add("rohs", "0");
         byte[] byRemoteInfo = WebClientObj.UploadValues(Url, "POST", PostVars);
         //StreamReader streamRead = new StreamReader(byRemoteInfo.ToString(), Encoding.Default);
         //FileStream fs = new FileStream(@"D:\\gethtml.txt", FileMode.Create);
         //BinaryWriter sr = new BinaryWriter(fs);
         //sr.Write(byRemoteInfo, 0, byRemoteInfo.Length);
         //sr.Close();
         //fs.Close();
         strResult = Encoding.Default.GetString(byRemoteInfo);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return strResult;
 }
开发者ID:hanhanlovehuhu,项目名称:-------,代码行数:30,代码来源:GetData.cs

示例7: Process

		/// <summary>
		/// 
		/// </summary>
		/// <param name="userAgent"></param>
		/// <param name="initialCapabilities"></param>
		/// <returns></returns>
		public System.Web.Configuration.CapabilitiesResult Process(string userAgent, System.Collections.IDictionary initialCapabilities)
		{
			System.Collections.Specialized.NameValueCollection header;
			header = new System.Collections.Specialized.NameValueCollection(1);
			header.Add("User-Agent", userAgent);
			return Process(header, initialCapabilities);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:13,代码来源:CapabilitiesBuild.cs

示例8: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "image/png";

            string prefFilter = context.Request["pref"] ?? "全て";
            string cityFilter = context.Request["city"] ?? "全て";
            string categoryFilter = context.Request["category"] ?? "全て";
            string productFilter = context.Request["product"] ?? "全て";
            string publishDayFilter = context.Request["publish"] ?? "全て";
            string pickDayFilter = context.Request["pick"] ?? "全て";
            string sortItem = context.Request["sort"] ?? "1";
            string widthString = context.Request["width"] ?? "";
            string heightString = context.Request["height"] ?? "";

            int width, height;
            if (Int32.TryParse(widthString, out width) == false) width = 600;
            if (Int32.TryParse(heightString, out height) == false) height = 300;
            width = Math.Min(1000, Math.Max(300, width));
            height = Math.Min(600, Math.Max(150, height));

            var list = Common.GetQuery(prefFilter, cityFilter, categoryFilter, productFilter, publishDayFilter, pickDayFilter, sortItem);
            var param = list.Item1.ToList().PrepareChartParam(width, height);

            using (var cl = new System.Net.WebClient())
            {
                var values = new System.Collections.Specialized.NameValueCollection();
                foreach (var item in param)
                {
                    values.Add(item.Substring(0, item.IndexOf('=')), item.Substring(item.IndexOf('=') + 1));
                }
                var resdata = cl.UploadValues("http://chart.googleapis.com/chart?chid=1", values);
                context.Response.OutputStream.Write(resdata, 0, resdata.Length);
            }
        }
开发者ID:udawtr,项目名称:yasaikensa,代码行数:34,代码来源:SearchChartImage.ashx.cs

示例9: OnBeforePopup

 protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
 {
     bool res = false;
     if (!string.IsNullOrEmpty(targetUrl))
     {
         if (webBrowser.selfRequest != null)
         {
             CefRequest req = CefRequest.Create();
             req.FirstPartyForCookies = webBrowser.selfRequest.FirstPartyForCookies;
             req.Options = webBrowser.selfRequest.Options;
             /*CefPostData postData = CefPostData.Create();
             CefPostDataElement element = CefPostDataElement.Create();
             int index = targetUrl.IndexOf("?");
             string url = targetUrl.Substring(0, index);
             string data = targetUrl.Substring(index + 1);
             byte[] bytes = Encoding.UTF8.GetBytes(data);
             element.SetToBytes(bytes);
             postData.Add(element);
             */
             System.Collections.Specialized.NameValueCollection h = new System.Collections.Specialized.NameValueCollection();
             h.Add("Content-Type", "application/x-www-form-urlencoded");
             req.Set(targetUrl, webBrowser.selfRequest.Method, null, webBrowser.selfRequest.GetHeaderMap());
             webBrowser.selfRequest = req;
         }
         //webBrowser.selfRequest.Set(targetUrl, webBrowser.selfRequest.Method, webBrowser.selfRequest.PostData, webBrowser.selfRequest.GetHeaderMap());
         res = webBrowser.OnNewWindow(targetUrl);
         if (res)
             return res;
     }
     res = base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, popupFeatures, windowInfo, ref client, settings, ref noJavascriptAccess);
     return res;
 }
开发者ID:lukeandshuo,项目名称:HydataBrowser,代码行数:32,代码来源:CwbLifeSpanHandler.cs

示例10: Decode

 public static System.Collections.Specialized.NameValueCollection Decode(string markString)
 {
     System.Text.RegularExpressions.MatchCollection _matckresult = _decodeReg.Matches(markString);
     if (_matckresult.Count > 0) {
         System.Collections.Specialized.NameValueCollection marks = new System.Collections.Specialized.NameValueCollection();
         for (int i = 0; i < _matckresult.Count; i++) {
             System.Text.RegularExpressions.Match match = _matckresult[i];
             string tempname, tempvalue;
             if (match.Value.IndexOf('=') > 0) {
                 tempname = match.Value.Substring(0, match.Value.IndexOf('='));
                 tempvalue = match.Value.Substring(match.Value.IndexOf('=') + 1);
             } else {
                 tempname = match.Value;
                 tempvalue = string.Empty;
             }
             tempname = tempname.Trim();
             if (!string.IsNullOrEmpty(tempvalue)) {
                 tempvalue = tempvalue.Trim(' ', tempvalue[0]);
             }
             marks.Add(tempname, tempvalue);
         }
         return marks;
     } else {
         throw new Exception(string.Format("Can not analyze \"{0}\"", markString));
     }
 }
开发者ID:BrookHuang,项目名称:XYFrame,代码行数:26,代码来源:ControlTools.cs

示例11: GetAssemblyEventMapping

        private System.Collections.Specialized.NameValueCollection GetAssemblyEventMapping(System.Reflection.Assembly assembly, Hl7Package package)
        {
            System.Collections.Specialized.NameValueCollection structures = new System.Collections.Specialized.NameValueCollection();
            using (System.IO.Stream inResource = assembly.GetManifestResourceStream(package.EventMappingResourceName))
            {
                if (inResource != null)
                {
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(inResource))
                    {
                        string line = sr.ReadLine();
                        while (line != null)
                        {
                            if ((line.Length > 0) && ('#' != line[0]))
                            {
                                string[] lineElements = line.Split(' ', '\t');
                                structures.Add(lineElements[0], lineElements[1]);
                            }
                            line = sr.ReadLine();

                        }
                    }
                }
            }
            return structures;
        }
开发者ID:snosrap,项目名称:nhapi,代码行数:25,代码来源:EventMapper.cs

示例12: Proxy

        public Proxy(DBPostPlugin plugin)
        {
            this.plugin = plugin;
            this.SortWorker = new RecordSortWorker();
            this.Records = new List<Record>();

            var proxy = KanColleClient.Current.Proxy;

            var apis = Enum.GetValues(typeof(Api)).Cast<Api>().ToList();
            foreach (var api in apis)
            {
                var url = api.GetUrl();
                proxy.ApiSessionSource.Where(x => x.Request.PathAndQuery
                    .StartsWith("/kcsapi/" + url))
                    .Subscribe(x =>
                    {
                        if (ToolSettings.SendDb && !string.IsNullOrEmpty(ToolSettings.DbAccessKey))
                        {
                            System.Collections.Specialized.NameValueCollection post
                                = new System.Collections.Specialized.NameValueCollection();
                            post.Add("token", ToolSettings.DbAccessKey);
                            post.Add("agent", "LZXNXVGPejgSnEXLH2ur");
                            post.Add("url", x.Request.PathAndQuery);
                            string requestBody = System.Text.RegularExpressions.Regex.Replace(
                                x.Request.BodyAsString,
                                @"&api(_|%5F)token=[0-9a-f]+|api(_|%5F)token=[0-9a-f]+&?", "");
                            post.Add("requestbody", requestBody);
                            post.Add("responsebody", x.Response.BodyAsString);
            #if DEBUG
                            MessageBox.Show(
                                string.Join(
                                    "\n", post.AllKeys.Select(key => key + ": " + post[key])),
                                    "この内容を送信します");
            #else
                            System.Net.WebClient wc = new System.Net.WebClient();
                            wc.UploadValuesAsync(new Uri("http://api.kancolle-db.net/2/"), post);
            #endif
                            Records.Add(new Record(DateTime.Now, api, x));
                            this.UpdateRows();

                            if (ToolSettings.NotifyLog)
                                this.Notify(Notification.Types.Test, "送信しました", x.Request.PathAndQuery);
                        }
                    });
            }
        }
开发者ID:peer4321,项目名称:KanColleDBPostPlugin,代码行数:46,代码来源:Proxy.cs

示例13: FormValidation_Email_ShouldValidate

 public void FormValidation_Email_ShouldValidate()
 {
     var f = new DynaForm("form")
         .AddFormField("emailaddress", email: true);
     var formMock = new System.Collections.Specialized.NameValueCollection();
     formMock.Add("emailaddress", "[email protected]");
     f.TryUpdateModel(formMock);
     Assert.IsTrue(f.Validation.IsValid);
 }
开发者ID:joeriks,项目名称:DynaForms,代码行数:9,代码来源:FormValidations.cs

示例14: FormValidation_Minimum_ShouldNotValidate

 public void FormValidation_Minimum_ShouldNotValidate()
 {
     var f = new DynaForm("form2")
         .AddFormField("number", numeric: true, min:4);
     var formMock = new System.Collections.Specialized.NameValueCollection();
     formMock.Add("number", "2");
     f.TryUpdateModel(formMock);
     Assert.IsFalse(f.Validation.IsValid);
 }
开发者ID:joeriks,项目名称:DynaForms,代码行数:9,代码来源:FormValidations.cs

示例15: Start

 public void Start()
 {
     String URI = registry.URL + "/api.php";
     this.client = new WebClient();
     System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection();
     reqparm.Add();
     byte[] responsebytes = client.UploadValues(URI, "POST", reqparm);
     string responsebody = Encoding.UTF8.GetString(responsebytes);
 }
开发者ID:heliocentric,项目名称:dagent,代码行数:9,代码来源:WinMonitor.cs


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