Exemplo n.º 1
0
            public void DoCallback()
            {
                string pluginName = PluginName;

                var assembly = Assembly.LoadFrom(Path.Combine("plugins", pluginName));
                if(assembly == null) return;
                var attribute =
                    assembly.GetCustomAttributes(typeof(PluginAssemblyAttribute), false).SingleOrDefault() as PluginAssemblyAttribute;
                if (attribute == null) throw new InvalidOperationException("The given plugin assembly does not contain a plugin descriptor");

                var descriptor = new PluginDescriptor
                {
                    BaseDll = pluginName,
                    Description = attribute.Description,
                    FriendlyName = attribute.FriendlyName,
                    Version = attribute.Version
                };

                AppDomain.CurrentDomain.SetData("descriptor", descriptor);
            }
Exemplo n.º 2
0
 private static void GeneratePluginDescriptor(string file)
 {
     var descriptor = new PluginDescriptor();
     Console.Write("Friendly name: ");
     descriptor.FriendlyName = Console.ReadLine();
     Console.Write("Version: ");
     descriptor.Version = Console.ReadLine();
     Console.Write("Description: ");
     descriptor.Description = Console.ReadLine();
     Console.Write("Base DLL: ");
     descriptor.BaseDll = Console.ReadLine();
     File.WriteAllText(file, JsonConvert.SerializeObject(descriptor));
     Console.WriteLine("Plugin descriptor '{0}' generated.", file);
 }