예제 #1
0
 internal void EnableGranularValidation(ValidateStringCallback validationCallback)
 {
     // Iterate over all the keys, adding each to the set containing the keys awaiting validation.
     // Unlike dictionaries, HashSet<T> can contain null keys, so don't need to special-case them.
     _keysAwaitingValidation = new HashSet <string>(Keys.Cast <string>(), StringComparer.OrdinalIgnoreCase);
     _validationCallback     = validationCallback;
 }
 /// <summary>
 /// Clears the contents of the <see cref="NpgsqlConnectionStringBuilder"/> instance.
 /// </summary>
 public override void Clear()
 {
     Contract.Assert(Keys != null);
     foreach (var k in Keys.Cast <string>().ToArray())
     {
         Remove(k);
     }
 }
        /*
         * We added granular request validation in ASP.NET 4.5 to provide a better request validation story for our developers.
         * Instead of validating the entire collection ahead of time, we'll only validate entries that are actually looked at.
         */

        internal void EnableGranularValidation(ValidateStringCallback validationCallback)
        {
            // Iterate over all the keys, adding each to the set containing the keys awaiting validation.
            // Unlike dictionaries, HashSet<T> can contain null keys, so don't need to special-case them.
            _keysAwaitingValidation = new HashSet <string>(Keys.Cast <string>().Where(KeyIsCandidateForValidation), StringComparer.OrdinalIgnoreCase);
            _validationCallback     = validationCallback;

            // This forces CopyTo and other methods that cache entries to flush their caches, ensuring
            // that all values go through validation again.
            InvalidateCachedArrays();
        }
예제 #4
0
 public void Set(string key, string value)
 {
     EnsureExistence();
     if (Has(key))
     {
         var index = Keys.Cast <string>().IndexOf(key);
         Values[index] = value;
     }
     else
     {
         Keys.Add(key);
         Values.Add(value);
     }
 }
예제 #5
0
 public bool Has(string key)
 {
     EnsureExistence();
     return(Keys.Cast <string>().Contains(key));
 }
예제 #6
0
 public string Get(string key)
 {
     EnsureExistence();
     return(Keys.Cast <string>().Corresponding(key, Values.Cast <string>()));
 }
예제 #7
0
 /// <summary>
 /// Returns a string containing all the settings in the class, in querystring form. Use ToStringEncoded() to get a URL-safe querystring.
 /// This method does not encode commas, spaces, etc.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(string.Join(";", Keys.Cast <string>().Select(x => x + ":" + this[x])));
 }
예제 #8
0
 public override string ToString()
 {
     return(string.Join("&", Keys.Cast <string>().Select(
                            key => string.Format("{0}={1}", key, this[key]))));
 }
예제 #9
0
 public static async Task<bool> SendKeyCombination(Keys[] keys, int time)
 {
     return await SendKeyCombination(keys.Cast<VirtualKeys>().ToArray(), time);
 }
예제 #10
0
 public IEnumerable <IKey> GetKeys() => Keys.Cast <IKey>();
예제 #11
0
 /// <summary>
 ///     Stimulate a key combination press
 /// </summary>
 /// <param name="keys">The key combination</param>
 /// <returns>If the function succeeds it returns true; otherwise, returns false</returns>
 public static bool SendKeyCombination(Keys[] keys)
 {
     return SendKeyCombination(keys.Cast<VirtualKeys>().ToArray());
 }
        public ConnectionConfiguration Parse(string connectionString)
        {
            ConnectionString = connectionString;

            var connectionConfiguration     = new ConnectionConfiguration(settings);
            var connectionConfigurationType = typeof(ConnectionConfiguration);

            foreach (var key in Keys.Cast <string>())
            {
                var property = connectionConfigurationType.GetProperty(key, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
                property?.SetValue(connectionConfiguration, TypeDescriptor.GetConverter(property.PropertyType).ConvertFrom(this[key]));
            }

            if (connectionConfiguration.UseTls && !ContainsKey("port"))
            {
                connectionConfiguration.Port = 5671;
            }

            if (ContainsKey("host"))
            {
                ParseHosts(connectionConfiguration, this["host"] as string);
            }
            else
            {
                throw new Exception("Invalid connection string. 'host' value must be supplied. e.g: \"host=myServer\"");
            }

            if (ContainsKey("dequeuetimeout"))
            {
                var message = "The 'DequeueTimeout' connection string option has been removed. Consult the documentation for further information.";

                Logger.Error(message);

                throw new NotSupportedException(message);
            }

            if (ContainsKey("maxwaittimeforconfirms"))
            {
                var message = "The 'MaxWaitTimeForConfirms' connection string option has been removed. Consult the documentation for further information";

                Logger.Error(message);

                throw new NotSupportedException(message);
            }

            if (ContainsKey("prefetchcount"))
            {
                var message = "The 'PrefetchCount' connection string option has been removed. Use 'EndpointConfiguration.UseTransport<RabbitMQTransport>().PrefetchCount' instead.";

                Logger.Error(message);

                throw new NotSupportedException(message);
            }

            if (ContainsKey("usepublisherconfirms"))
            {
                var message = "The 'UsePublisherConfirms' connection string option has been removed. Use 'EndpointConfiguration.UseTransport<RabbitMQTransport>().UsePublisherConfirms' instead.";

                Logger.Error(message);

                throw new NotSupportedException(message);
            }

            return(connectionConfiguration);
        }
예제 #13
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public Task CleatAsync()
 {
     return(_db.HashDeleteAsync(Name, Keys.Cast(x => (RedisValue)x).ToArray()));
 }
예제 #14
0
 /// <summary>
 ///
 /// </summary>
 public void Clear()
 {
     _db.HashDelete(Name, Keys.Cast(x => (RedisValue)x).ToArray());
 }
 public override System.Collections.Generic.IEnumerable <string> GetDynamicMemberNames()
 {
     return(Keys.Cast <string>().AsEnumerable());
 }