コード例 #1
0
ファイル: RetryOptions.cs プロジェクト: kouweizhong/relib
        public RetryOptions(string options, string prefix)
        {
            var items = StringHelper.ParseOptions(options);

            MaxRetryCount = NameValueCollectionHelper.ConvertToInt32(items, String.Concat(prefix, " max retry count").TrimStart(), 0);
            RetryTimeout  = NameValueCollectionHelper.ConvertToInt32(items, String.Concat(prefix, " retry timeout").TrimStart(), 0);
            RetryDelay    = NameValueCollectionHelper.ConvertToInt32(items, String.Concat(prefix, " retry delay").TrimStart(), 0);
            RetryFails    = NameValueCollectionHelper.ConvertToBoolean(items, String.Concat(prefix, " retry fails").TrimStart(), false);
        }
コード例 #2
0
        public ProtocolOptions(string options)
        {
            var items = StringHelper.ParseOptions(options);

            BufferSize        = NameValueCollectionHelper.ConvertToInt32(items, "buffer size", 1024);
            NoReply           = NameValueCollectionHelper.ConvertToBoolean(items, "no reply", false);
            PoolAccessTimeout = NameValueCollectionHelper.ConvertToInt32(items, "pool access timeout", 100);
            MaxPoolSize       = NameValueCollectionHelper.ConvertToInt32(items, "max pool size", 16);
        }
コード例 #3
0
        public static void ConvertToBoolean()
        {
            // Arrange
            var collection = new NameValueCollection();

            collection.Add("x", "true");

            // Act
            var result = NameValueCollectionHelper.ConvertToBoolean(collection, "x");

            // Assert
            Assert.Equal(true, result);
        }
コード例 #4
0
        public static void ConvertToBoolean_Required(string value)
        {
            // Arrange
            var collection = new NameValueCollection();

            collection.Add("x", value);

            // Act
            Assert.Throws <ArgumentException>(() =>
                                              NameValueCollectionHelper.ConvertToBoolean(collection, "x"));

            // Assert
        }
コード例 #5
0
 public CaptchaInstrumentationProvider(CaptchaOptions options)
     : this(options.Items[CaptchaOptionNames.InstrumentationCategory] ?? CaptchaOptionDefaults.InstrumentationCategory,
            options.Items[CaptchaOptionNames.InstrumentationInstanceNameSuffix] ?? options.Path,
            NameValueCollectionHelper.ConvertToBoolean(options.Items, CaptchaOptionNames.InstrumentationEnabled, CaptchaOptionDefaults.InstrumentationEnabled))
 {
 }
コード例 #6
0
 public static bool ConvertToBoolean(this NameValueCollection collection, string paramName, bool defaultValue)
 {
     return(NameValueCollectionHelper.ConvertToBoolean(collection, paramName, defaultValue));
 }