本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.ContainsKey方法的具体用法?C# NameValueCollection.ContainsKey怎么用?C# NameValueCollection.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.ContainsKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
//.........这里部分代码省略.........
示例2: CheckCompany
protected string CheckCompany(DataHelper data, NameValueCollection nvc)
{
if (nvc.ContainsKey(Constants.Csource) && nvc[Constants.Csource] == Constants.CSrcCm)
{
if (!nvc.ContainsKey(Constants.Ccompany))
throw new ExtendedException("Company is missing", (int)Constants.EError.CompanyMissing);
if (!data.CheckCompany(nvc[Constants.Ccompany]))
throw new ExtendedException(String.Format("Company code [{0}] is unknown", nvc[Constants.Ccompany]), (int)Constants.EError.CompanyUnknown);
return nvc[Constants.Ccompany];
}
return null;
}
示例3: CheckEvent
protected Constants.EEvent CheckEvent(NameValueCollection nvc, bool init, Boolean? confirmed)
{
if (!nvc.ContainsKey(Constants.Cevent))
if (confirmed == null)
throw new ValidationException("Event is missing");
int eventId = (int)Constants.EEvent.NoEvent;
if (!Int32.TryParse(nvc[Constants.Cevent], out eventId))
if (confirmed == null)
throw new ValidationException(String.Format("EventId [{0}] is unknown", nvc[Constants.Cevent]));
return (Constants.EEvent)eventId;
}
示例4: CheckSn
protected int CheckSn(DataHelper data, NameValueCollection nvc)
{
if (!nvc.ContainsKey(Constants.Csn))
throw new ExtendedException("SN is missing", (int)Constants.EError.SNMissing);
int deviceCode = -1;
if (!Int32.TryParse(nvc[Constants.Csn], out deviceCode))
throw new ExtendedException(String.Format("SN [{0}] is invalid", nvc[Constants.Csn]), (int)Constants.EError.SNInvalid);
if (!data.CheckSn(deviceCode))
throw new ExtendedException(String.Format("SN [{0}] is unknown", nvc[Constants.Csn]), (int)Constants.EError.SNUnknown);
return deviceCode;
}
示例5: GivenCollectionWithoutKeyWhenContainsKeyThenReturnFalse
public void GivenCollectionWithoutKeyWhenContainsKeyThenReturnFalse()
{
// arrange
var testClass = new NameValueCollection();
// act
var result = testClass.ContainsKey(TestKey);
// assert
Assert.That(result, Is.False);
}
示例6: GivenCollectionWithKeyWhenContainsKeyThenReturnTrue
public void GivenCollectionWithKeyWhenContainsKeyThenReturnTrue()
{
// arrange
var testClass = new NameValueCollection { { TestKey, "value" } };
// act
var result = testClass.ContainsKey(TestKey);
// assert
Assert.That(result, Is.True);
}