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


C# NameValueCollection.Add方法代码示例

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


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

示例1: AccountPropertiesDialog_FormClosing

 private void AccountPropertiesDialog_FormClosing( object sender, FormClosingEventArgs e )
 {
     if( ctx == null || DialogResult != DialogResult.OK ) {
         return;
     }
     if( string.IsNullOrEmpty( textBox1.Text ) ) {
         MessageBox.Show( "Du måste ange ett namn" );
     }
     _account = new Account {
         Name = textBox1.Text
     };
     if( account != null ) {
         _account.ID = account.ID;
     }
     foreach( Control c in panel1.Controls ) {
         CheckBox cb = c as CheckBox;
         if( cb == null || !cb.Checked ) {
             continue;
         }
         User u = (User)cb.Tag;
         _account.PermittedUsers.Add( u.ID );
     }
     NameValueCollection values = new NameValueCollection();
     values.Add( "Name", _account.Name );
     values.Add( "ID", _account.ID );
     foreach( int uid in _account.PermittedUsers ) {
         values.Add( "userid", uid );
     }
     _account = ctx.ServiceCaller.PostData<Account>( string.Format( "{0}/AccountService/Save", ctx.ServiceBaseURL ), values );
 }
开发者ID:EsleEnoemos,项目名称:HomeFinance,代码行数:30,代码来源:AccountPropertiesDialog.cs

示例2: Valid_Code_Request

        public async Task Valid_Code_Request()
        {
            var client = await _clients.FindClientByIdAsync("codeclient");
            var store = new InMemoryAuthorizationCodeStore();

            var code = new AuthorizationCode
            {
                Client = client,
                RedirectUri = "https://server/cb",
                RequestedScopes = new List<Scope>
                {
                    new Scope
                    {
                        Name = "openid"
                    }
                }
            };

            await store.StoreAsync("valid", code);

            var validator = Factory.CreateTokenRequestValidator(
                authorizationCodeStore: store);

            var parameters = new NameValueCollection();
            parameters.Add(Constants.TokenRequest.GrantType, Constants.GrantTypes.AuthorizationCode);
            parameters.Add(Constants.TokenRequest.Code, "valid");
            parameters.Add(Constants.TokenRequest.RedirectUri, "https://server/cb");

            var result = await validator.ValidateRequestAsync(parameters, client);

            result.IsError.Should().BeFalse();
        }
开发者ID:ridopark,项目名称:IdentityServer3,代码行数:32,代码来源:TokenRequestValidation_Valid.cs

示例3: GetVideoUrl

        public override string GetVideoUrl(VideoInfo video)
        {
            CookieContainer newCc = new CookieContainer();
            foreach (Cookie c in cc.GetCookies(new Uri(@"https://www.filmon.com/")))
            {
                newCc.Add(c);
            }

            NameValueCollection headers = new NameValueCollection();
            headers.Add("Accept", "*/*");
            headers.Add("User-Agent", userAgent);
            headers.Add("X-Requested-With", "XMLHttpRequest");
            string webdata = GetWebData(video.VideoUrl, (string)video.Other, newCc, headers: headers);

            JToken jt = JObject.Parse(webdata) as JToken;
            JArray streams = jt.Value<JArray>("streams");
            video.PlaybackOptions = new Dictionary<string, string>();
            foreach (JToken stream in streams)
            {
                string serverUrl = stream.Value<string>("url");

                RtmpUrl res = new RtmpUrl(serverUrl);
                res.Live = true;
                res.PlayPath = stream.Value<string>("name");

                int p = serverUrl.IndexOf("live/?id");
                res.App = serverUrl.Substring(p);
                video.PlaybackOptions.Add(stream.Value<string>("quality"), res.ToString());
            }

            return video.PlaybackOptions.First().Value;
        }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:32,代码来源:FilmonUtil.cs

示例4: API

        public ActionResult API()
        {
            Stream filestream = null;
            if (Request.Files.Count > 0)
            {
                filestream = Request.Files[0].InputStream;
            }

            var pars = new NameValueCollection();
            pars.Add(Request.Params);

            if (Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
            {
                var parsKeys = pars.AllKeys;
                foreach (var key in Request.Form.AllKeys)
                {
                    if (!parsKeys.Contains(key))
                    {
                        pars.Add(Request.Form);
                    }
                }
            }

            var res = getRuntime.DesignerAPI(pars, filestream, true);
            if (pars["operation"].ToLower() == "downloadscheme")
            {
                return File(Encoding.UTF8.GetBytes(res), "text/xml", "Scheme.xml");
            }

            return Content(res);
        }
开发者ID:qcoliveros,项目名称:WorkflowDesigner,代码行数:31,代码来源:DesignerController.cs

示例5: SetUp

		public void SetUp() {
			var config = new NameValueCollection();
			config.Add("applicationName", "IntegrationTests");
			config.Add("ldapServer", LdapServerInConfig);
			var ldapProvider = new LdapRoleProvider();

			ldapProvider.Initialize("IntegrationTests", config);

			var enabledField = typeof(Roles).GetField("s_Enabled",
			                                    BindingFlags.NonPublic |
			                                    BindingFlags.Static);

			enabledField.SetValue(typeof(Roles), true);

			var initialized = typeof(Roles).GetField("s_Initialized",
			                                    BindingFlags.NonPublic |
			                                    BindingFlags.Static);

			initialized.SetValue(typeof(Roles), true);

			var providers = new RoleProviderCollection(); 

			var readOnlyField = typeof(Roles).GetField("s_Providers",
			                                                BindingFlags.NonPublic |
			                                                BindingFlags.Static);
			readOnlyField.SetValue(typeof(Roles), providers);

			providers.Add(ldapProvider);

			var registeredProvider = Roles.Providers["IntegrationTests"];

			Assert.IsNotNull(registeredProvider);
			
			provider = registeredProvider;
		}
开发者ID:aelveborn,项目名称:njupiter,代码行数:35,代码来源:LdapRoleProviderTests.cs

示例6: runUpload

 public static void runUpload( )
 {
     if (Properties.Settings.Default.firstrun)
         return;
     NameValueCollection postdata = new NameValueCollection();
     postdata.Add("u", Properties.Settings.Default.username);
     postdata.Add("p", Properties.Settings.Default.password);
     if (!Clipboard.ContainsImage() && !Clipboard.ContainsText()) {
         nscrot.balloonText("No image or URL in clipboard!", 2);
         return;
     }
     if (!Clipboard.ContainsText()) {
         Image scrt = Clipboard.GetImage();
         System.Threading.Thread upld = new System.Threading.Thread(( ) =>
         {
             nscrot.uploadScreenshot(postdata, scrt);
         });
         upld.SetApartmentState(System.Threading.ApartmentState.STA);
         upld.Start();
     } else {
         string lURL = Clipboard.GetText();
         System.Threading.Thread shrt = new System.Threading.Thread(( ) =>
         {
             nscrot.shorten(lURL);
         });
         shrt.SetApartmentState(System.Threading.ApartmentState.STA);
         shrt.Start();
     }
 }
开发者ID:Maffsie,项目名称:NetScrot,代码行数:29,代码来源:Program.cs

示例7: ToQueryString

 public void ToQueryString()
 {
     var Collection = new NameValueCollection();
     Collection.Add("A", "1");
     Collection.Add("B", "2");
     Assert.Equal("?A=1&B=2", Collection.ToQueryString());
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:7,代码来源:NameValueCollectionExtensions.cs

示例8: Handling_namevaluecollection_forced_encryption_should_work

        public void Handling_namevaluecollection_forced_encryption_should_work()
        {
            /* Arrange */
            var crypto = A.Fake<ICryptoProvider>();
            A.CallTo(() => crypto.Encrypt(A<string>.Ignored)).ReturnsLazily(h => Convert.ToBase64String(Encoding.UTF8.GetBytes(h.Arguments[0].ToString())));
            A.CallTo(() => crypto.Decrypt(A<string>.Ignored)).ReturnsLazily(h => Encoding.UTF8.GetString(Convert.FromBase64String(h.Arguments[0].ToString())));
            A.CallTo(() => crypto.IsEncrypted(A<string>.Ignored)).Returns(true);

            var nv = new NameValueCollection();
            nv.Add("PlainOne", "PlainTextOne");
            nv.Add("PlainTwo", "PlainTextTwo");

            var handler = new NameValueExtendedSectionHandler();

            /* Act */
            var node = handler.WriteSection("TestSection", nv, crypto, true);
            var result = handler.ReadSection(node, crypto, true) as NameValueSettings;
            var val1 = result.Get("PlainOne", null);
            var val2 = result.Get("PlainTwo", null);
            var allEncrypted = result.IsEncrypted("PlainOne") && result.IsEncrypted("PlainTwo");

            /* Assert */
            val1.Should().Be("PlainTextOne");
            val2.Should().Be("PlainTextTwo");
            allEncrypted.Should().BeTrue();
        }
开发者ID:Geminior,项目名称:DeepConfig,代码行数:26,代码来源:NameValueExtendedSectionHandlerTests.cs

示例9: SendInstallData

        private static void SendInstallData(string error)
        {
            try
            {
                using (var client = new WebClient())
                {
                    var data = new NameValueCollection();
                    data.Add("error", error);
                    data.Add("computername", SystemInformation.ComputerName);

                    using (var mgmt = new ManagementClass("Win32_OperatingSystem"))
                    {
                        try
                        {
                            foreach (ManagementObject mgmtObj in mgmt.GetInstances())
                            {
                                // Just get first value.
                                data.Add("os", mgmtObj["Caption"].ToString().Trim());
                                break;
                            }
                        }
                        catch { }
                        var result = System.Text.Encoding.Default.GetString(client.UploadValues("http://www.filmkhoj.com/api/install", data));
                    }
                }
            }
            catch { }
        }
开发者ID:huoxudong125,项目名称:VideoSearch,代码行数:28,代码来源:EthicalRestartForm.cs

示例10: GetMessageAsNameValueCollection

        private NameValueCollection GetMessageAsNameValueCollection(PushoverMessage message)
        {
            var postData = new NameValueCollection()
            {
                {"token", _config.ApiToken},
                {"user", message.User},
                {"message", message.Message},
                {"priority", message.Priority.ToString("D")},
                {"sound", message.Sound.ToString("G").ToLower()}
            };

            if (!string.IsNullOrWhiteSpace(message.Device))
                postData.Add("device", message.Device);

            if (!string.IsNullOrWhiteSpace(message.Title))
                postData.Add("title", message.Title);

            if (!string.IsNullOrWhiteSpace(message.Url))
                postData.Add("url", message.Url);

            if (!string.IsNullOrWhiteSpace(message.UrlTitle))
                postData.Add("url_title", message.UrlTitle);

            if (!string.IsNullOrWhiteSpace(message.TimeStamp))
                postData.Add("timestamp", message.TimeStamp);

            return postData;
        }
开发者ID:DevFluff,项目名称:Messaging,代码行数:28,代码来源:PushoverClient.cs

示例11: Unknown_Grant_Type

        public async Task Unknown_Grant_Type()
        {
            var client = await _clients.FindClientByIdAsync("codeclient");
            var store = new InMemoryAuthorizationCodeStore();

            var code = new AuthorizationCode
            {
                Client = client,
                IsOpenId = true,
                RedirectUri = new Uri("https://server/cb"),
            };

            await store.StoreAsync("valid", code);

            var validator = Factory.CreateTokenValidator(
                authorizationCodeStore: store);

            var parameters = new NameValueCollection();
            parameters.Add(Constants.TokenRequest.GrantType, "unknown");
            parameters.Add(Constants.TokenRequest.Code, "valid");
            parameters.Add(Constants.TokenRequest.RedirectUri, "https://server/cb");

            var result = await validator.ValidateRequestAsync(parameters, client);

            Assert.IsTrue(result.IsError);
            Assert.AreEqual(Constants.TokenErrors.UnsupportedGrantType, result.Error);
        }
开发者ID:JaiChaturvedi,项目名称:Thinktecture.IdentityServer.v3,代码行数:27,代码来源:TokenRequestValidation_General_Invalid.cs

示例12: GitList

        public static void GitList(string hostname, string username, string password)
        {
            string sessionurl = "https://" + hostname + "/api/v3/session";

            NameValueCollection values = new NameValueCollection();
            values.Add("login", username);
            values.Add("password", password);

            string private_token = GetData(sessionurl, values).private_token;

            int page = 1;
            bool found;
            do
            {
                string projectsurl = "https://" + hostname + "/api/v3/projects?private_token=" + private_token + "&page=" + page;
                found = false;
                var results = GetData(projectsurl);
                foreach (var result in results)
                {
                    Console.WriteLine(result.http_url_to_repo);
                    found = true;
                }
                page++;
            } while (found);
        }
开发者ID:perjahn,项目名称:PerJahnUtils,代码行数:25,代码来源:Program.cs

示例13: SchemaCheck

    public void SchemaCheck()
    {
      for (int i = 0; i <= SchemaManager.Version; i++)
      {
        DropAllTables();
        MySQLMembershipProvider provider = new MySQLMembershipProvider();
        NameValueCollection config = new NameValueCollection();
        config.Add("connectionStringName", "LocalMySqlServer");
        config.Add("applicationName", "/");
        config.Add("passwordFormat", "Clear");

        if (i > 0)
          for (int x = 1; x <= i; x++)
            LoadSchema(x);

        try
        {
          provider.Initialize(null, config);
          if (i < SchemaManager.Version)
            Assert.Fail("Should have failed");
        }
        catch (ProviderException)
        {
          if (i == SchemaManager.Version)
            Assert.Fail("This should not have failed");
        }
      }
    }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:28,代码来源:SchemaTests.cs

示例14: RunIsoInBochs

        private void RunIsoInBochs(string iso, string harddisk)
        {
            if (!File.Exists(harddisk))
            {
                throw new FileNotFoundException("Harddisk file not found!", harddisk);
            }

            var xBochsConfig = Path.Combine(mBaseWorkingDirectory, "Kernel.bochsrc");
            var xParams = new NameValueCollection();

            xParams.Add("ISOFile", iso);
            xParams.Add(BuildPropertyNames.VisualStudioDebugPortString, "Pipe: Cosmos\\Serial");
            xParams.Add(BuildPropertyNames.EnableBochsDebugString, RunWithGDB.ToString());

            var xDebugConnector = new DebugConnectorPipeServer(DebugConnectorPipeServer.DefaultCosmosPipeName);
            InitializeDebugConnector(xDebugConnector);

            var xBochs = new Bochs(xParams, RunWithGDB, new FileInfo(xBochsConfig), harddisk);

            xBochs.OnShutDown = (a, b) =>
                                {
                                };

            xBochs.RedirectOutput = false;
            xBochs.LogError = s => OutputHandler.LogDebugMessage(s);
            xBochs.LogOutput = s => OutputHandler.LogDebugMessage(s);

            HandleRunning(xDebugConnector, xBochs);
        }
开发者ID:nstone101,项目名称:Cosmos,代码行数:29,代码来源:Engine.Bochs.cs

示例15: PostCanvasSISImport

        public Hashtable PostCanvasSISImport(string filename, string extension)
        {
            if(!validateSettings()){
                // TODO I know null isn't the best response for this return type but if the settings aren't valid it shouldn't
                // work.  What is a better return type?
                return null;
            }else{
                string url = @"https://" + sub_domain + ".instructure.com/api/v1/accounts/"+account_id+"/sis_imports.json";

                NameValueCollection nvc = new NameValueCollection();

                nvc.Add("import_type","instructure_csv");
                nvc.Add("access_token",access_token);
                nvc.Add("extension",extension);

              	WebClient client = new WebClient();
                client.QueryString = nvc;

                client.Headers.Add("Content-Type","application/x-www-form-urlencoded");

                byte[] fileContents = System.IO.File.ReadAllBytes(filename);

                byte[] responseBinary = client.UploadData(url,"POST",fileContents);

                string response = Encoding.UTF8.GetString(responseBinary);

                Console.WriteLine("response: " + response);
                // return response;
                Hashtable json_response = returnJson(response);
                json_response["raw_response"] = response;
                return json_response;
            }
        }
开发者ID:stronge,项目名称:canvas-contrib,代码行数:33,代码来源:CanvasSIS.cs


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