Example #1
0
        public IndigoInchi(Indigo indigo)
        {
            String          dllpath = indigo.getDllPath();
            string          libraryName;
            IndigoDllLoader dll_loader = IndigoDllLoader.Instance;

            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                libraryName = "indigo-inchi.dll";
                dll_loader.loadLibrary(dllpath, libraryName, "com.ggasoftware.indigo.Properties.ResourcesWin", false);
                break;

            case PlatformID.Unix:
                if (IndigoDllLoader.isMac())
                {
                    libraryName = "libindigo-inchi.dylib";
                    dll_loader.loadLibrary(dllpath, libraryName, "com.ggasoftware.indigo.Properties.ResourcesMac", false);
                }
                else
                {
                    libraryName = "libindigo-inchi.so";
                    dll_loader.loadLibrary(dllpath, libraryName, "com.ggasoftware.indigo.Properties.ResourcesLinux", false);
                }
                break;

            default:
                throw new PlatformNotSupportedException(String.Format("Unsupported platform: {0}", Environment.OSVersion.Platform));
            }

            _inchi_lib = dll_loader.getInterface <IndigoInchiLib> (libraryName);

            _indigo = indigo;
        }
Example #2
0
        public static IntPtr GetProcAddress(IntPtr library, string procedureName)
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                return(WindowsLoader.GetProcAddress(library, procedureName));

            case PlatformID.Unix:
                if (IndigoDllLoader.isMac())
                {
                    return(MacLoader.dlsym(library, procedureName));
                }
                else
                {
                    return(LinuxLoader.dlsym(library, procedureName));
                }
            }
            return(IntPtr.Zero);
        }
Example #3
0
        public static int FreeLibrary(IntPtr handle)
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                return(WindowsLoader.FreeLibrary(handle));

            case PlatformID.Unix:
                if (IndigoDllLoader.isMac())
                {
                    return(MacLoader.dlclose(handle));
                }
                else
                {
                    return(LinuxLoader.dlclose(handle));
                }
            }
            return(0);
        }
Example #4
0
        public static IntPtr LoadLibrary(string filename)
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                return(WindowsLoader.LoadLibrary(filename));

            case PlatformID.Unix:
                if (IndigoDllLoader.isMac())
                {
                    return(MacLoader.dlopen(filename.Replace("\\", "/"), 2));
                }
                else
                {
                    return(LinuxLoader.dlopen(filename.Replace("\\", "/"), 2));
                }
            }
            return(IntPtr.Zero);
        }
Example #5
0
        public static string GetLastError()
        {
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                return(WindowsLoader.GetLastError().ToString());

            case PlatformID.Unix:
                if (IndigoDllLoader.isMac())
                {
                    return(MacLoader.dlerror());
                }
                else
                {
                    return(LinuxLoader.dlerror());
                }
            }
            return(null);
        }
Example #6
0
        private void init(string lib_path)
        {
            string libraryName;

            dll_loader = IndigoDllLoader.Instance;
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32NT:
                libraryName = "indigo.dll";
                bool vs2010 = true;
                bool vs2012 = true;
                bool vs2013 = true;
                try
                {
                    dll_loader.loadLibrary(lib_path, "msvcr100.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2010", false);
                }
                catch
                {
                    vs2010 = false;
                }
                try
                {
                    dll_loader.loadLibrary(lib_path, "msvcr110.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2012", false);
                }
                catch
                {
                    vs2012 = false;
                }
                try
                {
                    dll_loader.loadLibrary(lib_path, "msvcr120.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2013", false);
                }
                catch
                {
                    vs2013 = false;
                }

                if (vs2010)
                {
                    dll_loader.loadLibrary(lib_path, "msvcr100.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2010", false);
                    dll_loader.loadLibrary(lib_path, "msvcp100.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2010", false);
                    dll_loader.loadLibrary(lib_path, libraryName, "com.ggasoftware.indigo.Properties.ResourcesWin2010", false);
                }
                else if (vs2012)
                {
                    dll_loader.loadLibrary(lib_path, "msvcr110.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2012", false);
                    dll_loader.loadLibrary(lib_path, "msvcp110.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2012", false);
                    dll_loader.loadLibrary(lib_path, libraryName, "com.ggasoftware.indigo.Properties.ResourcesWin2012", false);
                }
                else if (vs2013)
                {
                    dll_loader.loadLibrary(lib_path, "msvcr120.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2013", false);
                    dll_loader.loadLibrary(lib_path, "msvcp120.dll", "com.ggasoftware.indigo.Properties.ResourcesWin2013", false);
                    dll_loader.loadLibrary(lib_path, libraryName, "com.ggasoftware.indigo.Properties.ResourcesWin2013", false);
                }

                break;

            case PlatformID.Unix:
                if (IndigoDllLoader.isMac())
                {
                    libraryName = "libindigo.dylib";
                    dll_loader.loadLibrary(lib_path, libraryName, "com.ggasoftware.indigo.Properties.ResourcesMac", false);
                }
                else
                {
                    libraryName = "libindigo.so";
                    dll_loader.loadLibrary(lib_path, libraryName, "com.ggasoftware.indigo.Properties.ResourcesLinux", false);
                }
                break;

            default:
                throw new PlatformNotSupportedException(String.Format("Unsupported platform: {0}", Environment.OSVersion.Platform));
            }

            // Save instance id to check if session was allocated for this instance
            _dll_loader_id = IndigoDllLoader.InstanceId;

            _dllpath = lib_path;

            _indigo_lib = dll_loader.getInterface <IndigoLib>(libraryName);

            _sid = _indigo_lib.indigoAllocSessionId();
            _indigo_lib.indigoSetSessionId(_sid);
        }