/// <summary> /// 监控扩展。 /// </summary> /// <param name="descriptor">扩展描述符条目。</param> /// <param name="monitor">监控动作。</param> public override void Monitor(ExtensionDescriptorEntry descriptor, Action <IVolatileToken> monitor) { if (Disabled) { return; } if (DisableMonitoring) { return; } //如果程序集文件存在则进行监控。 var assemblyPath = GetAssemblyPath(descriptor); if (assemblyPath != null) { Logger.Debug("监控虚拟路径 \"{0}\"", assemblyPath); monitor(_applicationFolder.WhenPathChanges(assemblyPath)); return; } //如果该组件不存在,我们监测含有“bin”文件夹后,如果是在Visual Studio中,例如重新编译的组件可能存在,我们需要改变配置检测。 var assemblyDirectory = _applicationFolder.Combine(descriptor.Location, descriptor.Id, "bin"); if (!_applicationFolder.DirectoryExists(assemblyDirectory)) { return; } Logger.Debug("监控虚拟路径 \"{0}\"", assemblyDirectory); monitor(_applicationFolder.WhenPathChanges(assemblyDirectory)); }
/* private IEnumerable<KeyValuePair<AssemblyDescriptor, string>> GetModuleAssemblyPaths(ExtensionDescriptorEntry descriptor) * { * if (descriptor.Descriptor == null || descriptor.Descriptor.Runtime == null || descriptor.Descriptor.Runtime.Assemblies == null) * return null; * return descriptor.Descriptor.Runtime.Assemblies.ToDictionary(i => i, * v => _applicationFolder.Combine(descriptor.Location, descriptor.Id, "bin", v.Name + ".dll")); * }*/ private string GetModuleAssemblyPath(ExtensionDescriptorEntry descriptor) { return(_applicationFolder.Combine(descriptor.Location, descriptor.Id, "bin", descriptor.Id + ".dll")); }