• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NameValueCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Main

	static void Main(string[] args)
	{
		try
		{
			NameValueCollection AppSettings = ConfigurationManager.AppSettings;
			Configuration config = ConfigurationManager.OpenExeConfiguration (ConfigurationUserLevel.None);
			AppSettingsSection appsettings = config.AppSettings;

			try {
				AppSettings.Add ("fromtest", "valuehere");
			}
			catch {
				Console.WriteLine ("ConfigurationManager.AppSettings.Add resulted in exception");
			}

			AppSettings = new NameValueCollection (AppSettings);
			foreach (string key in AppSettings.AllKeys) {
				Console.WriteLine ("AppSettings[{0}] = {1}", key, AppSettings[key]);
			}

			foreach (string key in appsettings.Settings.AllKeys) {
				Console.WriteLine ("settings[{0}] = {1}", appsettings.Settings[key].Key, appsettings.Settings[key].Value);
			}
		}
		catch (Exception e)
		{
			// Error.
			Console.WriteLine(e.ToString());
		}
	}
开发者ID:nlhepler,项目名称:mono,代码行数:30,代码来源:t8.cs


示例17: EventSourceLoggerFactoryAdapter

         /// <summary>
 /// Initializes a new instance of the <see cref="EventSourceLoggerFactoryAdapter"/> class.
 /// </summary>
 /// <param name="properties">The properties.</param>
 public EventSourceLoggerFactoryAdapter(NameValueCollection properties)
 {
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
 }
开发者ID:nobitagamer,项目名称:Common.Logging.EventSource,代码行数:11,代码来源:EventSourceLoggerFactoryAdapter.cs


示例18: QuartzDatastore

    /// <summary>
    /// Quartz Job Scheduler - ServerScheduler
    /// </summary>
    public QuartzDatastore()
    {
        NameValueCollection properties = new NameValueCollection();
        properties["quartz.scheduler.instanceName"] = "ServerScheduler";

        // set thread pool info
        properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
        properties["quartz.threadPool.threadCount"] = "5";
        properties["quartz.threadPool.threadPriority"] = "Normal";

        // set remoting expoter
        properties["quartz.scheduler.proxy"] = "true";
        properties["quartz.scheduler.proxy.address"] = "tcp://localhost:555/QuartzScheduler";
        // First we must get a reference to a scheduler
        ISchedulerFactory sf = new StdSchedulerFactory(properties);

        //Any schedulers?
        if (sf.AllSchedulers.Count() == 0)
        {
            this.Scheduler = sf.GetScheduler();
        }
        else {
            this.Scheduler = sf.AllSchedulers.First();
        }

        //Load jobs from Scheduler
        GetAllJobs();
    }
开发者ID:ragingsmurf,项目名称:myLegis,代码行数:31,代码来源:QuartzDataStore.cs


示例19: InitLogging

        private static void InitLogging()
        {
            var properties = new NameValueCollection();
            properties["showDateTime"] = "true";

            Common.Logging.LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(properties);
        }
开发者ID:pankhuri3,项目名称:vector370-dotnet,代码行数:7,代码来源:Program.cs


示例20: RedirectAndPOST

 /// <summary>
 /// POST data and Redirect to the specified url using the specified page.
 /// </summary>
 /// <param name="page">The page which will be the referrer page.</param>
 /// <param name="destinationUrl">The destination Url to which the post and redirection is occuring.</param>
 /// <param name="data">The data should be posted.</param>
 /// <Author>Samer Abu Rabie</Author>
 public static void RedirectAndPOST(Page page, string destinationUrl, NameValueCollection data)
 {
     //Prepare the Posting form
         string strForm = PreparePOSTForm(destinationUrl, data);
         //Add a literal control the specified page holding the Post Form, this is to submit the Posting form with the request.
         page.Controls.Add(new LiteralControl(strForm));
 }
开发者ID:nmduy3984,项目名称:SanNhua,代码行数:14,代码来源:HttpHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NamedArgumentExpression类代码示例发布时间:2022-05-24
下一篇:
C# NameContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap