Attribute that needs to be used with all plugins. Specifies information about the plugin (name, version, author, etc.)
Inheritance: System.Attribute
Esempio n. 1
0
 /// <summary>
 /// Destroy the current instance of the plugin
 /// </summary>
 public void DestroyInstance()
 {
     if(_instantiated) {
         _plugin.Unload();
         _plugin = null;
         _attribute = null;
         _instantiated = false;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Create an instance of the plugin
        /// </summary>
        public bool CreateInstance()
        {
            if(_instantiated) {
                Debug.ReportWarning("Trying to instantiate a plugin more than once");
                return true;
            }

            if(pluginType != null) {
                _plugin = (IPlugin)Activator.CreateInstance(pluginType);
                object[] attributes = pluginType.GetCustomAttributes(typeof(PluginAttribute), false);

                foreach(Attribute a in attributes) {
                    if(typeof(PluginAttribute).IsAssignableFrom(a.GetType())) {
                        _attribute = (PluginAttribute)a;
                        _instantiated = true;
                        return true;
                    }
                }
            }

            return false;
        }