Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            sandboxHost = new SandboxHostFactory(Path.Combine(Environment.CurrentDirectory, "Plugins")).Create();

            RefreshAvailablePlugins();
            RefreshToolsMenu();

            sandboxHost.Loaded += (s, e) =>
            {
                this.Invoke((MethodInvoker) delegate
                {
                    RefreshAvailablePlugins();
                    RefreshToolsMenu();
                    textBoxLog.Text += "Loaded plugin " + e.SandboxeeInfo.Name + Environment.NewLine;
                });
            };

            sandboxHost.Unloaded += (s, e) =>
            {
                this.Invoke((MethodInvoker) delegate
                {
                    RefreshAvailablePlugins();
                    RefreshToolsMenu();
                    textBoxLog.Text += "Unloaded plugin " + e.SandboxeeInfo.Name + Environment.NewLine;
                });
            };
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            assemblyCreator.CreateAssembly("MyPlugin.dll", @"

            using System;
            using System.Reflection;
            using Sandboxer;
            using Sandboxer.Tests.Interfaces;

            [assembly: AssemblyTitle(""My Plugin"")]
            [assembly: Sandboxee]

            namespace MyPlugin
            {
                public class Initializer : ISandboxeeInitializer
                {
                    public void Initialize()
                    {
                    }
                }

                public class WordGenerator : MarshalByRefObject, IWordGenerator
                {
                    public string GenerateWord()
                    {
                        return ""Awesomeville"";
                    }
                }
            }

            ");

            assemblyCreator.CreateAssembly("NoPlugin.dll", @"

            using System.Reflection;

            [assembly: AssemblyTitle(""Some common assembly"")]

            namespace NoPlugin
            {
                public class SomeUsualClass
                {
                }
            }

            ");

            var factory = new SandboxHostFactory(assemblyCreator.PluginsDir);

            sut = factory.Create();
        }