static void Main(string[] args) { BoldText boldText = new BoldText(); boldText.Text = "Bold Text"; PlainText plainText = new PlainText(); plainText.Text = "Plain Text"; Hyperlink hyperlink = new Hyperlink(); hyperlink.Text = "Hyper Link"; List <DocumentPart> list = new List <DocumentPart> { boldText, plainText, hyperlink }; Document document = new Document(list); System.Console.WriteLine(document.ToLaTexOutput()); System.Console.ReadKey(); System.Console.WriteLine(document.ToHtmlOutlut()); System.Console.ReadKey(); System.Console.WriteLine(document.ToPlainTextOutput()); System.Console.ReadKey(); }
static void Main(string[] args) { PlainText plain = new PlainText() { Text = "valera chadovich" }; Hyperlink link = new Hyperlink() { Text = "valera chadovich", Url = "https://github.com/valerycadovic" }; BoldText bold = new BoldText() { Text = "bold valera chadovich" }; Document document = new Document(new DocumentPart[] { plain, link, bold }); System.Console.WriteLine("Base64:"); System.Console.WriteLine(document.ToBase64()); System.Console.WriteLine("HTML:"); System.Console.WriteLine(document.ToHtml()); System.Console.WriteLine("LaTeX:"); System.Console.WriteLine(document.ToLaTeX()); System.Console.WriteLine("Plain Text:"); System.Console.WriteLine(document.ToPlainText()); System.Console.ReadKey(); }
static void Main(string[] args) { BoldText bold = new BoldText(); bold.Text = "bold"; Hyperlink hyperlink = new Hyperlink(); hyperlink.Text = "hyperlink"; PlainText plainText = new PlainText(); plainText.Text = "plainText"; List <DocumentPart> parts = new List <DocumentPart>() { bold, hyperlink, plainText }; Document document = new Document(parts); System.Console.WriteLine("bold.ToHtml " + document.ToNewFormat(bold.ToHtml)); System.Console.WriteLine("bold.ToLaTeX " + document.ToNewFormat(bold.ToLaTeX)); System.Console.WriteLine("bold.ToPlainText " + document.ToNewFormat(bold.ToPlainText)); System.Console.WriteLine("hyperlink.ToHtml " + document.ToNewFormat(hyperlink.ToHtml)); System.Console.WriteLine("hyperlink.ToLaTeX " + document.ToNewFormat(hyperlink.ToLaTeX)); System.Console.WriteLine("hyperlink.ToPlainText " + document.ToNewFormat(hyperlink.ToPlainText)); System.Console.WriteLine("plainText.ToHtml " + document.ToNewFormat(plainText.ToHtml)); System.Console.WriteLine("plainText.ToLaTeX " + document.ToNewFormat(plainText.ToLaTeX)); System.Console.WriteLine("plainText.ToPlainText " + document.ToNewFormat(plainText.ToPlainText)); System.Console.ReadKey(); }
static void Main(string[] args) { //Bir doküman oluşturmak için DocumentPart soyut sınıfımız var //Bu sınıfların her birinin text özelliği var PlainText docPart1 = new PlainText(); Hyperlink docPart2 = new Hyperlink(); BoldText docPart3 = new BoldText(); docPart1.Text = "Tasarım kalıpları, bir tecrübenin ürünü olarak ortaya çıkmış tekniklerdir."; docPart2.Text = "Kitap Linki"; docPart2.Url = "www.charpiletasarimkaliplari.com"; docPart3.Text = "C# ile tasarım kalıpları"; //bu sınıflara gerçek manada özellikleri eklemek için //visitor sınıfından yardım alıyoruz. IVisitor htmlVisitor = new HtmlVisitor(); docPart1.Accept(htmlVisitor); docPart2.Accept(htmlVisitor); docPart3.Accept(htmlVisitor); Console.WriteLine("Çıktımız: \n" + htmlVisitor.Output); Console.ReadLine(); }
protected override string ToPlainText(BoldText docPart) { if (docPart == null) { throw new System.ArgumentNullException(nameof(docPart)); } return("**" + docPart.Text + "**"); }
protected override string ToHtml(BoldText docPart) { if (docPart == null) { throw new System.ArgumentNullException(nameof(docPart)); } return("<b>" + docPart.Text + "</b>"); }
protected override string ToLaTeX(BoldText docPart) { if (docPart == null) { throw new System.ArgumentNullException(nameof(docPart)); } return("\\textbf{" + docPart.Text + "}"); }
public void BoldTextCallVisitor_VisitMethod() { var converterMock = new Mock <IConverter>(); var boldText = new BoldText { Text = "Some bold text" }; boldText.Converter(converterMock.Object); converterMock.Verify(converter => converter.ConvertBoldText(It.Is <string>(text => string.Equals(text, boldText.Text, StringComparison.Ordinal))), Times.Once); }
public void BoldTextCallVisitor_VisitMethod() { var visitorMock = new Mock <Visitor>(); var boldText = new BoldText { Text = "Some bold text" }; boldText.Visit(visitorMock.Object); visitorMock.Verify(visitor => visitor.VisitBoldText(It.Is <BoldText>(text => string.Equals(text.Text, boldText.Text, StringComparison.Ordinal))), Times.Once); }
public void BoldText_AcceptMethod() { var documentConverterMock = new Mock <DocumentConverter>(); var boldText = new BoldText { Text = "Some bold text" }; boldText.Accept(documentConverterMock.Object); documentConverterMock.Verify(visitor => visitor.Visit(It.Is <BoldText>(text => text.Text.Equals(boldText.Text))), Times.Once); }
public static void Main(string[] args) { var doc1 = new BoldText { Text = "plain text" }; var doc2 = new HyperLink { Text = "hyper link", Url = "https://translate.google.com/hl=ru" }; var doc3 = new PlainText { Text = "plain text" }; var document = new Document(new DocumentPart[] { doc1, doc2, doc3 }); System.Console.WriteLine(document.ConvertTo(new DocumentPartToHtml())); System.Console.WriteLine(document.ConvertTo(new DocumentPartToLaTeX())); System.Console.WriteLine(document.ConvertTo(new DocumentPartToPlainText())); }
static void Main(string[] args) { var boldText = new BoldText { Text = "smth" }; var textTypes = new List <DocumentPart>(); textTypes.Add(boldText); var document = new Document(textTypes); System.Console.WriteLine(document.ToHtml()); System.Console.WriteLine(document.ToLaTeX()); System.Console.WriteLine(document.ToPlainText()); System.Console.ReadLine(); }
static void Main(string[] args) { var doc1 = new BoldText() { Text = "plain text" }; var doc2 = new HyperLink() { Text = "hyper link" }; var docs = new List <DocumentPart>() { doc1, doc2 }; var document = new Document(docs); var converted = document.ConvertTo(new DocumentPartToHtml()); System.Console.WriteLine(converted); }
static void Main(string[] args) { DocumentPart boldText = new BoldText() { Text = "Test Visitor pattern" }; DocumentPart plainText = new PlainText() { Text = "Test" }; DocumentPart hyperLink = new Hyperlink() { Text = "Huperlink", Url = @"http://en.wikipedia.org" }; IEnumerable <DocumentPart> documentPart = new List <DocumentPart>() { boldText, plainText, hyperLink }; foreach (var item in documentPart) { System.Console.WriteLine(item.ToHtml()); } System.Console.WriteLine(Environment.NewLine); foreach (var item in documentPart) { System.Console.WriteLine(item.ToLaTexText()); } System.Console.WriteLine(Environment.NewLine); foreach (var item in documentPart) { System.Console.WriteLine(item.ToPlainText()); } System.Console.ReadLine(); }
static void Main(string[] args) { var link = new Hyperlink(); link.Url = "git"; link.Text = "text"; var bold = new BoldText(); bold.Text = "boldText"; var plain = new PlainText(); plain.Text = "plainText"; DocumentPart[] parts = { link, bold, plain }; Document document = new Document(parts); System.Console.WriteLine($"To Html: {document.Convert(p => p.ToHtml())}"); System.Console.WriteLine($"To Plain text: {document.Convert(p => p.ToPlainText())}"); System.Console.WriteLine($"To LaTeX: {document.Convert(p => p.ToLaTeX())}"); System.Console.ReadLine(); }
static void Main(string[] args) { var boldText = new BoldText { Text = "boldText" }; var hyperLink = new Hyperlink { Url = "zelda.com", Text = "Go" }; var plainText = new PlainText { Text = "plainText" }; DocumentPart[] parts = { hyperLink, boldText, plainText }; Document document = new Document(parts); System.Console.WriteLine($"To LaTeX: {document.Convert(l => l.ToLaTeX())}"); System.Console.WriteLine($"To Html: {document.Convert(h => h.ToHtml())}"); System.Console.WriteLine($"To Plain text: {document.Convert(p => p.ToPlainText())}"); System.Console.ReadLine(); }
/// <inheritdoc></inheritdoc> public override string ConvertBoldText(BoldText boldText) { return("<b>" + boldText.Text + "</b>"); }
public string Convert(BoldText boldText) { return("\\textbf{" + boldText.Text + "}"); }
protected override string Visit(BoldText text) => "<b>" + text.Text + "</b>";
public abstract void VisitBoldText(BoldText boldText);
public void Visit(BoldText docPart) { Output += "<b>" + docPart.Text + "</b>"; }
protected abstract string Visit(BoldText boldText);
public override void VisitBoldText(BoldText boldText) { var result = "<b>" + boldText.Text + "</b>"; Builder.Append(result); }
public string Convert(DocumentPart elem) { BoldText target = (BoldText)elem; return("<b>" + target.Text + "</b>");; }
public override string Get(BoldText part) { return("**" + part.Text + "**"); }
public void Visit(BoldText docPart) { this.m_output += "\\textbf{" + docPart.Text + "}"; }
protected override void Visit(BoldText boldText) { ConcretString = boldText.Text; }
public void Visit(BoldText element) { Content += $"<b>{element.Text}</b>"; }
public override string Convert(BoldText boldText) => "\\textbf{" + boldText.Text + "}";
/// <inheritdoc></inheritdoc> public override string ConvertBoldText(BoldText boldText) { return("\\textbf{" + boldText.Text + "}"); }
public string VisitBoldText(BoldText boldText) { return string.Format("<b>{0}</b>", boldText.Text); }
public string VisitBoldText(BoldText boldText) { return string.Format("_{0}_", boldText.Text); }