Exemple #1
0
        public static PluginSandbox FindPlugins(Type basetype)
        {
            PluginSandbox c = new PluginSandbox();

            c.foundPlugins = new List <string>();


            //GET THE CURRENT ASSEMBLY AND PATH
            string file = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string path = Path.GetDirectoryName(file);


            //CREATE A SANDBOX TO LOAD ALL PLUGINS FOR EXAMINATION
            AppDomain     sandbox = AppDomain.CreateDomain("sandbox");
            PluginSandbox b       = (PluginSandbox)sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(PluginSandbox).FullName);

            foreach (string d in b.test(path, basetype))
            {
                c.foundPlugins.Add(d);
            }


            AppDomain.Unload(sandbox);
            return(c);
        }
Exemple #2
0
        public static PluginSandbox FindPlugins(Type basetype)
        {
            PluginSandbox c = new PluginSandbox();
            c.foundPlugins = new List<string>();

            //GET THE CURRENT ASSEMBLY AND PATH
            string file = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string path = Path.GetDirectoryName(file);

            //CREATE A SANDBOX TO LOAD ALL PLUGINS FOR EXAMINATION
            AppDomain sandbox = AppDomain.CreateDomain("sandbox");
            PluginSandbox b = (PluginSandbox)sandbox.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(PluginSandbox).FullName);
            foreach (string d in b.test(path, basetype))
            {
                c.foundPlugins.Add(d);
            }

            AppDomain.Unload(sandbox);
            return c;
        }
Exemple #3
0
        private static string FindPlugin(Type type, string pluginDefault)
        {
            PluginSandbox plugins = PluginSandbox.FindPlugins(type);

            int a = 0;

            foreach (string plugin in plugins.foundPlugins)
            {
                string[] arr      = plugin.Split(new char[] { ',' }, 2);
                string   assembly = arr[0];
                string   typed    = arr[1];
                Console.WriteLine("{0} {1}", ++a, typed);
            }

            Console.WriteLine("Enter the number corresponding the plugin");
            while (!int.TryParse(Console.ReadLine(), out a))
            {
                Console.WriteLine("Please enter a number");
            }

            return((a > 0 && a <= plugins.foundPlugins.Count) ? plugins.foundPlugins[a - 1] : pluginDefault);
        }