コード例 #1
0
ファイル: PluginManager.cs プロジェクト: fatalwall/SingleCopy
        private static System.Reflection.Assembly AssemblyResolver(object sender, ResolveEventArgs args)
        {
            string exePath = System.IO.Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath);

            string[] DirectoryList =
            {
                exePath,                                                     //App Folder
                System.IO.Path.Combine(exePath, "Plugins"),                  //App/Plugins Folder
                System.IO.Path.Combine(exePath, "Plugins", args.Name),       //App/Plugins/PluginName Folder
                Environment.SystemDirectory,                                 //System32 Folder
                Environment.GetFolderPath(Environment.SpecialFolder.Windows) //Windows Folder
            };

            System.Reflection.Assembly assembly = null;
            foreach (string path in DirectoryList)
            {
                if (TryGetAssembly(path, args.Name, out assembly))
                {
                    return(assembly);
                }
            }

            PluginLogger.Error("{0} could not be found in any of the following locations:\r\n\t{1}\r\n\t{2}\r\n\t{3}\r\n\t{4}\r\n\t{5}\r\n", (new string[] { args.Name }).Concat(DirectoryList).ToArray());
            return(null);
        }
コード例 #2
0
ファイル: PluginManager.cs プロジェクト: fatalwall/SingleCopy
        public static Bitmap getImage(Assembly assembly, string Name)
        {
            Bitmap image = null;

            if (ResourceManager.ContainsKey(assembly))
            {
                image = (Bitmap)ResourceManager[assembly].GetObject(Name);
            }
            if (image is null)
            {
                PluginLogger.Error("'{0}' does not contain an image resource named '{1}'", assembly.GetName().Name, Name);
            }
            return(image);
        }