本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.GetValue方法的具体用法?C# NameValueCollection.GetValue怎么用?C# NameValueCollection.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.GetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log4NetLoggerFactoryAdapter
/// <summary>
/// Constructor accepting configuration properties and an arbitrary
/// <see cref="ILog4NetRuntime"/> instance.
/// </summary>
/// <param name="properties">configuration properties, see <see cref="Log4NetLoggerFactoryAdapter"/> for more.</param>
/// <param name="runtime">a log4net runtime adapter</param>
protected Log4NetLoggerFactoryAdapter(NameValueCollection properties, ILog4NetRuntime runtime)
: base(true)
{
if (runtime == null)
{
throw new ArgumentNullException("runtime");
}
_runtime = runtime;
// parse config properties
var configType = properties.GetValue("configType", string.Empty).ToUpper();
var configFile = properties.GetValue("configFile", string.Empty);
// app-relative path?
if (configFile.StartsWith("~/") || configFile.StartsWith("~\\"))
{
configFile = string.Format("{0}/{1}", AppDomain.CurrentDomain.BaseDirectory.TrimEnd('/', '\\'), configFile.Substring(2));
}
if (configType == "FILE" || configType == "FILE-WATCH")
{
if (configFile == string.Empty)
{
throw new ConfigurationException("Configuration property 'configFile' must be set for log4Net configuration of type 'FILE' or 'FILE-WATCH'.");
}
if (!File.Exists(configFile))
{
throw new ConfigurationException("log4net configuration file '" + configFile + "' does not exists");
}
}
switch (configType)
{
case "INLINE":
_runtime.XmlConfiguratorConfigure();
break;
case "FILE":
_runtime.XmlConfiguratorConfigure(configFile);
break;
case "FILE-WATCH":
_runtime.XmlConfiguratorConfigureAndWatch(configFile);
break;
case "EXTERNAL":
// Log4net will be configured outside of Common.Logging
break;
default:
_runtime.BasicConfiguratorConfigure();
break;
}
}
示例2: Initialize
public bool Initialize(NameValueCollection options)
{
if (long.TryParse(options.GetValue("maxMemoryUsage"), out m_MaxMemoryUsage) || m_MaxMemoryUsage <= 0)
return false;
return true;
}
示例3: Initialize
public bool Initialize(NameValueCollection options)
{
var checkInterval = 0;
if (!int.TryParse(options.GetValue("checkInterval", "5"), out checkInterval))
return false;
m_CheckInterval = checkInterval;
var restartDelay = 0;
if (!int.TryParse(options.GetValue("restartDelay", "1"), out restartDelay))
return false;
m_RestartRelay = restartDelay;
return true;
}
示例4: Initialize
public bool Initialize(string name, NameValueCollection options)
{
Name = name;
var ipRange = options.GetValue("ipRange");
string[] ipRangeArray;
if (string.IsNullOrEmpty(ipRange)
|| (ipRangeArray = ipRange.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)).Length <= 0)
{
throw new ArgumentException("The ipRange doesn't exist in configuration!");
}
m_IpRanges = new Tuple<long, long>[ipRangeArray.Length];
for (int i = 0; i < ipRangeArray.Length; i++)
{
var range = ipRangeArray[i];
m_IpRanges[i] = GenerateIpRange(range);
}
return true;
}
示例5: can_get_value_without_default_from_namevaluecollection
public void can_get_value_without_default_from_namevaluecollection()
{
var collection = new NameValueCollection { { "question", "what is it" } };
var value = collection.GetValue<string>("question");
Expect(value, Is.EqualTo("what is it"));
}
示例6: Initialize
/// <summary>
/// Initializes the provider.
/// </summary>
/// <param name="name">The friendly name of the provider.</param>
/// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
/// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
/// <exception cref="T:System.InvalidOperationException">An attempt is made to call
/// <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider
/// has already been initialized.</exception>
/// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
public override void Initialize(string name, NameValueCollection config)
{
// Initialize base provider class
base.Initialize(name, config);
_enablePasswordRetrieval = config.GetValue("enablePasswordRetrieval", false);
_enablePasswordReset = config.GetValue("enablePasswordReset", false);
_requiresQuestionAndAnswer = config.GetValue("requiresQuestionAndAnswer", false);
_requiresUniqueEmail = config.GetValue("requiresUniqueEmail", false);
_maxInvalidPasswordAttempts = GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0);
_passwordAttemptWindow = GetIntValue(config, "passwordAttemptWindow", 10, false, 0);
_minRequiredPasswordLength = GetIntValue(config, "minRequiredPasswordLength", DefaultMinPasswordLength, true, 0x80);
_minRequiredNonAlphanumericCharacters = GetIntValue(config, "minRequiredNonalphanumericCharacters", DefaultMinNonAlphanumericChars, true, 0x80);
_passwordStrengthRegularExpression = config["passwordStrengthRegularExpression"];
_applicationName = config["applicationName"];
if (string.IsNullOrEmpty(_applicationName))
_applicationName = GetDefaultAppName();
//by default we will continue using the legacy encoding.
_useLegacyEncoding = config.GetValue("useLegacyEncoding", DefaultUseLegacyEncoding);
// make sure password format is clear by default.
string str = config["passwordFormat"] ?? "Clear";
switch (str.ToLower())
{
case "clear":
_passwordFormat = MembershipPasswordFormat.Clear;
break;
case "encrypted":
_passwordFormat = MembershipPasswordFormat.Encrypted;
break;
case "hashed":
_passwordFormat = MembershipPasswordFormat.Hashed;
break;
default:
throw new ProviderException("Provider bad password format");
}
if ((PasswordFormat == MembershipPasswordFormat.Hashed) && EnablePasswordRetrieval)
throw new ProviderException("Provider can not retrieve hashed password");
}