11namespace DotNetToolkit . Repository . AdoNet . Internal
22{
3+ #if NETSTANDARD
34 using Microsoft . DotNet . PlatformAbstractions ;
45 using Microsoft . Extensions . DependencyModel ;
56 using System ;
67 using System . Collections . Generic ;
7- using System . Data . Common ;
88 using System . Data . SqlClient ;
99 using System . IO ;
1010 using System . Linq ;
1111 using System . Reflection ;
12+ #endif
13+ using System . Data . Common ;
1214
1315 /// <summary>
1416 /// Represents a set of static methods for creating one or more instances of System.Data.Common.DbProviderFactory classes.
@@ -41,14 +43,15 @@ public static DbProviderFactory GetFactory(string providerName)
4143 return GetFactory ( DataAccessProviderType . PostgreSql ) ;
4244 default :
4345 throw new NotSupportedException ( $ "Unsupported Provider Factory specified: { providerName } ") ;
44- }
46+ }
4547#endif
4648 }
4749
4850 #endregion
4951
5052 #region Private Methods
5153
54+ #if NETSTANDARD
5255 private static Type GetTypeFromName ( string typeName )
5356 {
5457 return GetTypeFromName ( typeName , null ) ;
@@ -157,7 +160,9 @@ private static DbProviderFactory GetFactory(string dbProviderFactoryTypename, st
157160
158161 return instance as DbProviderFactory ;
159162 }
163+ #endif
160164
165+ #if NETSTANDARD
161166 private static DbProviderFactory GetFactory ( DataAccessProviderType type )
162167 {
163168 if ( type == DataAccessProviderType . SqlServer )
@@ -171,61 +176,25 @@ private static DbProviderFactory GetFactory(DataAccessProviderType type)
171176 return GetFactory ( "Microsoft.Data.Sqlite.SqliteFactory" , "Microsoft.Data.Sqlite" ) ;
172177#endif
173178 }
179+
174180 if ( type == DataAccessProviderType . MySql )
175181 return GetFactory ( "MySql.Data.MySqlClient.MySqlClientFactory" , "MySql.Data" ) ;
182+
176183 if ( type == DataAccessProviderType . PostgreSql )
177184 return GetFactory ( "Npgsql.NpgsqlFactory" , "Npgsql" ) ;
178185#if NETFULL
186+
179187 if ( type == DataAccessProviderType . OleDb )
180188 return System . Data . OleDb . OleDbFactory . Instance ;
189+
181190 if ( type == DataAccessProviderType . SqlServerCompact )
182191 return System . Data . Common . DbProviderFactories . GetFactory ( "System.Data.SqlServerCe.4.0" ) ;
183192#endif
184193
185194 throw new NotSupportedException ( $ "Unsupported Provider Factory specified: { type } ") ;
186195 }
187-
188- #endregion
189- }
190-
191- internal enum DataAccessProviderType
192- {
193- SqlServer ,
194- SqLite ,
195- MySql ,
196- PostgreSql ,
197-
198- #if NETFULL
199- OleDb ,
200- SqlServerCompact
201196#endif
202- }
203197
204- internal static class DataAccessProvider
205- {
206- public static DataAccessProviderType GetProviderType ( string providerName )
207- {
208- switch ( providerName . ToLower ( ) )
209- {
210- #if NETFULL
211- case "system.data.sqlserverce.4.0" :
212- return DataAccessProviderType . SqlServerCompact ;
213- case "microsoft.jet.oledb.4.0" :
214- return DataAccessProviderType . OleDb ;
215- #endif
216- case "system.data.sqlclient" :
217- return DataAccessProviderType . SqlServer ;
218- case "system.data.sqlite" :
219- case "microsoft.data.sqlite" :
220- return DataAccessProviderType . SqLite ;
221- case "mysql.data.mysqlclient" :
222- case "mysql.data" :
223- return DataAccessProviderType . MySql ;
224- case "npgsql" :
225- return DataAccessProviderType . PostgreSql ;
226- default :
227- throw new NotSupportedException ( $ "Unsupported Provider Factory specified: { providerName } ") ;
228- }
229- }
198+ #endregion
230199 }
231200}
0 commit comments