Example #1
0
        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();
        }
Example #2
0
        public virtual string Data(string txt)
        {
            string rtxt = _view.Data(txt);

            return(rtxt);
        }