public static IConfiguration GetConfig(IConfiguration deflt, ITriggerer trigger) { IConfiguration configuration; if (trigger.Text.NextModifiers() == "a") { string shortName = trigger.Text.NextWord(); IWCellAddon addon = WCellAddonMgr.GetAddon(shortName); if (addon == null) { trigger.Reply("Did not find any Addon matching: " + shortName); return((IConfiguration)null); } configuration = addon.Config; if (configuration == null) { trigger.Reply("Addon does not have a Configuration: " + (object)addon); return((IConfiguration)null); } } else { configuration = deflt; } return(configuration); }
public void InitAddon() { if (m_addon == null) { Type[] types; try { types = m_assembly.GetTypes(); } catch (Exception e) { throw new Exception(string.Format("Unable to load Addon {0} - " + "please make sure that it and it's dependencies were built against the current build and all it's dependencies are available.", this), e); } foreach (var type in types) { var interfaces = type.GetInterfaces(); if (interfaces.Contains(typeof(IWCellAddon))) { var addonAttributes = type.GetCustomAttributes<WCellAddonAttribute>(); m_attr = addonAttributes.Length > 0 ? addonAttributes[0] : null; m_addon = (IWCellAddon)Activator.CreateInstance(type); if (m_addon != null) { WCellAddonMgr.RegisterAddon(this); } break; } } } }
public void InitAddon() { if (m_addon == null) { Type[] types; try { types = m_assembly.GetTypes(); } catch (Exception e) { throw new Exception(string.Format("Unable to load Addon {0} - " + "please make sure that it and it's dependencies were built against the current build and all it's dependencies are available.", this), e); } foreach (var type in types) { var interfaces = type.GetInterfaces(); if (interfaces.Contains(typeof(IWCellAddon))) { var addonAttributes = type.GetCustomAttributes <WCellAddonAttribute>(); m_attr = addonAttributes.Length > 0 ? addonAttributes[0] : null; m_addon = (IWCellAddon)Activator.CreateInstance(type); if (m_addon != null) { WCellAddonMgr.RegisterAddon(this); } break; } } } }
protected static void InitAddon(WCellAddonContext context, InitMgr mgr) { IWCellAddon addon = context.Addon; mgr.AddStepsOfAsm(context.Assembly); RealmCommandHandler.Instance.AddCmdsOfAsm(context.Assembly); if (addon == null || !(addon is WCellAddonBase)) { return; } ((WCellAddonBase)addon).InitAddon(context); }
public static bool Unload(WCellAddonContext context) { IWCellAddon addon = context.Addon; if (addon == null) { return(false); } Logger currentClassLogger = LogManager.GetCurrentClassLogger(); currentClassLogger.Info("Unloading Addon: " + context + " ..."); TearDown(addon); Contexts.Remove(context); ContextsByFile.Remove(context.File.FullName); ContextsByName.Remove(context.ShortName); ContextsByTypeName.Remove(addon.GetType().FullName); currentClassLogger.Info("Done. - Unloaded Addon: " + context); return(true); }
public void InitAddon() { if (this.m_addon != null) { return; } Type[] types; try { types = this.m_assembly.GetTypes(); } catch (Exception ex) { throw new Exception( string.Format( "Unable to load Addon {0} - please make sure that it and it's dependencies were built against the current build and all it's dependencies are available.", (object)this), ex); } foreach (Type type in types) { if (((IEnumerable <Type>)type.GetInterfaces()).Contains <Type>(typeof(IWCellAddon))) { WCellAddonAttribute[] customAttributes = type.GetCustomAttributes <WCellAddonAttribute>(); this.m_attr = customAttributes.Length > 0 ? customAttributes[0] : (WCellAddonAttribute)null; this.m_addon = (IWCellAddon)Activator.CreateInstance(type); if (this.m_addon != null) { WCellAddonMgr.RegisterAddon(this); break; } break; } } }
/// <summary> /// /// </summary> public static string GetDefaultDescription(this IWCellAddon addon) { return(String.Format("{0} v{1} by {2} ({3})", addon.Name, addon.GetType().Assembly.GetName().Version, addon.Author, addon.Website)); }
private static void TearDown(IWCellAddon addon) { addon.TearDown(); }