本文整理汇总了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;
}
示例2: TableUrlManager
public TableUrlManager(string actionUrl, TableRequestModel requestModel, NameValueCollection routeValues)
{
_actionUrl = actionUrl;
_urlParams = routeValues.Merge(requestModel);
}
示例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;
}