Exemple #1
0
        public static void Load(string path)
        {
            if (!Directory.Exists(path))
            {
                return;
            }

            var photoPluginList   = new List <SusiePlugin>();
            var archivePluginList = new List <SusiePlugin>();

            Directory.EnumerateFiles(path, "*.spi")
            .Select(spi => SusiePlugin.Load(spi))
            .ForEach(spi =>
            {
                if (spi.Type == SusiePluginType.Import)
                {
                    photoPluginList.Add(spi);
                }
                else
                {
                    archivePluginList.Add(spi);
                }
            });

            SpiManager.photoPluginList   = photoPluginList.ToArray();
            SpiManager.archivePluginList = archivePluginList.ToArray();
        }
Exemple #2
0
        public static SusiePlugin Load(string filePath)
        {
            var ptr = Win32.LoadLibrary(filePath);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            var result = new SusiePlugin();

            IntPtr tmp;

            tmp = Win32.GetProcAddress(ptr, "GetPluginInfo");
            if (tmp == IntPtr.Zero)
            {
                return(null);
            }

            result.getPluginInfo = Marshal.GetDelegateForFunctionPointer <Susie.GetPluginInfo>(tmp);

            var buf = new StringBuilder(1000);

            if (result.getPluginInfo(0, buf, buf.Capacity) == 0)
            {
                return(null);
            }

            var version = buf.ToString();

            tmp = Win32.GetProcAddress(ptr, "IsSupported");
            if (tmp != IntPtr.Zero)
            {
                result.isSupported = Marshal.GetDelegateForFunctionPointer <Susie.IsSupported>(tmp);
            }

            if (version.EndsWith("IN"))
            {
                result.Type = SusiePluginType.Import;

                tmp = Win32.GetProcAddress(ptr, "GetPictureInfo");
                if (tmp != IntPtr.Zero)
                {
                    result.getPictureInfo = Marshal.GetDelegateForFunctionPointer <Susie.GetPictureInfo>(tmp);
                }

                tmp = Win32.GetProcAddress(ptr, "GetPicture");
                if (tmp != IntPtr.Zero)
                {
                    result.getPicture = Marshal.GetDelegateForFunctionPointer <Susie.GetPicture>(tmp);
                }

                tmp = Win32.GetProcAddress(ptr, "GetPreview");
                if (tmp != IntPtr.Zero)
                {
                    result.getPreview = Marshal.GetDelegateForFunctionPointer <Susie.GetPreview>(tmp);
                }
            }
            else if (version.EndsWith("AM"))
            {
                result.Type = SusiePluginType.Archive;

                tmp = Win32.GetProcAddress(ptr, "GetArchiveInfo");
                if (tmp != IntPtr.Zero)
                {
                    result.getArchiveInfo = Marshal.GetDelegateForFunctionPointer <Susie.GetArchiveInfo>(tmp);
                }

                tmp = Win32.GetProcAddress(ptr, "GetFileInfo");
                if (tmp != IntPtr.Zero)
                {
                    result.getFileInfo = Marshal.GetDelegateForFunctionPointer <Susie.GetFileInfo>(tmp);
                }

                tmp = Win32.GetProcAddress(ptr, "GetFile");
                if (tmp != IntPtr.Zero)
                {
                    result.getFile = Marshal.GetDelegateForFunctionPointer <Susie.GetFile>(tmp);
                }
            }

            return(result);
        }