GetInstance() public static method

Return instance with lowest number of channels
public static GetInstance ( ) : Instance
return Instance
Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="wmib.Channel"/> class.
        /// </summary>
        /// <param name='name'>
        /// Name.
        /// </param>
        public Channel(string name)
        {
            Name        = name;
            Suppress    = false;
            SystemUsers = new Security(this);
            LoadConfig();
            if (DefaultInstance == "any")
            {
                PrimaryInstance = Instance.GetInstance();
                // we need to save the instance so that next time bot reconnect to bouncer it uses the same instance
                DefaultInstance = PrimaryInstance.Nick;
                SaveConfig();
            }
            else
            {
                if (!Instance.Instances.ContainsKey(DefaultInstance))
                {
                    Syslog.WarningLog("There is no instance " + DefaultInstance + " reassigning channel " + this.Name +
                                      " to a different instance");
                    this.PrimaryInstance = Instance.GetInstance();
                    Syslog.Log("Reassigned to " + this.PrimaryInstance.Nick);
                }
                else
                {
                    PrimaryInstance = Instance.Instances[DefaultInstance];
                }
            }
            if (!Directory.Exists(Configuration.WebPages.HtmlPath))
            {
                Directory.CreateDirectory(Configuration.WebPages.HtmlPath);
            }

            foreach (Module module in ExtensionHandler.ExtensionList)
            {
                try
                {
                    if (module.IsWorking)
                    {
                        Channel self = this;
                        module.Hook_Channel(self);
                    }
                }
                catch (Exception fail)
                {
                    Syslog.Log("MODULE: exception at Hook_Channel in " + module.Name, true);
                    Core.HandleException(fail);
                }
            }
        }