/// <summary> /// Initializes a new instance of the <see cref="XLink"/> class. /// </summary> /// <param name="document">The document.</param> /// <param name="href">The href.</param> /// <param name="name">The name.</param> public XLink(IDocument document, string href, string name) { Document = document; Node = new XElement(Ns.Text + "a"); InitStandards(); Href = href; TextContent.Add(new SimpleText(Document, name)); }
/// <summary> /// Парсинг файла /// </summary> /// <param name="path"></param> /// <returns></returns> public TextContent ParseFile(string path) { var content = new TextContent(); const string reg = @"((?sx-m)[^\r\n].*?(?:(?:\.|\?|!)\s))"; StreamReader reader; try { reader = new StreamReader(path, Encoding.GetEncoding(1251)); } catch { Console.WriteLine("Cannot read the file"); return(null); } var i = 0; while (!reader.EndOfStream) { var line = reader.ReadLine(); if (line != null) { content.SymbolCount += line.Length; //список предложений, полученных со строки, прочтённой из файла var sentences = new List <string>(Regex.Split(line, reg)); foreach (var pr in sentences) { if (String.IsNullOrEmpty(pr)) { continue; } var sentence = new Sentence(); //Создаём объект типа "предложение" и передаём ему список слов, знаков препинания и чисел //в строковом формате sentence.Create(ParseToWord(pr), i); content.Add(sentence); } } i++; } reader.Close(); return(content); }
/// <summary> /// Overloaded constructor. /// Use this to create a standard paragraph with the given text from /// string simpletext. Notice, the text will be styled as standard. /// You won't be able to style it bold, underline, etc. this will only /// occur if standard style attributes of the texdocumentocument are set to /// this. /// </summary> /// <param name="document">The IDocument.</param> /// <param name="style">The only accepted ParentStyle is Standard! All other styles will be ignored!</param> /// <param name="simpletext">The text which should be append within this paragraph.</param> public Paragraph(IDocument document, ParentStyles style, string simpletext) { Document = document; Node = new XElement(Ns.Text + "p"); if (style == ParentStyles.Standard) { Init(ParentStyles.Standard.ToString()); } else if (style == ParentStyles.Table) { Init(ParentStyles.Table.ToString()); } else if (style == ParentStyles.Text_20_body) { Init(ParentStyles.Text_20_body.ToString()); } //Attach simple text withhin the paragraph if (simpletext != null) { TextContent.Add(new SimpleText(Document, simpletext)); } _parentStyle = style; }