Пример #1
0
        private ConversionResult ConvertObject(ConversionOption conversionOption)
        {
            CopyResultMessage = string.Empty;

            PrepareAdditionalObjects();

            IObjectConverter objectConverter;

            switch (conversionOption)
            {
            case ConversionOption.Json:
                objectConverter = new JsonConverter();
                break;

            case ConversionOption.Html:
                objectConverter = new HtmlConverter();
                break;

            case ConversionOption.PlainText:
                objectConverter = new PlainTextConverter();
                break;

            default:
                objectConverter = new PlainTextConverter();
                break;
            }

            return(objectConverter.Convert(Post));
        }
Пример #2
0
        static void Main(string[] args)
        {
            List <DocumentPart> parts = new List <DocumentPart>
            {
                new PlainText {
                    Text = "Some plain text"
                },
                new Hyperlink {
                    Text = "google.com", Url = "https://www.google.by/"
                },
                new BoldText {
                    Text = "Some bold text"
                }
            };

            Document document = new Document(parts);

            Converter converterHTML      = new HTMLConverter();
            Converter converterLaTeX     = new LaTeXCoverter();
            Converter converterPlainText = new PlainTextConverter();


            Console.WriteLine(document.Convert(converterHTML));

            Console.WriteLine(document.Convert(converterLaTeX));

            Console.WriteLine(document.Convert(converterPlainText));
        }
        static void Main(string[] args)
        {
            var htmlConverter      = new HtmlConverter();
            var laTeXConverter     = new LaTeXConverter();
            var plainTextConverter = new PlainTextConverter();

            List <DocumentPart> parts = new List <DocumentPart>
            {
                new PlainText {
                    Text = "Some plain text"
                },
                new Hyperlink {
                    Text = "google.com", Url = "https://www.google.by/"
                },
                new BoldText {
                    Text = "Some bold text"
                }
            };

            Document document = new Document(parts);

            Console.WriteLine(document.Convert(htmlConverter));
            Console.WriteLine(document.Convert(plainTextConverter));
            Console.WriteLine(document.Convert(laTeXConverter));
        }