Ejemplo n.º 1
0
        public CaptchaOptions(string options)
        {
            var items = StringHelper.ParseOptions(options);

            Path = items[CaptchaOptionNames.Path] ?? CaptchaOptionDefaults.Path;

            MinTimeout = TimeSpan.FromSeconds(NameValueCollectionHelper.ConvertToInt32(items,
                                                                                       CaptchaOptionNames.MinTimeout, CaptchaOptionDefaults.MinTimeout));
            MaxTimeout = TimeSpan.FromSeconds(NameValueCollectionHelper.ConvertToInt32(items,
                                                                                       CaptchaOptionNames.MaxTimeout, CaptchaOptionDefaults.MaxTimeout));

            VaryByCacheLifetime = TimeSpan.FromSeconds(NameValueCollectionHelper.ConvertToInt32(items,
                                                                                                CaptchaOptionNames.VaryByCacheLifetime, CaptchaOptionDefaults.VaryByCacheLifetime));

            ChallengeQueryKey = items[CaptchaOptionNames.ChallengeQueryKey]
                                ?? CaptchaOptionDefaults.ChallengeQueryKey;
            ValidationStateKey = items[CaptchaOptionNames.ValidationStateKey]
                                 ?? CaptchaOptionDefaults.ValidationStateKey;

            Width = NameValueCollectionHelper.ConvertToInt32(items,
                                                             CaptchaOptionNames.Width, CaptchaOptionDefaults.Width);
            Height = NameValueCollectionHelper.ConvertToInt32(items,
                                                              CaptchaOptionNames.Height, CaptchaOptionDefaults.Height);

            Items = items;
        }
Ejemplo n.º 2
0
        public DefaultTuringNumberProvider(CaptchaOptions options)
        {
            var items = options.Items;

            m_characterGroup = items[CaptchaOptionNames.Chars] ?? CaptchaOptionDefaults.Chars;
            m_max            = NameValueCollectionHelper.ConvertToInt32(items, CaptchaOptionNames.MaxChars, CaptchaOptionDefaults.MaxChars);
            m_min            = NameValueCollectionHelper.ConvertToInt32(items, CaptchaOptionNames.MinChars, m_max);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        public SymmetricAlgorithmOptions(string options)
        {
            var items = StringHelper.ParseOptions(options);

            Name              = items["name"] ?? "Default";
            MaxPoolSize       = NameValueCollectionHelper.ConvertToInt32(items, "max pool size", 16);
            PoolAccessTimeout = NameValueCollectionHelper.ConvertToInt32(items, "pool access timeout", 100);
            PoolWaitTimeout   = NameValueCollectionHelper.ConvertToInt32(items, "pool wait timeout", 250);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public DistributedOptions(string options)
        {
            var items = StringHelper.ParseOptions(options);

            ClientAccessTimeout = NameValueCollectionHelper.ConvertToInt32(items, "client access timeout", 100);
            IdlePoolSize        = NameValueCollectionHelper.ConvertToInt32(items, "idle pool size", 16);
            IdleLeaseTime       = NameValueCollectionHelper.ConvertToInt32(items, "idle lease time", 10 * 1000);
            IdleAccessTimeout   = NameValueCollectionHelper.ConvertToInt32(items, "idle access timeout", 100);
        }
Ejemplo n.º 7
0
        public ConnectionOptions(string options)
        {
            var items = StringHelper.ParseOptions(options);

            Name              = items["name"] ?? "Default";
            Server            = items["server"] ?? IpNumberHelper.Localhost;
            Port              = NameValueCollectionHelper.ConvertToInt32(items, "port");
            DnsTimeout        = NameValueCollectionHelper.ConvertToInt32(items, "dns timeout", 250);
            ConnectTimeout    = NameValueCollectionHelper.ConvertToInt32(items, "connect timeout", 250);
            SendTimeout       = NameValueCollectionHelper.ConvertToInt32(items, "send timeout", 250);
            SendBufferSize    = NameValueCollectionHelper.ConvertToInt32(items, "send buffer size", 8 * 1024);
            ReceiveTimeout    = NameValueCollectionHelper.ConvertToInt32(items, "receive timeout", 250);
            ReceiveBufferSize = NameValueCollectionHelper.ConvertToInt32(items, "receive buffer size", 8 * 1024);
            MaxPoolSize       = NameValueCollectionHelper.ConvertToInt32(items, "max pool size", 16);
            PoolAccessTimeout = NameValueCollectionHelper.ConvertToInt32(items, "pool access timeout", 100);
            PoolWaitTimeout   = NameValueCollectionHelper.ConvertToInt32(items, "pool wait timeout", 250);
            IdleTimeout       = NameValueCollectionHelper.ConvertToInt32(items, "idle timeout", 30 * 1000);
            LeaseTimeout      = NameValueCollectionHelper.ConvertToInt32(items, "lease timeout", 15 * 60 * 1000);

            FullName = String.Format(CultureInfo.InvariantCulture, "Name={0}, Server={1}:{2}",
                                     Name, Server, Port);
        }
Ejemplo n.º 8
0
 public JpegImageCodecInfo(CaptchaOptions options)
     : this(NameValueCollectionHelper.ConvertToInt32(options.Items, CaptchaOptionNames.EncoderQuality, CaptchaOptionDefaults.EncoderQuality))
 {
 }
 public static int ConvertToInt32(this NameValueCollection collection, string paramName, int defaultValue)
 {
     return(NameValueCollectionHelper.ConvertToInt32(collection, paramName, defaultValue));
 }
 public DefaultVaryByCustomProvider(CaptchaOptions options)
     : this(NameValueCollectionHelper.ConvertToInt32(options.Items,
                                                     CaptchaOptionNames.MaxVaryCacheSize,
                                                     CaptchaOptionDefaults.MaxVaryCacheSize))
 {
 }