// 获取所有插件探测 (Addin Probing) 目录下的所有可扫描插件文件(新增或更改的文件) internal static ScanFilePackResult GetScanFilePackResult(AddinFileSettings addinFileSettings, IEnumerable <AddinFilePack> existingFilePacks) { var result = new ScanFilePackResult(); var appDir = SystemHelper.AppDirectory; if (addinFileSettings.IndividualAddinDirectories != null) { foreach (var individualAddinDir in addinFileSettings.IndividualAddinDirectories) { GetScanFilePack(individualAddinDir, string.Empty, existingFilePacks, ref result); } } foreach (var probingDirectory in addinFileSettings.AddinProbingDirectories) { GetScanFilePacks(appDir, probingDirectory, existingFilePacks, ref result); } if (result.ScanFilePacks == null || result.ScanFilePackCount == 0) { return(null); } GetApplicationAssemblies(appDir, result); return(result); }
static void ValidateAddinProbingDirectory(AddinFileSettings addinFileConfig, string addinProbingPath) { var match = false; foreach (var probingDirectory in addinFileConfig.AddinProbingDirectories) { if (probingDirectory.Equals(addinProbingPath, StringComparison.InvariantCultureIgnoreCase)) { match = true; } } if (!match) { throw new InvalidOperationException(""); } }
internal AddinFramework(AddinOptions options) { _repository = new AddinRepository(); _messageDialog = options.MessageDialog ?? new DefaultMessageDialog(); _nameConvention = options.NameConvention ?? new DefaultNameConvention(); _fileSettings = options.FileSettings ?? new AddinFileSettings(); _assemblyLoadPolicy = options.AssemblyLoadPolicy ?? new DefaultAssemblyLoadPolicy(); _ebFactory = options.ExtensionBuilderFactory ?? new ReflectionExtensionBuilderFactory(); _epFactory = options.ExtensionPointFactory ?? new ReflectionExtensionPointFactory(); _eventBroker = options.EventBroker ?? new EventBroker(new EventBrokerOption()); _serviceProvider = options.ServiceProvider ?? new DefaultServiceProvider(); _stringLocalizer = options.StringLocalizer ?? new DefaultStringLocalizer(); LogManager.Initialize(new FileLogSetting(_fileSettings.DataDirectory, AddinFileSettings.LogFileName)); _logger = LogManager.GetDefaultLogger(); _properties = new Dictionary <HashKey, object>(); }
static void DoInitialize() { //var trustLevel = WebHelper.GetTrustLevel(); if (_addinEngine != null) { return; } var fileSettings = new AddinFileSettings(AddinFileSettings.DefaultAddinDataDirectory, new[] { "bin" }, new[] { AddinFileSettings.DefaultAddinProbingDirectory }); var addinOptions = AddinOptions.Create().WithAssemblyLoadPolicy(new MvcAssemblyLoadPolicy()).WithFileSettings(fileSettings); _addinEngine = new AddinEngine(addinOptions); _addinEngine.Initialize(true); var addins = _addinEngine.GetAllAddins(); foreach (var addin in addins) { PrepareAddin(addin); } _addinEngine.Start(); //addins = _addinEngine.GetStartedAddins(); ////var probingPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath; //foreach (var addin in addins) //{ // //probingPath += addin.File.BaseDirectory + ";"; // //var asms = addin.Runtime.LoadAssemblies(); // //foreach (var asm in asms) // // BuildManagerHelper.AddReferencedAssemblyNormally(asm); //} ////AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = probingPath; //var menustrip = new MvcMenuStrip(); //_addinEngine.LoadExtensionPoint(menustrip); //_addinEngine.Framework.SetProperty("MvcMenuStrip", menustrip); }
// @return value: whether the persistence file has been updated. public ResolutionResult Resolve(INameConvention nameConvention, AddinFileSettings fileSettings, AssemblyLoadPolicy assemblyLoadPolicy, AddinStorage addinStorage, AddinRelationManager relationManager, ScanFilePackResult scanFilePackResult) { var ctx = new ResolutionContext(); var cm = new ConvertionManager(); InitializeDataTransformers(ctx, cm); if (assemblyLoadPolicy.PrivateAssemblyProbingDirectories != null) { foreach (var privateAssemblyProbingDirectory in assemblyLoadPolicy.PrivateAssemblyProbingDirectories) { AssemblyResolution.AddSearchDirectory(privateAssemblyProbingDirectory); } } var resolver = new DefaultAddinResolver(addinStorage, relationManager, cm); // 强制 ExtensionBuilder 节点应用 NameConvention return(resolver.Resolve(nameConvention, ctx, scanFilePackResult)); }
// 获取指定插件探测 (Addin Probing) 目录下的可扫描插件文件 internal static ScanFilePack GetScanFilePack(AddinFileSettings addinFileConfig, IEnumerable <AddinFilePack> existingFilePacks, string addinProbingPath, string addinDirectory) { ValidateAddinProbingDirectory(addinFileConfig, addinProbingPath); return(null); }
public AddinOptions WithFileSettings(AddinFileSettings fileSettings) { _fileSettings = fileSettings; return(this); }