示例#1
0
    /// <summary>
    /// Dynamically generates a class that will load the "fbembed.dll" given in <c>dllName</c>, and that
    /// also implements <see cref="IFbClient"/>, which you can use to call the library.
    /// </summary>
    /// <param name="dllName">The name of the DLL to load (e.g. "fbembed", "C:\path\to\fbembed.dll", etc)</param>
    /// <returns>A class that implements <see cref="IFbClient"/> and calls into the native library you specify.</returns>
    public static IFbClient Create(string dllName)
    {
        if (string.IsNullOrEmpty(dllName))
        {
            dllName = DefaultDllName;
        }
        var createdNew = false;
        var result     = cache.GetOrAdd(dllName, s => { createdNew = true; return(BuildFbClient(s)); });

        if (createdNew)
        {
            ShutdownHelper.RegisterFbClientShutdown(() => NativeHelpers.CallIfExists(() => result.fb_shutdown(0, 0)));
        }
        return(result);
    }
        /// <summary>
        /// Dynamically generates a class that will load the "fbembed.dll" given in <c>dllName</c>, and that
        /// also implements <see cref="IFbClient"/>, which you can use to call the library.
        /// </summary>
        /// <param name="dllName">The name of the DLL to load (e.g. "fbembed", "C:\path\to\fbembed.dll", etc)</param>
        /// <returns>A class that implements <see cref="IFbClient"/> and calls into the native library you specify.</returns>
        public static IFbClient Create(string dllName)
        {
            if (string.IsNullOrEmpty(dllName))
            {
                dllName = DefaultDllName;
            }
            var createdNew = false;
            var result     = cache.GetOrAdd(dllName, s => { createdNew = true; return(BuildFbClient(s)); });

            if (createdNew)
            {
                ShutdownHelper.RegisterFbClientShutdown(() => ShutdownEntryPointWrapper(result));
            }
            return(result);
        }