System.Data.Common.DbProviderFactories.GetFactoryClasses()

Here are the examples of the csharp api class System.Data.Common.DbProviderFactories.GetFactoryClasses() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

15 Examples 7

1. Example

Project: OrigoDB
Source File: SqlStorageTest.cs
[Test]
        public void DisplayProviders()
        {
            var table = DbProviderFactories.GetFactoryClasses();
            foreach (DataRow row in table.Rows)
            {
                foreach (DataColumn column in table.Columns)
                {
                    Console.WriteLine(column.ColumnName + ":" + row[column]);
                }
                Console.WriteLine("-------------------------------------------------");
            }
        }

2. Example

Project: FreeSCADA
Source File: DatabaseFactory.cs
public static DataTable GetAvailableDB()
		{
			DataTable dt = DbProviderFactories.GetFactoryClasses();
			dt.Rows.Add(new object[] { "SQLite Data Provider", ".Net Framework Data Provider for SQLite", SQLiteName, "System.Data.SQLite.SQLiteFactory, System.Data.SQLite" });
			return dt;
		}

3. Example

Project: referencesource
Source File: SqlProvider.cs
private static DbProviderFactory GetProvider(string providerName) {
            bool hasProvider = 
                DbProviderFactories.GetFactoryClasses().Rows.OfType<DataRow>()
                .Select(r => (string)r["InvariantName"])
                .Contains(providerName, StringComparer.OrdinalIgnoreCase);
            if (hasProvider) {
                return DbProviderFactories.GetFactory(providerName);
            }
            return null;
        }

4. Example

Project: NLog
Source File: DatabaseTarget.cs
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spel/n ..... /n //View Source file for more details /n }

5. Example

Project: CommunityServer
Source File: DbRegistry.cs
public static void Configure()
        {
            if (!configured)
            {
                lock (syncRoot)
                {
                    if (!configured)
                    {
                        var factories = DbProviderFactories.GetFactoryClasses();
                        AppDomain.CurrentDomain.SetData("DataDirectory", AppDomain.CurrentDomain.BaseDirectory); //SQLite
                        foreach (ConnectionStringSettings cs in ConfigurationManager.ConnectionStrings)
                        {
                            var factory = factories.Rows.Find(cs.ProviderName);
                            if (factory == null)
                            {
                                throw new ConfigurationErrorsException("Db factory " + cs.ProviderName + " not found.");
                            }
                            RegisterDatabase(cs.Name, cs);
                        }
                        configured = true;
                    }
                }
            }
        }

6. Example

Project: ActivityManager
Source File: SqlDataSource.cs
private static string ParseProviderName(string name)
        {
            DataTable dt = DbProviderFactories.GetFactoryClasses();
            List<string> providers = new List<string>();
            foreach (DataRow row in dt.Rows)
            {
                providers.Add(row["InvariantName"].ToString());
            }
            foreach (string provider in providers)
            {
                if (Regex.IsMatch(provider, name, RegexOptions.IgnoreCase))
                    return provider;
            }
            SqlException exception = new SqlException("????????? {0} ?? ??????");
            exception.Data.Add("{0}", name);
            throw exception;
        }

7. Example

Project: ALinq
Source File: Sql2000Provider.cs
private static DbProviderFactory GetProvider(string providerName)
        {
            if (
                DbProviderFactories.GetFactoryClasses().Rows.OfType<DataRow>()
                .Select(r => (string)r["InvariantName"])
                .Contains(providerName, StringComparer.OrdinalIgnoreCase))
            {
                return DbProviderFactories.GetFactory(providerName);
            }
            return null;
        }

8. Example

Project: ALinq
Source File: Sql2005Provider.cs
private static DbProviderFactory GetProvider(string providerName)
        {
            if (
                DbProviderFactories.GetFactoryClasses().Rows.OfType<DataRow>().Select(
                    delegate(DataRow r) { return (string)r["InvariantName"]; }).Contains(providerName,
                                                                                          StringComparer.
                                                                                              OrdinalIgnoreCase))
            {
                return DbProviderFactories.GetFactory(providerName);
            }
            return null;
        }

9. Example

Project: NBi
Source File: ConnectionFactory.cs
protected string TranslateProviderName(string providerName)
        {
            var providers = new List<string>();
            foreach (DataRowView item in DbProviderFactories.GetFactoryClasses().DefaultView)
                providers.Add((string)item[2]);

            var invariantNames = providers.FindAll(p => p.ToLowerInvariant()==providerName.ToLowerInvariant());

            if (invariantNames.Count==1)
                return invariantNames[0];
            else if (invariantNames.Count>1)
                throw new ArgumentException(string.Format("More than one Provider can be returned based on providerName given: '{0}'", providerName));

            return null;
        }

10. Example

Project: NDF.Infrastructure
Source File: DbProviderFactoryExtensions.cs
private static DbProviderFactoryClass[] GetDbProviderFactoryClasses()
        {
            List<DbProviderFactoryClass> list = DbProviderFactories.GetFactoryClasses().ToList<DbProviderFactoryClass>();

            var types = typeof(DbProviderFactory).GetSubClass().Where(t => !t.IsAbstract);
            foreach (Type type in types)
            {
                if (!list.Any(item => item.AssemblyQualifiedName == type.AssemblyQualifiedName || item.InvariantName == type.Namespace))
                {
                    DbProviderFactoryClass item = new DbProviderFactoryClass();
                    string name = type.Name.Replace("Factory", "");
                    item.Name = name + " Data Provider";
                    item.Description = ".NET Framework Data Provider for " + name;
                    item.InvariantName = type.Namespace;
                    item.AssemblyQualifiedName = type.AssemblyQualifiedName;
                    list.Add(item);
                }
            }

            DbProviderFactoryClass[] factories = list.Where(
                item =>
                {
                    Type type = null;
                    return Types.TryGetType(item.AssemblyQualifiedName, out type);
                }).ToArray();

            return factories;
        }

11. Example

Project: BehaviorIsManaged
Source File: DatabaseTarget.cs
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spel/n ..... /n //View Source file for more details /n }

12. Example

Project: NLog
Source File: DatabaseTarget.cs
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spel/n ..... /n //View Source file for more details /n }

13. Example

Project: referencesource
Source File: EntityUtil.cs
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
        internal sta/n ..... /n //View Source file for more details /n }

14. Example

Project: Pscx
Source File: GetAdoDataProviderCommand.cs
protected override void EndProcessing()
        {
            try
            {
                Pred/n ..... /n //View Source file for more details /n }

15. Example

Project: Samples
Source File: Program.cs
static void Main(string[] args)
        {
            try
            {
                Console.Writ/n ..... /n //View Source file for more details /n }