public void StoreDescriptorsShouldNoOpIfNoChanges() {
            var container = BuildContainer();
            var clock = (StubClock)container.Resolve<IClock>();
            var appDataFolder = (StubAppDataFolder)container.Resolve<IAppDataFolder>();
            var dependenciesFolder = container.Resolve<IDependenciesFolder>();

            var d1 = new DependencyDescriptor {
                Name = "name1",
                LoaderName = "test1",
                VirtualPath = "~/bin1"
            };

            var d2 = new DependencyDescriptor {
                Name = "name2",
                LoaderName = "test2",
                VirtualPath = "~/bin2"
            };

            dependenciesFolder.StoreDescriptors(new[] { d1, d2 });
            var dateTime1 = appDataFolder.GetLastWriteTimeUtc(Path.Combine("Dependencies", "Dependencies.xml"));
            clock.Advance(TimeSpan.FromMinutes(1));

            dependenciesFolder.StoreDescriptors(new[] { d2, d1 });
            var dateTime2 = appDataFolder.GetLastWriteTimeUtc(Path.Combine("Dependencies", "Dependencies.xml"));
            Assert.That(dateTime1, Is.EqualTo(dateTime2));
        }
        public override void ExtensionRemoved(ExtensionLoadingContext ctx, DependencyDescriptor dependency) {
            if (_assemblyProbingFolder.AssemblyExists(dependency.Name)) {
                ctx.DeleteActions.Add(
                    () => {
                        Logger.Information("ExtensionRemoved: Deleting assembly \"{0}\" from probing directory", dependency.Name);
                        _assemblyProbingFolder.DeleteAssembly(dependency.Name);
                    });

                // We need to restart the appDomain if the assembly is loaded
                if (_hostEnvironment.IsAssemblyLoaded(dependency.Name)) {
                    Logger.Information("ExtensionRemoved: Module \"{0}\" is removed and its assembly is loaded, forcing AppDomain restart", dependency.Name);
                    ctx.RestartAppDomain = true;
                }
            }
        }
        public void StoreDescriptorsShouldWork() {
            var dependenciesFolder = BuildContainer().Resolve<IDependenciesFolder>();

            var d = new DependencyDescriptor {
                Name = "name",
                LoaderName = "test",
                VirtualPath = "~/bin"
            };

            dependenciesFolder.StoreDescriptors(new[] { d });
            var e = dependenciesFolder.LoadDescriptors();
            Assert.That(e, Has.Count.EqualTo(1));
            Assert.That(e.First().Name, Is.EqualTo("name"));
            Assert.That(e.First().LoaderName, Is.EqualTo("test"));
            Assert.That(e.First().VirtualPath, Is.EqualTo("~/bin"));
        }
Exemplo n.º 4
0
 public virtual void ExtensionRemoved(ExtensionLoadingContext ctx, DependencyDescriptor dependency) { }
 public override void ExtensionRemoved(ExtensionLoadingContext ctx, DependencyDescriptor dependency) {
 }
 public override IEnumerable<string> GetVirtualPathDependencies(DependencyDescriptor dependency) {
     // Return csproj and all .cs files
     return GetDependencies(dependency.VirtualPath);
 }
 public override IEnumerable<ExtensionCompilationReference> GetCompilationReferences(DependencyDescriptor dependency) {
     yield return new ExtensionCompilationReference { BuildProviderTarget = dependency.VirtualPath };
 }
        private string GetExtensionHash(ExtensionLoadingContext context, DependencyDescriptor dependencyDescriptor) {
            var hash = new Hash();
            hash.AddStringInvariant(dependencyDescriptor.Name);

            foreach (var virtualpathDependency in context.ProcessedExtensions[dependencyDescriptor.Name].VirtualPathDependencies) {
                hash.AddDateTime(GetVirtualPathModificationTimeUtc(context.VirtualPathModficationDates, virtualpathDependency));
            }

            foreach (var reference in dependencyDescriptor.References) {
                hash.AddStringInvariant(reference.Name);
                hash.AddString(reference.LoaderName);
                hash.AddDateTime(GetVirtualPathModificationTimeUtc(context.VirtualPathModficationDates, reference.VirtualPath));
            }

            return hash.Value;
        }
 public IEnumerable<string> GetVirtualPathDependencies(DependencyDescriptor dependency) {
     throw new NotImplementedException();
 }
 public override IEnumerable<string> GetVirtualPathDependencies(DependencyDescriptor dependency) {
     yield return _assemblyProbingFolder.GetAssemblyVirtualPath(dependency.Name);
 }
Exemplo n.º 11
0
 public void ExtensionRemoved(ExtensionLoadingContext ctx, DependencyDescriptor dependency) {
     throw new NotImplementedException();
 }
        public void LoadDescriptorsShouldWorkAcrossInstances() {
            var container = BuildContainer();
            var clock = (StubClock)container.Resolve<IClock>();
            var appDataFolder = (StubAppDataFolder)container.Resolve<IAppDataFolder>();
            var dependenciesFolder = container.Resolve<IDependenciesFolder>();

            var d1 = new DependencyDescriptor {
                Name = "name1",
                LoaderName = "test1",
                VirtualPath = "~/bin1"
            };

            var d2 = new DependencyDescriptor {
                Name = "name2",
                LoaderName = "test2",
                VirtualPath = "~/bin2"
            };

            dependenciesFolder.StoreDescriptors(new[] { d1, d2 });

            // Create a new instance over the same appDataFolder
            var dependenciesFolder2 = container.Resolve<IDependenciesFolder>();
            Assert.That(dependenciesFolder2, Is.Not.SameAs(dependenciesFolder));

            // Ensure descriptors were persisted properly
            var result = dependenciesFolder2.LoadDescriptors();
            Assert.That(result, Has.Count.EqualTo(2));
            Assert.That(result.Select(p => p.Name), Has.Some.EqualTo("name1"));
            Assert.That(result.Select(p => p.Name), Has.Some.EqualTo("name2"));
        }
 public override void ExtensionRemoved(ExtensionLoadingContext ctx, DependencyDescriptor dependency) {
     DeleteAssembly(ctx, dependency.Name);
 }
Exemplo n.º 14
0
 public IEnumerable<string> GetFileHashDependencies(DependencyDescriptor dependency) {
     return GetDependencies(dependency.VirtualPath);
 }
Exemplo n.º 15
0
 public virtual IEnumerable<ExtensionCompilationReference> GetCompilationReferences(DependencyDescriptor dependency) {
     return Enumerable.Empty<ExtensionCompilationReference>();
 }
Exemplo n.º 16
0
 public IEnumerable<ExtensionCompilationReference> GetCompilationReferences(DependencyDescriptor dependency) {
     throw new NotImplementedException();
 }
Exemplo n.º 17
0
 public virtual IEnumerable<string> GetVirtualPathDependencies(DependencyDescriptor dependency) {
     return Enumerable.Empty<string>();
 }
 public override IEnumerable<ExtensionCompilationReference> GetCompilationReferences(DependencyDescriptor dependency) {
     yield return new ExtensionCompilationReference { AssemblyName = dependency.Name };
 }