ApiExamples.DocumentHelper.FindTextInFile C# (CSharp) Метод

FindTextInFile() статический приватный Метод

static private FindTextInFile ( string path, string expression ) : void
path string
expression string
Результат void
        internal static void FindTextInFile(string path, string expression)
        {
            using (var sr = new StreamReader(path))
            {
                while (!sr.EndOfStream)
                {
                    var line = sr.ReadLine();

                    if (String.IsNullOrEmpty(line)) continue;

                    if (line.Contains(expression))
                    {
                        Console.WriteLine(line);
                        Assert.Pass();
                    }
                    else
                    {
                        Assert.Fail();
                    }
                }
            }
        }

Usage Example

Пример #1
0
        public void ExportOfficeMath(SaveFormat saveFormat, HtmlOfficeMathOutputMode outputMode)
        {
            Document doc = new Document(MyDir + "OfficeMath.docx");

            HtmlSaveOptions saveOptions = new HtmlSaveOptions
            {
                OfficeMathOutputMode = outputMode
            };

            Save(doc, @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                 saveFormat, saveOptions);

            switch (saveFormat)
            {
            case SaveFormat.Html:
                DocumentHelper.FindTextInFile(
                    MyDir + @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                    "<img src=\"HtmlSaveOptions.ExportToHtmlUsingImage.001.png\" width=\"49\" height=\"19\" alt=\"\" style=\"-aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline\" />");
                return;

            case SaveFormat.Mhtml:
                DocumentHelper.FindTextInFile(
                    MyDir + @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                    "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"><mi>A</mi><mo>=</mo><mi>π</mi><msup><mrow><mi>r</mi></mrow><mrow><mn>2</mn></mrow></msup></math>");
                return;

            case SaveFormat.Epub:
                DocumentHelper.FindTextInFile(
                    MyDir + @"\Artifacts\HtmlSaveOptions.ExportToHtmlUsingImage." + saveFormat.ToString().ToLower(),
                    "<span style=\"font-family:\'Cambria Math\'\">A=π</span><span style=\"font-family:\'Cambria Math\'\">r</span><span style=\"font-family:\'Cambria Math\'\">2</span>");
                return;
            }
        }
All Usage Examples Of ApiExamples.DocumentHelper::FindTextInFile