private void Window_Loaded(object sender, RoutedEventArgs e) { // Get add-in pipeline folder (the folder in which this application was launched from) string appPath = System.IO.Path.Combine(Environment.CurrentDirectory, "AddIns"); //update must use the host root folder AddInStore.Update(Environment.CurrentDirectory); if (System.IO.Directory.Exists(appPath)) { // Rebuild visual add-in pipeline string[] warnings = AddInStore.RebuildAddIns(appPath); if (warnings.Length > 0) { string msg = "Could not rebuild pipeline:"; foreach (string warning in warnings) { msg += "\n" + warning; } MessageBox.Show(msg); return; } } // Activate add-in with Internet zone security isolation Collection <AddInToken> addInTokens = AddInStore.FindAddIns(typeof(IWPFAddInHostView), PipelineStoreLocation.ApplicationBase, new string[] { appPath }); lstAddIns.ItemsSource = addInTokens; }
/// <summary> /// Loads a list of all available AddIns /// </summary> private void Window_Loaded(object sender, RoutedEventArgs e) { string path = Environment.CurrentDirectory; AddInStore.Update(path); string[] s = AddInStore.RebuildAddIns(path); IList <AddInToken> tokens = AddInStore.FindAddIns(typeof(HostView.NumberProcessorHostView), path); lstAddIns.ItemsSource = tokens; automationHost = new AutomationHost(progressBar); }
static void Main(string[] args) { //Init pipline, create PipelineSegments.store and AddIns.store string path = Environment.CurrentDirectory; AddInStore.Update(path); //string[] warnings = AddInStore.Update(path); //foreach (var tmp in warnings) //{ // Console.WriteLine(tmp); //} //发现, used the host side view(without attribute) var tokens = AddInStore.FindAddIns(typeof(HostSideView.HostSideView), path); Console.WriteLine("当前共有{0}个插件可以选择。它们分别为:", tokens.Count); var index = 1; foreach (var tmp in tokens) { Console.WriteLine(string.Format("[{4}]名称:{0},描述:{1},版本:{2},发布者:{3}", tmp.Name, tmp.Description, tmp.Version, tmp.Publisher, index++)); } //[[ find addin in the another folder string anotherAddInPath = @"C:\OutPutForAddIn\Test"; AddInStore.RebuildAddIns(anotherAddInPath); //todo: why there find the addin in the fist folder???? IList <AddInToken> PluginList = AddInStore.FindAddIns(typeof(HostSideView.HostSideView), PipelineStoreLocation.ApplicationBase, anotherAddInPath); //]] var token = ChooseCalculator(tokens); //隔离和激活插件 AddInProcess process = new AddInProcess();//(Platform.X64); process.Start(); var addin = token.Activate <HostSideView.HostSideView>(process, AddInSecurityLevel.FullTrust); Console.WriteLine("PID:{0}", process.ProcessId); //调用插件 Console.WriteLine(addin.Say()); Console.ReadKey(); }
public void LoadApplications(Action <HmeServer> serverAction, params string[] applicationDirectories) { string[] results = AddInStore.Rebuild(PipelineStoreLocation.ApplicationBase); string[] addinResults = AddInStore.RebuildAddIns(applicationDirectories[0]); var addInTokens = AddInStore.FindAddIns(typeof(IHmeApplicationDriver), PipelineStoreLocation.ApplicationBase,//); applicationDirectories); foreach (AddInToken token in addInTokens) { IHmeApplicationDriver driver = token.Activate <IHmeApplicationDriver>(AddInSecurityLevel.Host); Uri assemblyCodeBase = new Uri(driver.GetType().Assembly.GetName().CodeBase); System.IO.FileInfo assemblyFileInfo = new System.IO.FileInfo(assemblyCodeBase.LocalPath); foreach (var identity in driver.ApplicationIdentities) { HmeServer server = new HmeServer(identity, driver); if (serverAction != null) { serverAction(server); } Add(server, identity, assemblyFileInfo.DirectoryName); } } }
static void Main(string[] args) { var errors = AddInStore.Rebuild(PipelinePath); if (errors.Length > 0) { foreach (var error in errors) { Console.WriteLine(error); } Console.ReadKey(); return; } errors = AddInStore.RebuildAddIns(PluginPath); if (errors.Length > 0) { foreach (var error in errors) { Console.WriteLine(error); } Console.ReadKey(); return; } var pluginTokens = AddInStore.FindAddIns(typeof(Plugin), PipelinePath, PluginPath); foreach (var token in pluginTokens) { Console.WriteLine(token.AddInFullName); foreach (var item in token) { Console.WriteLine($"\t{item.Name}:{item.Value}"); } } foreach (var pluginToken in pluginTokens) { var process = new AddInProcess { KeepAlive = false }; //var set = new PermissionSet(PermissionState.Unrestricted); //set.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, Path.GetDirectoryName(t.AssemblyName.CodeBase))); var plugin = pluginToken.Activate <Plugin>(process, AddInSecurityLevel.Host); if (plugin != null) { plugin.SetDefaultLog(new FileLog(LogLevelEnum.All)); if (plugin.Configuration != null) { foreach (var configuration in plugin.Configuration) { Console.WriteLine(configuration.GetType().FullName); } } plugin.Execute(); plugin.Interrupt(); var controller = AddInController.GetAddInController(plugin); controller.Shutdown(); } } Console.ReadKey(); }
public void RefreshPluginStore() { AddInStore.Rebuild(_pipelineRootFolder); AddInStore.RebuildAddIns(_pluginRoot); _plugins = AddInStore.FindAddIns(typeof(IMyPlugin), _pipelineRootFolder, _pluginRoot); }