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


C# NameValueCollection.GetBoolean方法代码示例

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


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

示例1: GetBooleanTest

        public void GetBooleanTest()
        {
            NameValueCollection collection = new NameValueCollection();
            collection.Add("True", Boolean.TrueString);
            collection.Add("False", Boolean.FalseString);

            Assert.IsTrue(collection.GetBoolean("True"));
            Assert.IsFalse(collection.GetBoolean("False"));
            Assert.IsFalse(collection.GetBoolean("DoesNotExist"));
        }
开发者ID:SolidSnake74,项目名称:SharpCore,代码行数:10,代码来源:NameValueCollectionExtensionsUnitTest.cs

示例2: GetBoolean_WithInvalidValueForKey_ReturnsFalse

        public void GetBoolean_WithInvalidValueForKey_ReturnsFalse()
        {
            // arrange
            var collection = new NameValueCollection {{"Key", "blah"}};

            // act
            var result = collection.GetBoolean("Key");

            // assert
            Assert.IsFalse(result);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:11,代码来源:CollectionExtensionsTests.cs

示例3: GivenCollectionWithKeyAsNotBooleanWhenGetBooleanThenReturnDefault

        public void GivenCollectionWithKeyAsNotBooleanWhenGetBooleanThenReturnDefault()
        {
            // arrange
            var testClass = new NameValueCollection { { TestKey, "xx" } };

            // act
            var result = testClass.GetBoolean(TestKey, true);

            // assert
            Assert.That(result, Is.True);
        }
开发者ID:TheCodeKing,项目名称:BetterMembership.Net,代码行数:11,代码来源:NameValueCollectionExtensionTests.cs

示例4: GravatarService

 public GravatarService(NameValueCollection settings)
     : this(settings["GravatarUrlFormatString"], settings.GetBoolean("GravatarEnabled"))
 {
 }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:4,代码来源:GravatarService.cs

示例5: 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");
//.........这里部分代码省略.........
开发者ID:TheCodeKing,项目名称:BetterMembership.Net,代码行数:101,代码来源:BetterMembershipProvider.cs

示例6: GetBoolean_WithNameValueCollectionHavingCorrespondingValue_ReturnsBoolean

        public void GetBoolean_WithNameValueCollectionHavingCorrespondingValue_ReturnsBoolean()
        {
            // arrange
            var collection = new NameValueCollection {{"Key", "true"}};

            // act
            var result = collection.GetBoolean("Key");

            // assert
            Assert.IsTrue(result);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:11,代码来源:CollectionExtensionsTests.cs


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