public void TestStrategy() { var tp = new TextProcessor(); tp.SetOutputFormat(OutputFormat.Markdown); tp.AppendList(new [] { "foo", "bar", "baz" }); Console.WriteLine(tp); tp.Clear(); tp.SetOutputFormat(OutputFormat.Html); tp.AppendList(new[] { "foo", "bar", "baz" }); Console.WriteLine(tp); }
public void Run() { var tp = new TextProcessor(); tp.SetOutputFormat(OutputFormat.MarkDown); tp.AppendList(new[] { "foo", "bar", "baz" }); WriteLine(tp); tp.Clear(); tp.SetOutputFormat(OutputFormat.Html); tp.AppendList(new[] { "foo", "bar", "baz" }); WriteLine(tp); }
static void Main(string[] args) { Console.WriteLine("---HTML格式----"); var p = new TextProcessor(); p.AppendList(new[] { "foo", "bar", "baz" }); Console.WriteLine(p); Console.WriteLine("---Markdown格式----"); p.Clear(); p.SetListStrategy(OutputFormat.Markdown); p.AppendList(new [] { "foo", "bar", "baz" }); Console.WriteLine(p); Console.ReadKey(); }
internal static void Strategy() { var list = new[] { "C#", "Java", "Angular", "React", "Javascript", "CSS", "HTML" }; //var tp = new TextProcessor(); //tp.SetOutputFormat(OutputFormat.NumberList); var tp = new TextProcessor(OutputFormat.NumberList); tp.AppendList(list); Console.WriteLine(tp); tp.Clear(); //tp.SetOutputFormat(OutputFormat.Html); tp = new TextProcessor(OutputFormat.Html); tp.AppendList(list); Console.WriteLine(tp); tp.Clear(); // Strategy Demo 2:----------------------------- StrategyDemo2(); }