예제 #1
0
        static void Main()
        {
            // Assume that the current directory is the application folder,
            // and that it contains the pipeline folder structure.
            //String addInRoot = Environment.CurrentDirectory + "\\Pipeline";
            const string addInRoot = @"..\..\..\Pipeline";

            // Update the cache files of the pipeline segments and add-ins.
            string[] warnings = AddInStore.Update(addInRoot);
            foreach (string warning in warnings)
            {
                Console.WriteLine(warning);
            }

            // Search for add-ins of type ICalculator (the host view of the add-in).
            Collection <AddInToken> tokens =
                AddInStore.FindAddIns(typeof(ICalculator), addInRoot);

            // Ask the user which add-in they would like to use.
            AddInToken calcToken = ChooseCalculator(tokens);

            // Activate the selected AddInToken in a new application domain
            // with the Internet trust level.
            ICalculator calc = calcToken.Activate <ICalculator>(AddInSecurityLevel.Internet);

            // Run the add-in.
            RunCalculator(calc);
        }
예제 #2
0
        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;
        }
예제 #3
0
 private void UpdateStore(object sender, RoutedEventArgs e)
 {
     string[] messages = AddInStore.Update(Settings.Default.PipelinePath);
     if (messages.Length != 0)
     {
         MessageBox.Show(string.Join("\n", messages), "AddInStore Warnings", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
예제 #4
0
        private void OnHostAppWindowLoaded(object sender, RoutedEventArgs e)
        {
            var addInPath = Environment.CurrentDirectory;

            AddInStore.Update(addInPath);
            IList <AddInToken> tokens = AddInStore.FindAddIns(typeof(ImageProcessorHostView), addInPath);

            AddInListBox.ItemsSource = tokens;
        }
예제 #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string path = Environment.CurrentDirectory;

            AddInStore.Update(path);

            IList <AddInToken> tokens = AddInStore.FindAddIns(typeof(HostView.ImageProcessorHostView), path);

            lstAddIns.ItemsSource = tokens;
        }
        private void OnUpdateStore(object sender, RoutedEventArgs e)
        {
            var messages = AddInStore.Update(_DefaultPipelinePath);

            if (messages.Length != 0)
            {
                MessageBox.Show(string.Join(Environment.NewLine, messages), "AddInStore Warnings", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
            }
        }
예제 #7
0
        private void OnHostAppWindowLoaded(object sender, RoutedEventArgs e)
        {
            var path = Environment.CurrentDirectory;

            AddInStore.Update(path);

            IList <AddInToken> tokens = AddInStore.FindAddIns(typeof(ImageProcessorHostView), path);

            AddInListBox.ItemsSource = tokens;

            _automationHost = new AutomationHost(AddInProcessProgressBar);
        }
예제 #8
0
        public static void UpdateInstalledModules()
        {
            AddInStore.Update(AddInPipelineRoot);
            var addins = AddInStore.FindAddIns(typeof(IModule), AddInPipelineRoot);

            foreach (var token in addins)
            {
                if (!Modules.Any(m => m._token.Equals(token)))
                {
                    Modules.Add(new Module(token));
                }
            }
        }
예제 #9
0
        private void AddInsInit()
        {
            string strAddInPath = Environment.CurrentDirectory;

            AddInStore.Update(strAddInPath);

            tokens = AddInStore.FindAddIns(typeof(HostView.KPICaculaterHostView), strAddInPath);
            AddInList.ItemsSource = tokens;
            if (tokens.Count > 0)
            {
                AddInList.SelectedIndex = 0;
            }
        }
예제 #10
0
        /// <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);
        }
예제 #11
0
        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();
        }
예제 #12
0
        public MainWindow()
        {
            InitializeComponent();

            _addInRoot = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location),
                "Pipeline");


            string[] warnings = AddInStore.Update(_addInRoot);

            Collection <AddInToken> tokens = AddInStore.FindAddIns(typeof(IAccessComposition), _addInRoot);

            comboBoxProvider.ItemsSource   = tokens;
            comboBoxProvider.SelectedIndex = 0;

            //radioButtonLoad.IsChecked = true;
            radioButtonSave.IsChecked = true;
        }
예제 #13
0
        /// <summary>
        ///     Loads the plugins.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">Invalid assembly path.</exception>
        private static List <PluginWrapper> LoadPlugins( )
        {
            /////
            // Get the current path.
            /////
            string currentPath = Path.GetDirectoryName(Assembly.GetEntryAssembly( ).Location);

            if (currentPath == null)
            {
                throw new ArgumentException("Invalid assembly path.");
            }

            string addInRoot = Path.Combine(currentPath, "Pipeline");

            /////
            // Update the cache files of the pipeline segments and add-ins.
            /////
            string[] warnings = AddInStore.Update(addInRoot);

            foreach (string warning in warnings)
            {
                EventLog.Instance.WriteWarning(warning);
            }

            /////
            // Search for add-ins of type IPlugin (the host view of the add-in).
            /////
            List <AddInToken> tokens = AddInStore.FindAddIns(typeof(IPlugin), addInRoot).ToList( );

            var plugins = new List <PluginWrapper>( );

            foreach (AddInToken token in tokens)
            {
                EventLog.Instance.WriteTrace("Activating '{0}' from assembly '{1}'...", token.Name, token.AssemblyName);

                var plugin = token.Activate <IPlugin>(AddInSecurityLevel.FullTrust);

                plugins.Add(new PluginWrapper(token, plugin));
            }

            return(plugins);
        }
예제 #14
0
        public PluginLoader()
        {
            var directoryInfo = new DirectoryInfo(Assembly.GetExecutingAssembly().Location);
            var addInRootPath = Path.Combine(directoryInfo.Parent.FullName, "Plugin");

            string[] warnings = AddInStore.Update(addInRootPath);
            DisplayWarnings(warnings);

            Collection <AddInToken> tokens = AddInStore.FindAddIns(typeof(ISightstonePlugin), addInRootPath);

            DisplayTokens(tokens);

            foreach (AddInToken token in tokens)
            {
                var grantSet = new PermissionSet(PermissionState.None);
                grantSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
                grantSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.AllAccess, Path.Combine(Assembly.GetExecutingAssembly().Location, "Plugin", token.AddInFullName)));
                grantSet.AddPermission(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
                ISightstonePlugin calculatorPlugin = token.Activate <ISightstonePlugin>(AddInSecurityLevel.FullTrust);
            }
        }
예제 #15
0
        public static void Main(string[] args)
        {
            string path = Environment.CurrentDirectory;

            AddInStore.Update(path);

            var tokens = AddInStore.FindAddIns(typeof(ProcessorHostView), path);

            var user         = new User("Erickson");
            var manufacturer = new Manufacturer("Samsung");
            var device       = new Device("Galaxy S10+", manufacturer);
            var context      = new ProcessorContext(device, user);

            foreach (var token in tokens)
            {
                var addIn = token.Activate <ProcessorHostView>(AddInSecurityLevel.Internet);

                Console.WriteLine(addIn.Process(context));
            }

            Console.ReadKey();
        }
예제 #16
0
 public PluginManager(string addInRootPath)
 {
     _addInRootPath = addInRootPath;
     _plugins       = new Dictionary <Type, IList <PluginTokenBase> >();
     AddInStore.Update(addInRootPath);
 }
예제 #17
0
        public static void Update()
        {
            string path = Environment.CurrentDirectory;

            AddInStore.Update(path);
        }
예제 #18
0
        static void Main()
        {
// <Snippet2>
// Get path for the pipeline root.
// Assumes that the current directory is the
// pipeline directory structure root directory.
            String pipeRoot = Environment.CurrentDirectory;

// <Snippet3>
// Update the cache files of the
// pipeline segments and add-ins.
            string[] warnings = AddInStore.Update(pipeRoot);

            foreach (string warning in warnings)
            {
                Console.WriteLine(warning);
            }
// </Snippet3>

// <Snippet4>
// Search for add-ins of type Calculator (the host view of the add-in)
// specifying the host's application base, instead of a path,
// for the FindAddIns method.

            Collection <AddInToken> tokens =
                AddInStore.FindAddIns(typeof(Calculator), PipelineStoreLocation.ApplicationBase);
// </Snippet4>
// </Snippet2>

// <Snippet5>
//Ask the user which add-in they would like to use.
            AddInToken selectedToken = ChooseAddIn(tokens);

//Activate the selected AddInToken in a new
//application domain with the Internet trust level.
            Calculator CalcAddIn = selectedToken.Activate <Calculator>(AddInSecurityLevel.Internet);

//Run the add-in using a custom method.
            RunCalculator(CalcAddIn);
// </Snippet5>

// <Snippet6>
// Find a specific add-in.

// Construct the path to the add-in.
            string addInFilePath = pipeRoot + @"\AddIns\P3AddIn2\P3AddIn2.dll";

// The fourth parameter, addinTypeName, takes the full name
// of the type qualified by its namespace. Same as AddInToken.AddInFullName.
            Collection <AddInToken> tokenColl = AddInStore.FindAddIn(typeof(Calculator),
                                                                     pipeRoot, addInFilePath, "CalcAddIns.P3AddIn2");

            Console.WriteLine("Found {0}", tokenColl[0].Name);
// </Snippet6>

// <Snippet8>
// Get the AddInController of a
// currently actived add-in (CalcAddIn).
            AddInController aiController = AddInController.GetAddInController(CalcAddIn);

// Select another token.
            AddInToken selectedToken2 = ChooseAddIn(tokens);

// Activate a second add-in, CalcAddIn2, in the same
// appliation domain and process as the first add-in by passing
// the first add-in's AddInEnvironment object to the Activate method.
            AddInEnvironment aiEnvironment = aiController.AddInEnvironment;
            Calculator       CalcAddIn2    =
                selectedToken2.Activate <Calculator>(aiEnvironment);

// Get the AddInController for the second add-in to compare environments.
            AddInController aiController2 = AddInController.GetAddInController(CalcAddIn2);

            Console.WriteLine("Add-ins in same application domain: {0}", aiController.AppDomain.Equals(aiController2.AppDomain));
            Console.WriteLine("Add-ins in same process: {0}", aiEnvironment.Process.Equals(aiController2.AddInEnvironment.Process));
// </Snippet8>


// <Snippet9>
// Get the application domain
// of an existing add-in (CalcAddIn).
            AddInController aiCtrl      = AddInController.GetAddInController(CalcAddIn);
            AppDomain       AddInAppDom = aiCtrl.AppDomain;

// Activate another add-in in the same application domain.
            Calculator CalcAddIn3 =
                selectedToken2.Activate <Calculator>(AddInAppDom);

// Show that CalcAddIn3 was loaded
// into CalcAddIn's application domain.
            AddInController aic = AddInController.GetAddInController(CalcAddIn3);

            Console.WriteLine("Add-in loaded into existing application domain: {0}",
                              aic.AppDomain.Equals(AddInAppDom));
// </Snippet9>

// <Snippet10>
// Create an external process.
            AddInProcess pExternal = new AddInProcess();

// Activate an add-in in the external process
// with a full trust security level.
            Calculator CalcAddIn4 =
                selectedToken.Activate <Calculator>(pExternal,
                                                    AddInSecurityLevel.FullTrust);

// Show that the add-in is an external process
// by verifying that it is not in the current (host's) process.
            AddInController AddinCtl = AddInController.GetAddInController(CalcAddIn4);

            Console.WriteLine("Add-in in host's process: {0}",
                              AddinCtl.AddInEnvironment.Process.IsCurrentProcess);
// </Snippet10>
// <Snippet11>
// Use qualification data to control
// how an add-in should be activated.

            if (selectedToken.QualificationData[AddInSegmentType.AddIn]["Isolation"].Equals("NewProcess"))
            {
                // Create an external process.
                AddInProcess external = new AddInProcess();

                // Activate an add-in in the new process
                // with the full trust security level.
                Calculator CalcAddIn5 =
                    selectedToken.Activate <Calculator>(external,
                                                        AddInSecurityLevel.FullTrust);
                Console.WriteLine("Add-in activated per qualification data.");
            }
            else
            {
                Console.WriteLine("This add-in is not designated to be activated in a new process.");
            }
// </Snippet11>

// <Snippet12>
// Show the qualification data for each
// token in an AddInToken collection.
            foreach (AddInToken token in tokens)
            {
                foreach (QualificationDataItem qdi in token)
                {
                    Console.WriteLine("{0} {1}\n\t QD Name: {2}, QD Value: {3}",
                                      token.Name,
                                      qdi.Segment,
                                      qdi.Name,
                                      qdi.Value);
                }
            }

// </Snippet12>
        }
예제 #19
0
        /// <summary>
        ///
        /// </summary>
        public void LoadPlugins()
        {
            osae.AddToLog("Entered LoadPlugins", true);
            string path = osae.APIpath;

            AddInStore.Update(path);
            Collection <AddInToken> tokens = null;

            tokens = AddInStore.FindAddIns(typeof(IOpenSourceAutomationAddInv2), path);
            osae.AddToLog("Found " + tokens.Count.ToString() + " tokens", true);
            foreach (AddInToken token in tokens)
            {
                if (!pluginExist(token.Name))
                {
                    plugins.Add(new Plugin(token));
                }
            }
            osae.AddToLog("Found " + plugins.Count.ToString() + " plugins", true);
            MySqlConnection connection = new MySqlConnection("SERVER=" + osae.DBConnection + ";" +
                                                             "DATABASE=" + osae.DBName + ";" +
                                                             "PORT=" + osae.DBPort + ";" +
                                                             "UID=" + osae.DBUsername + ";" +
                                                             "PASSWORD="******";");

            foreach (Plugin plugin in plugins)
            {
                try
                {
                    osae.AddToLog("---------------------------------------", true);
                    osae.AddToLog("Plugin name: " + plugin.PluginName, true);
                    osae.AddToLog("Testing connection", true);
                    if (!goodConnection)
                    {
                        try
                        {
                            connection.Open();
                            goodConnection = true;
                        }
                        catch
                        {
                        }
                    }

                    if (goodConnection)
                    {
                        if (plugin.PluginName != "")
                        {
                            OSAEObject obj = osae.GetObjectByName(plugin.PluginName);
                            if (obj != null)
                            {
                                osae.AddToLog("Plugin Object found: " + obj.Name + " - Enabled: " + obj.Enabled.ToString(), true);
                                if (obj.Enabled == 1)
                                {
                                    if (plugin.process == null)
                                    {
                                        enablePlugin(plugin);
                                    }
                                    osae.AddToLog("ProcessID: " + plugin.process.ProcessId, true);
                                }
                                else
                                {
                                    plugin.Enabled = false;
                                }

                                osae.AddToLog("Status: " + plugin.Enabled.ToString(), true);
                                osae.AddToLog("PluginVersion: " + plugin.PluginVersion, true);
                            }
                        }
                        else
                        {
                            //add code to create the object.  We need the plugin to specify the type though

                            MySqlDataAdapter adapter;
                            DataSet          dataset = new DataSet();
                            MySqlCommand     command = new MySqlCommand();
                            command.Connection  = connection;
                            command.CommandText = "SELECT * FROM osae_object_type_property p inner join osae_object_type t on p.object_type_id = t.object_type_id WHERE object_type=@type AND property_name='Computer Name'";
                            command.Parameters.AddWithValue("@type", plugin.PluginType);
                            adapter = new MySqlDataAdapter(command);
                            adapter.Fill(dataset);

                            if (dataset.Tables[0].Rows.Count > 0)
                            {
                                plugin.PluginName = plugin.PluginType + "-" + osae.ComputerName;
                            }
                            else
                            {
                                plugin.PluginName = plugin.PluginType;
                            }
                            osae.AddToLog("Plugin object does not exist in DB: " + plugin.PluginName, true);
                            osae.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginType, "", "System", false);
                            osae.ObjectPropertySet(plugin.PluginName, "Computer Name", osae.ComputerName);

                            osae.AddToLog("Plugin added to DB: " + plugin.PluginName, true);
                            sendMessageToClients("plugin", plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + osae.ComputerName);
                        }
                        masterPlugins.Add(plugin);
                    }
                }
                catch (Exception ex)
                {
                    osae.AddToLog("Error loading plugin: " + ex.Message, true);
                }
                catch
                {
                    osae.AddToLog("Error loading plugin", true);
                }
            }
        }
        public void LoadPlugins()
        {
            osae.AddToLog("Entered LoadPlugins", true);
            string path = osae.APIpath;

            AddInStore.Update(path);

            Collection <AddInToken> tokens = null;

            tokens = AddInStore.FindAddIns(typeof(IOpenSourceAutomationAddInv2), path);
            foreach (AddInToken token in tokens)
            {
                plugins.Add(new Plugin(token));
            }

            foreach (Plugin plugin in plugins)
            {
                try
                {
                    osae.AddToLog("---------------------------------------", true);
                    osae.AddToLog("plugin name: " + plugin.PluginName, true);
                    osae.AddToLog("plugin type: " + plugin.PluginType, true);

                    if (plugin.PluginName != "")
                    {
                        OSAE.OSAEObject obj = osae.GetObjectByName(plugin.PluginName);
                        osae.AddToLog("setting found: " + obj.Name + " - " + obj.Enabled.ToString(), true);
                        bool isSystemPlugin = false;
                        foreach (ObjectProperty p in obj.Properties)
                        {
                            if (p.Name == "System Plugin")
                            {
                                if (p.Value == "TRUE")
                                {
                                    isSystemPlugin = true;
                                }
                                break;
                            }
                        }
                        osae.AddToLog("isSystemPlugin?: " + isSystemPlugin.ToString(), true);
                        if (!isSystemPlugin)
                        {
                            if (obj.Enabled.ToString() == "1")
                            {
                                try
                                {
                                    if (plugin.ActivatePlugin())
                                    {
                                        plugin.addin.RunInterface(plugin.PluginName);
                                    }
                                    osae.ObjectStateSet(plugin.PluginName, "ON");
                                }
                                catch (Exception ex)
                                {
                                    osae.AddToLog("Error activating plugin (" + plugin.PluginName + "): " + ex.Message + " - " + ex.InnerException, true);
                                }
                                catch
                                {
                                    osae.AddToLog("Error activating plugin", true);
                                }
                            }
                            else
                            {
                                plugin.Enabled = false;
                            }

                            osae.AddToLog("status: " + plugin.Enabled.ToString(), true);
                            osae.AddToLog("PluginName: " + plugin.PluginName, true);
                            osae.AddToLog("PluginVersion: " + plugin.PluginVersion, true);
                            Thread thread = new Thread(() => messageHost("plugin", "plugin|" + plugin.PluginName + "|" + plugin.Status
                                                                         + "|" + plugin.PluginVersion + "|" + plugin.Enabled));
                            thread.Start();
                        }
                        //else
                        //    plugins.Remove(plugin);
                    }
                    else
                    {
                        //add code to create the object.  We need the plugin to specify the type though
                        osae.AddToLog("Plugin object doesn't exist", true);
                        DataSet dataset = wcfObj.ExecuteSQL("SELECT * FROM osae_object_type_property p inner join osae_object_type t on p.object_type_id = t.object_type_id WHERE object_type='" + plugin.PluginType + "' AND property_name='Computer Name'");
                        osae.AddToLog("dataset count: " + dataset.Tables[0].Rows.Count.ToString(), true);

                        // if object type has a property called 'Computer Name' we know it is not a System Plugin
                        if (dataset.Tables[0].Rows.Count > 0)
                        {
                            plugin.PluginName = plugin.PluginType + "-" + osae.ComputerName;

                            osae.AddToLog("Plugin object does not exist in DB: " + plugin.PluginName, true);
                            osae.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginType, "", "System", false);
                            osae.ObjectPropertySet(plugin.PluginName, "Computer Name", osae.ComputerName);

                            osae.AddToLog("Plugin added to DB: " + plugin.PluginName, true);
                            Thread thread = new Thread(() => messageHost("plugin", "plugin|" + plugin.PluginName + "|" + plugin.Status
                                                                         + "|" + plugin.PluginVersion + "|" + plugin.Enabled));
                            thread.Start();
                        }
                    }
                }
                catch (Exception ex)
                {
                    osae.AddToLog("Error loading plugin: " + ex.Message, true);
                }
                catch
                {
                    osae.AddToLog("Error loading plugin", true);
                }
            }
            osae.AddToLog("Done loading plugins", true);
        }
예제 #21
0
파일: Program.cs 프로젝트: zhimaqiao51/docs
        static void Main(string[] args)
        {
            // <Snippet2>
            // In this example, the pipeline root is the current directory.
            String pipeRoot = Environment.CurrentDirectory;

            // Rebuild the cache of pipeline and add-in information.
            string[] warnings = AddInStore.Update(pipeRoot);
            if (warnings.Length > 0)
            {
                foreach (string one in warnings)
                {
                    Console.WriteLine(one);
                }
            }
            // </Snippet2>

            // <Snippet3>
            // Find add-ins of type LibraryManager under the specified pipeline root directory.
            Collection <AddInToken> tokens = AddInStore.FindAddIns(typeof(LibraryManager), pipeRoot);
            // </Snippet3>
            // Determine which add-in to use.
            AddInToken selectedToken = ChooseAddIn(tokens);

            // <Snippet4>
            // Activate the selected AddInToken in a new
            // application domain with a specified security trust level.
            LibraryManager manager = selectedToken.Activate <LibraryManager>(AddInSecurityLevel.FullTrust);
            // </Snippet4>

            // Create a collection of books.
            IList <BookInfo> books = CreateBooks();

            // Show the collection count.
            Console.WriteLine("Number of books:  {0}", books.Count.ToString());

            // Have the add-in process the books.
            // The add-in will discount computer books by $20
            // and list their before and after prices. It
            // will also remove all horror books.
            manager.ProcessBooks(books);

            // List the genre of each book. There
            // should be no horror books.
            foreach (BookInfo bk in books)
            {
                Console.WriteLine(bk.Genre());
            }

            Console.WriteLine("Number of books: {0}", books.Count.ToString());

            Console.WriteLine();
            // Have the add-in pass a BookInfo object
            // of the best selling book.
            BookInfo bestBook = manager.GetBestSeller();

            Console.WriteLine("Best seller is {0} by {1}", bestBook.Title(), bestBook.Author());

            // Have the add-in show the sales tax rate.
            manager.Data("sales tax");

            // <Snippet6>
            AddInController ctrl = AddInController.GetAddInController(manager);

            ctrl.Shutdown();
            // </Snippet6>
            Console.WriteLine("Press any key to exit.");
            Console.ReadLine();
        }
예제 #22
0
 private void UpdatePipeline()
 {
     var warnings = AddInStore.Update(_addInRoot);
     var tokens   = AddInStore.FindAddIns(typeof(IFirmwareConfiguration), _addInRoot);
 }