/// <summary> /// For each of the documents in the folder 'Parallel\Resources\', /// Replace the string "Apple" with the string "Potato" and replace the "Apple" image by a "Potato" image. /// Do this in Parrallel accross many CPU cores. /// </summary> public static void DoParallelActions() { Console.WriteLine("\tDoParallelActions()"); // Get the docx files from the Resources directory. var inputDir = new DirectoryInfo(ParallelSample.ParallelSampleResourcesDirectory); var inputFiles = inputDir.GetFiles("*.docx"); // Loop through each document and do actions on them. System.Threading.Tasks.Parallel.ForEach(inputFiles, f => ParallelSample.Action(f)); }
private static void Main(string[] args) { Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); //Paragraphs ParagraphSample.SimpleFormattedParagraphs(); ParagraphSample.ForceParagraphOnSinglePage(); ParagraphSample.ForceMultiParagraphsOnSinglePage(); ParagraphSample.TextActions(); ParagraphSample.Heading(); ////Document DocumentSample.AddCustomProperties(); DocumentSample.ReplaceText(); DocumentSample.ApplyTemplate(); DocumentSample.AppendDocument(); //Images ImageSample.AddPicture(); ImageSample.CopyPicture(); ImageSample.ModifyImage(); //Indentation/Direction/Margins MarginSample.SetDirection(); MarginSample.Indentation(); MarginSample.Margins(); //Header/Footers HeaderFooterSample.HeadersFooters(); //Tables TableSample.InsertRowAndImageTable(); TableSample.TextDirectionTable(); TableSample.CreateRowsFromTemplate(); TableSample.ColumnsWidth(); TableSample.MergeCells(); //Hyperlink HyperlinkSample.Hyperlinks(); //Section SectionSample.InsertSections(); //Lists ListSample.AddList(); //Equations EquationSample.InsertEquation(); //Bookmarks BookmarkSample.InsertBookmarks(); BookmarkSample.ReplaceText(); //Charts ChartSample.BarChart(); ChartSample.LineChart(); ChartSample.PieChart(); ChartSample.Chart3D(); //Tale of Content TableOfContentSample.InsertTableOfContent(); TableOfContentSample.InsertTableOfContentWithReference(); //Lines LineSample.InsertHorizontalLine(); //Protection ProtectionSample.AddPasswordProtection(); ProtectionSample.AddProtection(); //Parallel ParallelSample.DoParallelActions(); //Others MiscellaneousSample.CreateRecipe(); MiscellaneousSample.CompanyReport(); MiscellaneousSample.CreateInvoice(); Console.WriteLine("\nPress any key to exit."); Console.ReadKey(); }