示例#1
0
        public void ShouldNotDisposeExternalIFileSystemWatcher()
        {
            MockFileSystemWatcher mockwatcher = new MockFileSystemWatcher();
            IPluginDirectory      tested      = new PluginDirectory(mockwatcher);
            bool wasDisposed = false;

            mockwatcher.Disposed += (s, e) => wasDisposed = true;
            tested.Dispose();
            Assert.IsFalse(wasDisposed);
        }
示例#2
0
        public void ShouldDisposeOwnedFileSystemWatcher()
        {
            MockFileSystemWatcher mockwatcher = new MockFileSystemWatcher();
            PluginDirectory       tested      = new PluginDirectory(new MockFileSystemWatcher());
            bool wasDisposed = false;

            tested.WatcherConnect(mockwatcher, true);
            mockwatcher.Disposed += (s, e) => wasDisposed = true;
            tested.Dispose();
            Assert.IsTrue(wasDisposed);
        }
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            AssemblyContainer assemblyContainer = new AssemblyContainer();

              PluginRepository pluginRepository = new PluginRepository();
              pluginRepository.AddPluginSource(new PluginExtractor(assemblyContainer));

              System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
              string pluginDir = settingsReader.GetValue("PluginPath", typeof(string)) as string;
              PluginDirectory pluginDirectory = new PluginDirectory(pluginDir, true);
              assemblyContainer.AddDir(pluginDirectory);

              container.Register(
            Component.For<IPluginRepository>().LifestyleSingleton().Instance(pluginRepository),

            Component.For<IAssemblyRepository>().LifestyleSingleton().Instance(assemblyContainer)
            .OnDestroy(kernel => { assemblyContainer.RemoveDir(pluginDirectory); pluginDirectory.Dispose(); })
              );
        }
        public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store)
        {
            AssemblyContainer assemblyContainer = new AssemblyContainer();

            PluginRepository pluginRepository = new PluginRepository();

            pluginRepository.AddPluginSource(new PluginExtractor(assemblyContainer));

            System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
            string          pluginDir       = settingsReader.GetValue("PluginPath", typeof(string)) as string;
            PluginDirectory pluginDirectory = new PluginDirectory(pluginDir, true);

            assemblyContainer.AddDir(pluginDirectory);

            container.Register(
                Component.For <IPluginRepository>().LifestyleSingleton().Instance(pluginRepository),

                Component.For <IAssemblyRepository>().LifestyleSingleton().Instance(assemblyContainer)
                .OnDestroy(kernel => { assemblyContainer.RemoveDir(pluginDirectory); pluginDirectory.Dispose(); })
                );
        }
 public void ShouldNotDisposeExternalIFileSystemWatcher()
 {
     MockFileSystemWatcher mockwatcher = new MockFileSystemWatcher();
       IPluginDirectory tested = new PluginDirectory(mockwatcher);
       bool wasDisposed = false;
       mockwatcher.Disposed += (s, e) => wasDisposed = true;
       tested.Dispose();
       Assert.IsFalse(wasDisposed);
 }
 public void ShouldDisposeOwnedFileSystemWatcher()
 {
     MockFileSystemWatcher mockwatcher = new MockFileSystemWatcher();
       PluginDirectory tested = new PluginDirectory(new MockFileSystemWatcher());
       bool wasDisposed = false;
       tested.WatcherConnect(mockwatcher, true);
       mockwatcher.Disposed += (s, e) => wasDisposed = true;
       tested.Dispose();
       Assert.IsTrue(wasDisposed);
 }