Beispiel #1
0
        /// <summary>
        /// Constructs a new PluginInfo
        /// </summary>
        /// <param name="filename">Path to the plugin.</param>
        /// <param name="plugin">Valid plugin instance. Must not be null.</param>
        /// <exception cref="ArgumentNullException"><paramref name="plugin"/> is <see langword="null"/></exception>
        public PluginInfo(string filename, IRadegastPlugin plugin)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            PluginInstance = plugin;
            FileName       = filename;
            DisplayName    = PluginInstance.GetType().Name;

            PluginAttribute pluginAttributes = null;

            try
            {
                var customAttributes = Attribute.GetCustomAttributes(PluginInstance.GetType());
                pluginAttributes = customAttributes.First(attribute => attribute is PluginAttribute) as PluginAttribute;
            }
            catch
            {
                // Suppress
            }

            Attribures = pluginAttributes ?? new PluginAttribute {
                Name = PluginInstance.GetType().FullName
            };
        }
Beispiel #2
0
        /// <summary>
        /// Gets extended atributes for plugin
        /// </summary>
        /// <param name="plug">Plugin to lookup extra attributes</param>
        /// <returns>Extended atributes for plugin</returns>
        public static PluginAttribute GetAttributes(IRadegastPlugin plug)
        {
            PluginAttribute a = null;

            foreach (Attribute attr in Attribute.GetCustomAttributes(plug.GetType()))
            {
                if (attr is PluginAttribute)
                {
                    a = (PluginAttribute)attr;
                }
            }

            if (a == null)
            {
                a      = new PluginAttribute();
                a.Name = plug.GetType().FullName;
            }

            return(a);
        }
        /// <summary>
        /// Gets extended atributes for plugin
        /// </summary>
        /// <param name="plug">Plugin to lookup extra attributes</param>
        /// <returns>Extended atributes for plugin</returns>
        public static PluginAttribute GetAttributes(IRadegastPlugin plug)
        {
            PluginAttribute a = null;

            foreach (Attribute attr in Attribute.GetCustomAttributes(plug.GetType()))
            {
                if (attr is PluginAttribute)
                    a = (PluginAttribute)attr;
            }

            if (a == null)
            {
                a = new PluginAttribute();
                a.Name = plug.GetType().FullName;
            }

            return a;
        }