> Yes, but this will not work with DllImport. It accepts only constant 
> string as param. And using LoadLibrary will work only on Windows, so for 
> Linux/Mono it will be out.
> 
> BTW if the DLL is in standard dirs there's no problem with loading, 
> isn't it?


The problems are in FirebirdSql.Data.Client.Embedded:

#if     (LINUX)
#if     (FBCLIENT)
                        public const string     DllPath = "libfbclient";
#elif (GDS32)
                        public const string     DllPath = "libgds";
#elif (VULCAN)
                        public const string     DllPath = "libfirebird32";
#elif (FYRACLE)
                        public const string     DllPath = "fyracle";
#else
                        public const string     DllPath = "libfbembed";
#endif
#else
#if     (FBCLIENT)
                        public const string     DllPath = "fbclient";
#elif (GDS32)
                        public const string     DllPath = "gds32";
#elif (VULCAN)
                        public const string     DllPath = "firebird32";
#elif (FYRACLE)
                        public const string     DllPath = "fyracle";
#else
                public const string DllPath = "fbembed";
#endif
#endif


I do not want to recompile provider for using it with fbclient.dll 
instead of fbembed.dll.


So i looked into sources and what do you think about next changes:

1) Make interface FirebirdSql.Data.Client.Embedded.IFbClient with same 
methods as in current IFbClient


2) Make concreate implementations of IFbClient, for example:

        [SuppressUnmanagedCodeSecurity]
        internal sealed class FbClientWinEmbedded : IFbClient
        {
                [DllImport("fbembed")]
                public static extern int isc_array_get_slice(
                        [In, Out] int[] statusVector,
                        ref     int dbHandle,
                        ref     int trHandle,
                        ref     long arrayId,
                        IntPtr desc,
                        byte[] destArray,
                        ref     int sliceLength);

                int IFbClient.isc_array_get_slice(                              
                        [In, Out] int[] statusVector,
                        ref     int dbHandle,
                        ref     int trHandle,
                        ref     long arrayId,
                        IntPtr desc,
                        byte[] destArray,
                        ref     int sliceLength);

                {
                        return isc_array_get_slice(
                                statusVector,
                                ref dbHandle,
                                ref trHandle,
                                ref arrayId,
                                desc,
                                destArray,
                                ref sliceLength);
                }


3) Make new class like FbClientFactory:

namespace FirebirdSql.Data.Client.Embedded
{
        internal static class FbClientFactory
        {
                private static Dictionary<string, IFbClient> fbClients =
                        new Dictionary<string, IFbClient>();

                static FbClientFactory()
                {
                        fbClients.Add("WinEmbed".ToLower(), new 
FbClientWinEmbedded());
                        // so on ...
                }

                internal static IFbClient GetFbClientByName(string clientName)
                {
                        return fbClients[clientName.ToLower()];
                }
        }
}


4) Add field and parameter to class constructors, for example:
public FesDatabase(string clientName)
{
        //...
        this.clientName = clientName;
}

        
5) Replace all current calls of FbClient.xxx on 
FbClientFactory.GetFbClientByName(clientName).xxx



What do you think? I can try to implement this.

Which way is better, Dean's or myne?



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to