예제 #1
0
        public void TestLoad2()
        {
            var assemblyFileName = "Foo2.dll";

            if (File.Exists(assemblyFileName))
            {
                File.Delete(assemblyFileName);
            }

            var builder = new PluginBuilder("Simon", "Foo2", "Foo2", "Simon", "None of your business", "Get of my lawn");

            builder.ImplementInterface <IFileFormatPlugin>("Foo2.MyAwesomePlugin");
            builder.Save();
            var description = new PluginDescription
            {
                FilePath = assemblyFileName,
                PluginImplementations = new List <IPluginImplementationDescription>
                {
                    new PluginImplementationDescription("Foo2.MyAwesomePlugin", typeof(IFileFormatPlugin))
                }
            };

            using (var scanner = new PluginAssemblyLoader())
            {
                var plugin = scanner.Load <IFileFormatPlugin>(description, description.PluginImplementations[0]);
                plugin.Should().NotBeNull();
                plugin.GetType().FullName.Should().Be("Foo2.MyAwesomePlugin");
            }
        }
예제 #2
0
        public void TestLoad1()
        {
            var assemblyFileName = "Foo1.dll";

            if (File.Exists(assemblyFileName))
            {
                File.Delete(assemblyFileName);
            }

            var builder = new PluginBuilder("Simon", "Foo1", "Foo1", "Simon", "None of your business", "Get of my lawn");

            builder.ImplementInterface <IFileFormatPlugin>("Foo1.MyAwesomePlugin");
            builder.Save();
            var description = new PluginDescription
            {
                FilePath = assemblyFileName,
                Plugins  = new Dictionary <Type, string>
                {
                    { typeof(IFileFormatPlugin), "Foo1.MyAwesomePlugin" }
                }
            };

            using (var scanner = new PluginAssemblyLoader())
            {
                var plugin = scanner.Load <IFileFormatPlugin>(description);
                plugin.Should().NotBeNull();
                plugin.GetType().FullName.Should().Be("Foo1.MyAwesomePlugin");
            }
        }
예제 #3
0
        public void TestScanAndLoad()
        {
            using (var scanner = new PluginAssemblyLoader())
            {
                var assemblyFileName = "Foo3.dll";
                if (File.Exists(assemblyFileName))
                {
                    File.Delete(assemblyFileName);
                }

                var builder = new PluginBuilder("Simon", "Foo3", "Foo3", "Simon", "None of your business", "Get of my lawn");
                builder.ImplementInterface <IFileFormatPlugin>("Foo3.MyAwesomePlugin");
                builder.Save();

                var description = scanner.ReflectPlugin(assemblyFileName);
                var plugin      = scanner.Load <IFileFormatPlugin>(description, description.PluginImplementations[0]);
                plugin.Should().NotBeNull();
                plugin.GetType().FullName.Should().Be("Foo3.MyAwesomePlugin");
            }
        }