public void LoadComponents() { foreach (ComponentClass relogComponent in _components) { relogComponent.Component.OnUnload(); } _components.Clear(); try { if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "Components")) { return; } var di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "Components"); foreach (FileInfo fi in di.GetFiles()) { if (fi.Extension.ToLower() == ".dll") { try { Assembly assembly = Assembly.LoadFrom(fi.FullName); if (assembly != null) { String fName = fi.Name.Replace(fi.Extension, String.Empty); ComponentClass toRemove = _components.FirstOrDefault(c => c.Component.GetName() == fName); if (toRemove != null) { _components.Remove(toRemove); } foreach (Type t in assembly.GetTypes()) { if (t.GetInterface("IRelogComponent") != null && t.IsClass) { object obj = Activator.CreateInstance(t); var component = (IRelogComponent)obj; AddComponent(component); } } } } catch (Exception ex) { Logger.LoggingObject.Log(ELogType.Error, ex.Message); } } } } catch (Exception ex) { Logger.LoggingObject.Log(ELogType.Error, ex.Message); } foreach (ComponentClass relogComponent in _components) { relogComponent.Component.OnLoad(); } }
public void OpenSettingsForm(string nameofComponentToCall, Account account = null) { ComponentClass first = _components.FirstOrDefault(c => c.Component.GetName() == nameofComponentToCall); if (first != null) { OpenSettingsForm(first.Component, account); } }
public void EnableComponent(string componentToEnable) { ComponentClass first = _components.FirstOrDefault(c => c.Component.GetName() == componentToEnable); if (first != null) { first.IsEnabled = true; first.Component.OnEnable(); Logger.LoggingObject.Log(ELogType.Info, LanguageManager.Singleton.GetTranslation( ETranslations.ComponentManagerEnableComponent), componentToEnable); } }
public bool HasComponentOfType(Type componentToCheck) { ComponentClass first = _components.FirstOrDefault(c => c.Component.GetType() == componentToCheck); return(first != null && first.Component != null); }
public bool HasComponentWithName(string componentToCheck) { ComponentClass first = _components.FirstOrDefault(c => c.Component.GetName() == componentToCheck); return(first != null && first.Component != null); }