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


C# NameValueCollection.GetInteger方法代码示例

本文整理汇总了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));
        }
开发者ID:TheCodeKing,项目名称:BetterMembership.Net,代码行数:11,代码来源:NameValueCollectionExtensionTests.cs

示例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));
        }
开发者ID:TheCodeKing,项目名称:BetterMembership.Net,代码行数:11,代码来源:NameValueCollectionExtensionTests.cs

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

示例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));
        }
开发者ID:TheCodeKing,项目名称:BetterMembership.Net,代码行数:11,代码来源:NameValueCollectionExtensionTests.cs


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