本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.GetInteger方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.GetInteger方法的具体用法?C# NameValueCollection.GetInteger怎么用?C# NameValueCollection.GetInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.GetInteger方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GivenCollectionWithKeyAsIntegerWhenGetIntegerThenReturnValue
public void GivenCollectionWithKeyAsIntegerWhenGetIntegerThenReturnValue()
{
// arrange
var testClass = new NameValueCollection { { TestKey, "9" } };
// act
var result = testClass.GetInteger(TestKey, 3);
// assert
Assert.That(result, Is.EqualTo(9));
}
示例2: GivenCollectionWithKeyAsEmtpyStringWhenGetIntegerThenReturnDefault
public void GivenCollectionWithKeyAsEmtpyStringWhenGetIntegerThenReturnDefault()
{
// arrange
var testClass = new NameValueCollection { { TestKey, string.Empty } };
// act
var result = testClass.GetInteger(TestKey, 3);
// assert
Assert.That(result, Is.EqualTo(3));
}
示例3: Initialize
public override void Initialize(string name, NameValueCollection config)
{
Condition.Requires(name, "name").IsNotNullOrWhiteSpace();
Condition.Requires(config, "config").IsNotNull();
if (config.ContainsKey("requiresQuestionAndAnswer"))
{
throw new ProviderException("unrecognized attribute requiresQuestionAndAnswer");
}
if (config.ContainsKey("enablePasswordRetrieval"))
{
throw new ProviderException("unrecognized attribute enablePasswordRetrieval");
}
if (config.ContainsKey("enablePasswordReset"))
{
throw new ProviderException("unrecognized attribute enablePasswordReset");
}
if (config.ContainsKey("passwordFormat"))
{
throw new ProviderException("unrecognized attribute passwordFormat");
}
this.connectionStringName = config.GetString("connectionStringName", "DefaultConnection");
this.userTableName = config.GetString("userTableName", "UserProfile");
this.userIdColumn = config.GetString("userIdColumn", "UserId");
this.userNameColumn = config.GetString("userNameColumn", "UserName");
this.userEmailColumn = config.GetString("userEmailColumn");
this.autoCreateTables = config.GetBoolean("autoCreateTables", true);
this.autoInitialize = config.GetBoolean("autoInitialize", true);
this.maxInvalidPasswordAttempts = config.GetInteger("maxInvalidPasswordAttempts", int.MaxValue);
this.minRequiredNonalphanumericCharacters = config.GetInteger("minRequiredNonalphanumericCharacters");
this.minRequiredPasswordLength = config.GetInteger("minRequiredPasswordLength", 1);
this.requiresUniqueEmail = config.GetBoolean("requiresUniqueEmail");
this.maxEmailLength = config.GetInteger("maxEmailLength", 254);
this.maxUserNameLength = config.GetInteger("maxUserNameLength", 56);
this.maxPasswordLength = config.GetInteger("maxPasswordLength", 128);
this.emailStrengthRegularExpression = config.GetString(
"emailStrengthRegularExpression", @"^[0-9a-zA-Z.+_-][email protected][0-9a-zA-Z.+_-]+\.[a-zA-Z]{2,4}$");
this.userNameRegularExpression = config.GetString("userNameRegularExpression", @"^[0-9a-zA-Z_-]+$");
this.ApplicationName = config.GetString("applicationName", "/");
this.allowEmailAsUserName = config.GetBoolean("allowEmailAsUserName", true);
try
{
new Regex(this.emailStrengthRegularExpression);
}
catch (ArgumentException e)
{
throw new ProviderException("invalid value for emailStrengthRegularExpression", e);
}
try
{
new Regex(this.userNameRegularExpression);
}
catch (ArgumentException e)
{
throw new ProviderException("invalid value for userNameRegularExpression", e);
}
if (config.ContainsKey("passwordAttemptWindowInSeconds") && config.ContainsKey("passwordAttemptWindow"))
{
throw new ProviderException(
"passwordAttemptWindowInSeconds and passwordAttemptWindow cannot both be set");
}
if (config.ContainsKey("passwordAttemptWindowInSeconds"))
{
this.passwordAttemptWindowInSeconds = config.GetInteger("passwordAttemptWindowInSeconds", int.MaxValue);
}
else
{
var passwordAttemptWindowInMinutes = config.GetInteger("passwordAttemptWindow", -1);
if (passwordAttemptWindowInMinutes < 0)
{
this.passwordAttemptWindowInSeconds = int.MaxValue;
}
else
{
this.passwordAttemptWindowInSeconds = passwordAttemptWindowInMinutes * 60;
}
}
if (this.requiresUniqueEmail && !this.HasEmailColumnDefined)
{
throw new ProviderException("requiresUniqueEmail cannot be defined without userEmailColumn");
}
config.Remove("userTableName");
config.Remove("userIdColumn");
config.Remove("userNameColumn");
config.Remove("userEmailColumn");
config.Remove("autoCreateTables");
config.Remove("autoInitialize");
config.Remove("passwordAttemptWindow");
config.Remove("passwordAttemptWindowInSeconds");
config.Remove("maxEmailLength");
//.........这里部分代码省略.........
示例4: GivenCollectionWithKeyAsNotIntegerAndNoDefaulWhenGetIntegerThenReturnZero
public void GivenCollectionWithKeyAsNotIntegerAndNoDefaulWhenGetIntegerThenReturnZero()
{
// arrange
var testClass = new NameValueCollection { { TestKey, "xx" } };
// act
var result = testClass.GetInteger(TestKey);
// assert
Assert.That(result, Is.EqualTo(0));
}