Example #1
0
        /// <summary>
        /// Adds a plugin.
        /// </summary>
        /// <param name="asm">The asm.</param>
        public static void AddPlugin(Assembly asm)
        {
            try {
                foreach(Type type in asm.GetTypes()) {
                    if(type.IsAbstract) continue;
                    PluginInfo i = new PluginInfo();
                    AssemblyName nameInfo = asm.GetName();
                    i.Name = nameInfo.FullName;
                    i.Version = nameInfo.Version.Major + "." + nameInfo.Version.Minor +
                        " build " + nameInfo.Version.Build;
                        object[] c = asm.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
                        i.Author = ((AssemblyCopyrightAttribute)c[0]).Copyright;
                        c = asm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                        i.Description = ((AssemblyDescriptionAttribute)c[0]).Description;
                        c = asm.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
                        string prodcut = ((AssemblyProductAttribute)c[0]).Product;
                        if(prodcut.Length > 0) {
                            i.Name = prodcut;
                        }

                    AddPlugin(type, i);
                }
            } catch (Exception ex){
                string asmName = String.Empty;
                try{
                    asmName = asm.GetName().FullName;
                }catch (Exception  _ex){
                    asmName = String.Format("Cannot interogate assembly.: {0}",_ex.Message);
                }
                String.Format(@"A Plugin threw an exception on Assembly.GetTypes().
            This is probably due to a version mismatch.  Make sure your plugin is compiled using
            the version of Rendition this site is running ({2}).  If your plugin is used in .aspx pages make sure
            the plugin is added to the Global Assembly Cache.
            Source: {0}
            Error: {1} ", asmName, getInnermostException(ex).Message, Main.Version).Debug(1);
            }
        }
Example #2
0
 /// <summary>
 /// Adds a plugin.
 /// </summary>
 /// <param name="plugin">The plugin.</param>
 /// <param name="pinfo">The pinfo.</param>
 public static void AddPlugin(Type plugin, PluginInfo pinfo)
 {
     if(plugin.BaseType.FullName == "Rendition.Plugin") {
         /* see if the plugin is revoked */
         if(!isPluginRevoked(plugin.GUID)) {
             /* this is a plugin
              * add it to the plugin list
              */
             try {
                 Plugin p = Activator.CreateInstance(plugin) as Plugin;
                 p.Info = pinfo;
                 Plugins.Add(p);
                 ("Plugin Loaded:" + p.Info.Name + " v." + p.Info.Version).Debug(5);
             } catch(ReflectionTypeLoadException e) {
                 String.Format("Plugin threw an exception on Activator.CreateInstance.{0}",
                 e.LoaderExceptions).Debug(1);
             }
         } else {
             string[] pluginData = { plugin.FullName, plugin.GUID.ToString() };
             RevokedPlugins.Add(pluginData);
         }
     }
 }