Exemple #1
0
        /// <summary>
        /// Get the provider for a specific type. This method tries to find a corresponding
        /// namespace provider to use, and if no match is found, returns the default provider.
        /// </summary>
        /// <param name="type">The type for which to find a provider.</param>
        /// <returns>A GentleProvider instance.</returns>
        public static IGentleProvider GetProvider(Type type)
        {
            NamespaceProvider np = NamespaceProviders.GetNamespaceProvider(type);

            if (np != null)
            {
                return(GetProvider(null, np.ProviderName, np.ConnectionString, np.Schema));
            }
            // use the default provider
            return(GetProvider(null, null, null, null));
        }
Exemple #2
0
 /// <summary>
 /// Add a new namespace provider. If a namespace provider has been registered, Gentle will
 /// try to match the namespace of a type to those registered, and if a match is found will
 /// use the associated provider and connection string (instead of the default provider).
 /// Namespaces are matched using StartsWith, so using incomplete substrings is supported
 /// (the longest match will be used if multiple namespaces match).
 /// </summary>
 /// <param name="nmspace">The namespace string to use.</param>
 /// <param name="provider">The provider to use for this namespace.</param>
 /// <param name="connectionString">The connection string to use with this provider.</param>
 public static void AddNamespaceProvider(string nmspace, string provider, string connectionString)
 {
     NamespaceProviders.RegisterNamespace(nmspace, provider, connectionString);
 }