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); }
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); }
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); }
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 }
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)) { }
public static bool ConvertToBoolean(this NameValueCollection collection, string paramName, bool defaultValue) { return(NameValueCollectionHelper.ConvertToBoolean(collection, paramName, defaultValue)); }