Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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;
                    }
                }
            }
        }
Exemplo n.º 3
0
        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;
                    }
                }
            }
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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;
                }
            }
        }
Exemplo n.º 7
0
 /// <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));
 }
Exemplo n.º 8
0
 private static void TearDown(IWCellAddon addon)
 {
     addon.TearDown();
 }