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


C# NameValueCollection.GetValue方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:bobpace,项目名称:FileHelperHeaders,代码行数:57,代码来源:Log4NetLoggerFactoryAdapter.cs

示例2: Initialize

        public bool Initialize(NameValueCollection options)
        {
            if (long.TryParse(options.GetValue("maxMemoryUsage"), out m_MaxMemoryUsage) || m_MaxMemoryUsage <= 0)
                return false;

            return true;
        }
开发者ID:Nokecy,项目名称:NDock,代码行数:7,代码来源:MemoryRecycleTrigger.cs

示例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;
        }
开发者ID:weitaoxiao,项目名称:NDock,代码行数:18,代码来源:AssemblyUpdatedRecycleTrigger.cs

示例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;
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:24,代码来源:IPConnectionFilter.cs

示例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"));
        }
开发者ID:rut5949,项目名称:Dnn.Platform,代码行数:8,代码来源:CollectionExtensionTests.cs

示例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");

        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:57,代码来源:MembershipProviderBase.cs


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