Beispiel #1
0
        void loadPlugins()
        {
            Lama.log("NOTICE", "Load plugins");
            try
            {
                DirectoryInfo pluginsDir = new DirectoryInfo(Path.GetDirectoryName(Application.ExecutablePath) + @"\Plugins\");
                //Read dllignore
                List <string> dllignore = new List <string>(File.ReadAllLines(pluginsDir.FullName + "dllignore"));
                //Read dll
                foreach (FileInfo file in pluginsDir.GetFiles())
                {
                    if (file.Extension.Equals(".dll") && !dllignore.Contains(file.Name))
                    {
                        try
                        {
                            DllLoader loader = new DllLoader(file.FullName);

                            int cpt = loader.getAllCountInstances(Lama.inGamePlugins)
                                      + loader.getAllCountInstances(Lama.homeComponentPlugins)
                                      + loader.getAllCountInstances(Lama.tabPlugins);

                            if (cpt == 0)
                            {
                                StreamWriter sw = new StreamWriter(File.Open(pluginsDir.FullName + "dllignore", FileMode.Append));
                                sw.WriteLine(file.Name);
                                sw.Close();
                            }
                        }
                        //catch (NullReferenceException) { }
                        catch (IOException) { }
                        catch (Exception er)
                        {
                            Lama.log("ERROR", "[LoadPlugins][" + file.FullName + "]" + er.Message + er.GetType().Name);
                            try
                            {
                                StreamWriter sw = new StreamWriter(File.Open(pluginsDir.FullName + "dllignore", FileMode.Append));
                                sw.WriteLine(file.Name);
                                sw.Close();
                            }
                            catch (Exception) { }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Lama.log("ERROR", "[LoadPlugins]" + e.Message);
            }
        }