From dd133b36594ba644c9ef5a28dee5703718b6ea9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20Fl=C3=ADdr?= Date: Mon, 23 Oct 2017 19:12:49 +0200 Subject: [PATCH] release 1.2.6 - provider detection fix --- Connection/StaticInit.vb | 30 +++++++++++++++++++++++++++--- Databasic.nuspec | 2 +- My Project/AssemblyInfo.vb | 4 ++-- README.md | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/Connection/StaticInit.vb b/Connection/StaticInit.vb index fec15be..83234d9 100644 --- a/Connection/StaticInit.vb +++ b/Connection/StaticInit.vb @@ -1,4 +1,4 @@ -Imports System.Configuration +Imports System.Configuration Imports System.Data.Common Imports System.IO Imports System.Reflection @@ -46,14 +46,15 @@ Partial Public MustInherit Class Connection End Sub Private Shared Sub _staticInitCompleteProviders() - Dim asms As New Dictionary(Of String, Reflection.Assembly) + Dim asms As New List(Of String) Dim asmName As String Dim connectionType As Type Dim conn As Connection Dim referencedAsms As Reflection.Assembly() = AppDomain.CurrentDomain.GetAssemblies() For Each asm As Reflection.Assembly In referencedAsms + asmName = asm.GetName().Name + asms.Add(asmName) If Connection._staticInitIsDatabasicSubAssembly(asm) Then - asmName = asm.GetName().Name connectionType = asm.GetType(asmName + ".Connection") If Not TypeOf connectionType Is Type Then Continue For conn = Activator.CreateInstance(connectionType) @@ -63,6 +64,29 @@ Partial Public MustInherit Class Connection ) End If Next + Try + Dim appDirAsms As IEnumerable(Of Assembly) = ( + From file In Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory) + Where Path.GetExtension(file).ToLower() = ".dll" + Select Assembly.LoadFrom(file) + ) + For Each asm As System.Reflection.Assembly In appDirAsms + asmName = asm.GetName().Name + If ( + Not asms.Contains(asmName) And + Connection._staticInitIsDatabasicSubAssembly(asm) + ) Then + connectionType = asm.GetType(asmName + ".Connection") + If Not TypeOf connectionType Is Type Then Continue For + conn = Activator.CreateInstance(connectionType) + Connection._supportedProviders.Add(conn.ClientName, connectionType) + Connection._providersResources.Add( + conn.ClientName, Activator.CreateInstance(conn.ProviderResource) + ) + End If + Next + Catch ex As Exception + End Try End Sub Private Shared Function _staticInitIsDatabasicSubAssembly(asm As Reflection.Assembly) As Boolean diff --git a/Databasic.nuspec b/Databasic.nuspec index 9093fcc..cb2b69a 100644 --- a/Databasic.nuspec +++ b/Databasic.nuspec @@ -2,7 +2,7 @@ Databasic.Core - 1.2.5.0 + 1.2.6.0 Databasic - Core Tom Flidr Tom Flidr diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 29fb8b0..165f34f 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -37,5 +37,5 @@ Install this package only with specific database package like: ' by using the '*' as shown below: ' - - + + diff --git a/README.md b/README.md index 81f6044..06ce523 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Databasic - Core Package -[![Latest Stable Version](https://img.shields.io/badge/Stable-v1.2.5-brightgreen.svg?style=plastic)](https://github.com/databasic-net/databasic-core/releases) +[![Latest Stable Version](https://img.shields.io/badge/Stable-v1.2.6-brightgreen.svg?style=plastic)](https://github.com/databasic-net/databasic-core/releases) [![License](https://img.shields.io/badge/Licence-BSD3-brightgreen.svg?style=plastic)](https://raw.githubusercontent.com/databasic-net/databasic-core/master/LICENCE.md) ![.NET Version](https://img.shields.io/badge/.NET->=4.0-brightgreen.svg?style=plastic)