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


C# NameValueCollection类代码示例

本文整理汇总了C#中NameValueCollection的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection类的具体用法?C# NameValueCollection怎么用?C# NameValueCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetToken

            private void GetToken(string code)
            {
                using (var wb = new WebClient())
                {
                    var parameters = new NameValueCollection
                                 {
                                     {"client_id", "7be60d85e67648d490d3126f73c77434"},
                                     {"client_secret", "fba7cd45089e4cf7922b086310d19913"},
                                     {"grant_type", "authorization_code"},
                                     {"redirect_uri", "http://localhost:4719/"},
                                     {"code", code}
                                 };

                    var response = wb.UploadValues("https://api.instagram.com/oauth/access_token", "POST", parameters);
                    string json = Encoding.ASCII.GetString(response);

                    try
                    {
                        var OauthResponse = (InstagramOAuthResponse)JsonConvert.DeserializeObject(json, typeof(InstagramOAuthResponse));
                    }
                    catch (Exception ex)
                    {
                        //handle ex if needed.
                    }
                }
            }
开发者ID:Babych,项目名称:instasample,代码行数:26,代码来源:InstagramClient.cs

示例2: ServerLoop

    public void ServerLoop()
    {
        while (server_status == "online")
        {
            NameValueCollection pa = new NameValueCollection();
            pa.Add("sid", host_id);

            byte[] data = client.UploadValues(AppConst.SERVER_DOMAIN + AppConst.SERVER_PATH + "?act=SetServerAct", pa);
            current_server_activity = HoUtility.ByteToString(data);
            //main.Log("current_server_activity: " + current_server_activity);
            if (current_server_activity == "client_connected")
            {
                data = client.UploadValues(AppConst.SERVER_DOMAIN + AppConst.SERVER_PATH + "?act=ClientIP", pa);
                revitClientIP = HoUtility.ByteToString(data).Trim();
            }
            else if (current_server_activity == "model_uploaded")
            {
                System.IO.File.Delete("building.fbx");
                client.DownloadFile(AppConst.SERVER_DOMAIN + AppConst.SERVER_PATH + AppConst.SERVER_MODEL_PATH + host_id + ".fbx", "building.fbx");
                data = client.UploadValues(AppConst.SERVER_DOMAIN + AppConst.SERVER_PATH + "?act=GetSemanticFile", pa);

                main.SetSemanticInfo(HoUtility.ByteToString(data));
                main.DownloadModelCb();
            }
            Thread.Sleep(1000);
        }
    }
开发者ID:sonygod,项目名称:ESPUnity,代码行数:27,代码来源:ServerThread.cs

示例3: SetValues

 void SetValues(NameValueCollection c)
 {
     cookie.Values.Clear();
         foreach (string key in c) {
             cookie.Values.Add(key, c[key]);
         }
 }
开发者ID:RyanShaul,项目名称:dig,代码行数:7,代码来源:KeyedCookie.cs

示例4: ETWLoggerFactoryAdapter

 public ETWLoggerFactoryAdapter(NameValueCollection properties)
     : base(true)
 {
     CheckPermitDuplicateEventSourceRegistration(properties);
     ConfigureEventSource(properties);
     ConfigureLogLevel(properties);
 }
开发者ID:net-commons,项目名称:common-logging,代码行数:7,代码来源:ETWLoggerFactoryAdapter.cs

示例5: GoTo

    public void GoTo(ViewPages viewPages, NameValueCollection parameters)
    {
        HttpContext currentContext = HttpContext.Current;
            string redirectUrl = string.Empty;

            switch (viewPages)
            {
                case ViewPages.Eventos:
                    redirectUrl = "~/ListaEventos.aspx";
                    break;
                case ViewPages.EventoDetalles:
                    redirectUrl = "~/Evento.aspx";
                    break;
                case ViewPages.Confirmacion:
                    redirectUrl = "~/Confirmacion.aspx";
                    break;
                case ViewPages.Error:
                    redirectUrl = "~/Erroaspx";
                    break;
                default:
                    throw new ArgumentOutOfRangeException("viewPages");
            }

            currentContext.Response.Redirect(redirectUrl, true);
    }
开发者ID:vvalotto,项目名称:PlataformaNET,代码行数:25,代码来源:ServicioNavegacion.cs

示例6: NameValueCollectionAdd

        public void NameValueCollectionAdd()
        {
            NameValueCollection nvc = new NameValueCollection();
            nvc.Add("anint", 17);
            nvc.Add("adouble", 1.234);
            nvc.Add("astring", "bugs bunny");
            nvc.Add("aguid", Guid.Empty);

            nvc.Count.Should().Be(4);

            nvc.GetValue<int>("anint").Should().Be(17);
            nvc.GetValue<double>("adouble").Should().Be(1.234);
            nvc.GetValue<string>("astring").Should().Be("bugs bunny");
            nvc.GetValue<Guid>("aguid").Should().Be(Guid.Empty);

            int i = 1;
            10.Times(() => nvc.Add("x" + i, i++));

            nvc.ToString().Should().Contain("anint");
            nvc.ToString().Should().Contain("17");
            nvc.ToString().Should().Contain("adouble");
            nvc.ToString().Should().Contain("bugs bunny");
            nvc.ToString().Should().Contain("aguid");
            nvc.ToString().Should().Contain("...");
        }
开发者ID:ShaneCastle,项目名称:TeaFiles.Net,代码行数:25,代码来源:NameValueTest.cs

示例7: UsesTraceSource

        public void UsesTraceSource()
        {
            Console.WriteLine("Config:"+ AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);

            Assert.AreEqual("FromAppConfig", ConfigurationManager.AppSettings["appConfigCheck"]);

            // just ensure, that <system.diagnostics> is configured for our test
            Trace.Refresh();
            TraceSource ts = new TraceSource("TraceLoggerTests", SourceLevels.All);
            Assert.AreEqual(1, ts.Listeners.Count);
            Assert.AreEqual(typeof(CapturingTraceListener), ts.Listeners[0].GetType());

            CapturingTraceListener.Events.Clear();
            ts.TraceEvent(TraceEventType.Information, 0, "message");
            Assert.AreEqual(TraceEventType.Information, CapturingTraceListener.Events[0].EventType);
            Assert.AreEqual("message", CapturingTraceListener.Events[0].FormattedMessage);

            // reset events and set loggerFactoryAdapter
            CapturingTraceListener.Events.Clear();
            NameValueCollection props = new NameValueCollection();
            props["useTraceSource"] = "TRUE";
            TraceLoggerFactoryAdapter adapter = new TraceLoggerFactoryAdapter(props);
            adapter.ShowDateTime = false;
            LogManager.Adapter = adapter;

            ILog log = LogManager.GetLogger("TraceLoggerTests");            
            log.WarnFormat("info {0}", "arg");
            Assert.AreEqual(TraceEventType.Warning, CapturingTraceListener.Events[0].EventType);
            Assert.AreEqual("[WARN]  TraceLoggerTests - info arg", CapturingTraceListener.Events[0].FormattedMessage);
        }
开发者ID:Rocketmakers,项目名称:common-logging,代码行数:30,代码来源:TraceLoggerTests.cs

示例8: UnityDebugLoggerFactoryAdapter

 public UnityDebugLoggerFactoryAdapter(NameValueCollection properties)
 {
     _level = ArgUtils.TryParseEnum(LogLevel.All, ArgUtils.GetValue(properties, "level"));
     _showLogName = ArgUtils.TryParse(true, ArgUtils.GetValue(properties, "showLogName"));
     _showLogLevel = ArgUtils.TryParse(true, ArgUtils.GetValue(properties, "showLogLevel"));
     _useUnityLogLevel = ArgUtils.TryParse(true, ArgUtils.GetValue(properties, "useUnityLogLevel"));
 }
开发者ID:SaladLab,项目名称:Common.Logging.Unity3D,代码行数:7,代码来源:UnityDebugLoggerFactoryAdapter.cs

示例9: ParseQueryString

        public static NameValueCollection ParseQueryString(string Query)
        {
            string query = null;
            var collection = new NameValueCollection();

            if (string.IsNullOrEmpty(Query))
                return new NameValueCollection();

            if (Query.Length > 0 && Query[0] == '?')
                query = Query.Substring(1);
            else
                query = Query;

            string[] items = query.Split('&');

            foreach (var item in items)
            {
                var pair = item.Split('=');

                if (pair.Length > 1)
                    collection.Add(pair[0], pair[1]);
                else
                    collection.Add(pair[0], string.Empty);
            }

            return collection;
        }
开发者ID:regionbbs,项目名称:EasyOAuth,代码行数:27,代码来源:Utils.cs

示例10: fredTries

	private void fredTries()
	{
		try
		{
			using (var client = new WebClient())
			{
				var values = new NameValueCollection(); //key and value mapping
				values["user_name"] = "chupacabra";
				values["user_email"] = @"[email protected]";
				values["user_password_new"] = "omnomnom";
				var response = client.UploadValues("http://tral-ee.lo5.org/requestHandler.php", values); //google responds with error here...expected....same thing in postman
				var responseString = Encoding.Default.GetString(response);
				Debug.Log(responseString);
			}
		}
		catch (System.InvalidOperationException e)
		{
			if (e is WebException)
			{
				Debug.Log(e.Message);
				//Debug.Log (e.StackTrace);
				Debug.Log(e.GetBaseException());
			}
		}
	}
开发者ID:FredLandis,项目名称:TrolleyProblemGameCode,代码行数:25,代码来源:postRequestTest.cs

示例11: Initialize

    /// <summary>
    /// Initialize the session state provider
    /// </summary>
    public override void Initialize(string name, NameValueCollection config)
    {
        
        if (config == null)
            throw new ArgumentNullException("config");

        if (name == null || name.Length == 0)
            name = "SqlSessionStateProvider";

        if (String.IsNullOrEmpty(config["description"]))
        {
            config.Remove("description");
            config.Add("description", "Sql session state provider");
        }

        // Initialize the abstract base class.
        base.Initialize(name, config);

        // Set the application name
        this.applicationName = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath;

        // Get the session state configuration
        Configuration cfg = WebConfigurationManager.OpenWebConfiguration(this.applicationName);
        sessionStateConfiguration = (SessionStateSection)cfg.GetSection("system.web/sessionState");

    } // End of the Initialize method
开发者ID:raphaelivo,项目名称:a-webshop,代码行数:29,代码来源:SqlSessionStateProvider.cs

示例12: 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:timw255,项目名称:Sitefinity-STS-Modification,代码行数:29,代码来源:SimpleWebTokenHandler.cs

示例13: ConfigureCommonLogging

 static void ConfigureCommonLogging()
 {
     var nameValueCollection = new NameValueCollection();
     var nlogAdapter = new NLogLoggerFactoryAdapter(nameValueCollection);
     Common.Logging.LogManager.Adapter = nlogAdapter;
     LoggingPcl::Common.Logging.LogManager.Adapter = nlogAdapter;
 }
开发者ID:vbfox,项目名称:U2FExperiments,代码行数:7,代码来源:Program.cs

示例14: bt_AddApply_Click

    protected void bt_AddApply_Click(object sender, EventArgs e)
    {
        bt_OK_Click(null, null);
        if ((int)ViewState["ClientID"] == 0)
        {
            MessageBox.Show(this, "对不起,请您先保存后在发起申请");
            return;
        }

        CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]);

        NameValueCollection dataobjects = new NameValueCollection();
        dataobjects.Add("ID", ViewState["ClientID"].ToString());
        dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
        dataobjects.Add("ClientName", bll.Model.FullName.ToString());
        dataobjects.Add("OperateClassify", bll.Model["OperateClassify"]);
        dataobjects.Add("DIClassify", bll.Model["DIClassify"]);

        int TaskID = EWF_TaskBLL.NewTask("Add_Distributor", (int)Session["UserID"], "新增经销商流程,经销商名称:" + bll.Model.FullName, "~/SubModule/CM/DI/DistributorDetail.aspx?ClientID=" + ViewState["ClientID"].ToString(), dataobjects);
        if (TaskID > 0)
        {
            bll.Model["TaskID"] = TaskID.ToString();
            bll.Model["State"] = "2";
            bll.Update();
            //new EWF_TaskBLL(TaskID).Start();        //直接启动流程
        }

        Response.Redirect("~/SubModule/EWF/Apply.aspx?TaskID=" + TaskID.ToString());
    }
开发者ID:fuhongliang,项目名称:GraduateProject,代码行数:29,代码来源:DistributorDetail.aspx.cs

示例15: HandleCallbackRequest

 protected override void HandleCallbackRequest(NameValueCollection request, String callbackUrl)
 {
     // the code below was never tested
     if (request["error"] != null)
     {
         throw new Exception("OAuth provider returned an error: " + request["error"]);
     }
     String state = request["state"];
     if (state != null && state != (String)HttpContext.Current.Session[Oauth2RequestStateSessionkey])
     {
         throw new Exception("Invalid OAuth State - did not match the one passed to provider");
     }
     String accessToken = request["code"];
     // usually either RequiresAccessToken, or RequiresRefreshToken, will be set.
     if (provider.RequiresRefreshToken.GetValueOrDefault())
     {
         string refreshToken = GetAccessToken(accessToken, provider.Host + provider.RefreshTokenUrl, provider.RefreshTokenData, callbackUrl).refresh_token;
         SaveAccessToken(null, refreshToken, null);
     }
     else if (provider.RequiresAccessToken.GetValueOrDefault())
     {
         TokenResponse token = GetAccessToken(accessToken, provider.Host + provider.AccessTokenUrl, provider.AccessTokenData, callbackUrl);
         accessToken = token.access_token;
         SaveAccessToken(null, accessToken, null, (token.expires_in == 0) ? (DateTime?)null : DateTime.UtcNow.AddSeconds(token.expires_in));
     }
     else
     {
         throw new ValidationException("Either Refresh Token or Access Token url must be provided");
     }
 }
开发者ID:ssommerfeldt,项目名称:TAC_EAB,代码行数:30,代码来源:OAuth2AuthorizationServiceViewController.cs


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