Esempio n. 1
0
 public static void ShutdownManager(BismuthGenericManager manager)
 {
     for (int i = 0; i < managers.Count; ++i)
     {
         if (managers[i].Item2 == manager)
         {
             Tuple <BismuthManagerInfo, BismuthGenericManager> mgr = managers[i];
             managers.RemoveAt(i);
             try
             {
                 if (mgr.Item2.Shutdown())
                 {
                     LogManager.Log("SHUTDOWN", "Successfully shutdown " + mgr.Item1.Name);
                 }
                 else
                 {
                     LogManager.Warn("SHUTDOWN", mgr.Item1.Name + " did not report a successful shutdown");
                 }
             }
             catch (Exception e)
             {
                 LogManager.Error("SHUTDOWN", "Exception when shutting down " + mgr.Item1.Name + "\r\n" + e.ToString());
             }
         }
     }
 }
Esempio n. 2
0
        public static void SetupManagersFromAssembly(Assembly assembly)
        {
            Type[] types = null;
            try
            {
                types = (from type in assembly.GetTypes()
                         where Attribute.IsDefined(type, typeof(BismuthManagerInfo))
                         select type).ToArray();
            }
            catch
            {
                //Could only cause an exception error on a plugin
                LogManager.Error("STARTUP", "Could not load types from plugin '" + assembly.Location + "'. This plugin may be corrupt and has been skipped.");
                return;
            }

            for (int i = 0; i < types.Length; ++i)
            {
                BismuthManagerInfo    managerInfo = types[i].GetCustomAttribute <BismuthManagerInfo>();
                BismuthGenericManager manager     = (BismuthGenericManager)Activator.CreateInstance(types[i]);

                try
                {
                    if (manager.Setup())
                    {
                        LogManager.Log("STARTUP", "Successfully setup " + managerInfo.Name);
                        Tuple <BismuthManagerInfo, BismuthGenericManager> managerTuple = new Tuple <BismuthManagerInfo, BismuthGenericManager>(managerInfo, manager);
                        managers.Add(managerTuple);
                    }
                    else
                    {
                        LogManager.Warn("STARTUP", managerInfo.Name + " did not setup successfully and has been skipped.");
                    }
                }
                catch (Exception e)
                {
                    LogManager.Error("STARTUP", "Exception when setting up " + managerInfo.Name + "\r\n" + e.ToString());
                }
            }
        }
Esempio n. 3
0
 public static void ShutdownManager(BismuthGenericManager manager)
 {
     for (int i = 0; i < managers.Count; ++i)
     {
         if (managers[i].Item2 == manager)
         {
             Tuple<BismuthManagerInfo, BismuthGenericManager> mgr = managers[i];
             managers.RemoveAt(i);
             try
             {
                 if (mgr.Item2.Shutdown())
                     LogManager.Log("SHUTDOWN", "Successfully shutdown " + mgr.Item1.Name);
                 else
                     LogManager.Warn("SHUTDOWN", mgr.Item1.Name + " did not report a successful shutdown");
             }
             catch (Exception e)
             {
                 LogManager.Error("SHUTDOWN", "Exception when shutting down " + mgr.Item1.Name + "\r\n" + e.ToString());
             }
         }
     }
 }