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


C# NameValueCollection.Merge方法代码示例

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


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

示例1: BindModel

    /// <summary>
    /// bindig logic
    /// </summary>
    /// <param name="controllerContext"></param>
    /// <param name="bindingContext"></param>
    /// <returns>converted object</returns>
    public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
    {
      NameValueCollection RequestParameters = new NameValueCollection();

      //get parameters from RoutData
      RequestParameters = controllerContext.RouteData.Values.ToNameValueCollection();


      //MErge parameters RoutData with GET || Post parameters
      if (controllerContext.HttpContext.Request.HttpMethod == "POST")
      {
        RequestParameters = RequestParameters.Merge(controllerContext.HttpContext.Request.Form);
      }
      else if (controllerContext.HttpContext.Request.HttpMethod == "GET")
      {
        RequestParameters = RequestParameters.Merge(controllerContext.HttpContext.Request.QueryString);
      }

      //Do binding
      bindingContext = tryToSetValues(RequestParameters, bindingContext);
      ValidateModel(bindingContext);
      return bindingContext.ModelMetadata.Model;
    }
开发者ID:clpereira2001,项目名称:Lelands-Master,代码行数:29,代码来源:CustomItemBinder.cs

示例2: TableUrlManager

 public TableUrlManager(string actionUrl, TableRequestModel requestModel, NameValueCollection routeValues)
 {
     _actionUrl = actionUrl;
     _urlParams = routeValues.Merge(requestModel);
 }
开发者ID:gregemes,项目名称:MvcTables,代码行数:5,代码来源:TableUrlManager.cs

示例3: GetSection

        public object GetSection(string configKey)
        {
            if (configKey == "appSettings")
            {
                if (_appSettings != null)
                    return _appSettings;
            }
            else if (configKey == "connectionStrings")
            {
                if (_connectionStrings != null)
                    return _connectionStrings;
            }


            // get the section from the default location (web.config or app.config)
            object section = _clientConfigSystem.GetSection(configKey);
            

            switch (configKey)
            {
                case "appSettings":
                    if (section is NameValueCollection)
                    {
                        // create a new collection because the underlying collection is read-only
                        var cfg = new NameValueCollection((NameValueCollection)section);
                        _appSettings = cfg;
                        
                        // merge the settings from core with the local appsettings
                        _appSettings = cfg.Merge(System.Configuration.ConfigurationManager.AppSettings);
                        section = _appSettings;
                    }
                    break;

                case "connectionStrings":
                    // Cannot simply return our ConnectionStringSettingsCollection as the calling routine expects a ConnectionStringsSection result
                    ConnectionStringsSection connectionStringsSection = new ConnectionStringsSection();
                    _connectionStrings = connectionStringsSection;

                    // create a new collection because the underlying collection is read-only
                    var cssc = new ConnectionStringSettingsCollection();

                    // copy the existing connection strings into the new collection
                    foreach (ConnectionStringSettings connectionStringSetting in ((ConnectionStringsSection)section).ConnectionStrings)
                    {
                        cssc.Add(connectionStringSetting);
                    }

                    //// merge the settings from core with the local connectionStrings
                    cssc = cssc.Merge(System.Configuration.ConfigurationManager.ConnectionStrings);
                    
                    // Add our merged connection strings to the new ConnectionStringsSection
                    foreach (ConnectionStringSettings connectionStringSetting in cssc)
                    {
                        connectionStringsSection.ConnectionStrings.Add(connectionStringSetting);
                    }

                    _connectionStrings = connectionStringsSection;
                    section = _connectionStrings;
                    break;
            }

            return section;
        }
开发者ID:LazyTarget,项目名称:Lux,代码行数:63,代码来源:ConfigSystemProxy.cs


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