public static void Main(string[] args) { try { //setup our DI var serviceProvider = new ServiceCollection() //.AddSingleton<IReader, MemoryReader>() .AddSingleton <IReader, FileReader>(f => new FileReader("wordlist.txt")) .AddSingleton <IAnalyzer, ComposableStringAnalyzer>() .BuildServiceProvider(); AnalysisResult analysisResult = serviceProvider.GetService <IAnalyzer>().Analyze(); //The result is stored in the bin folder in resultlist.txt var dumperServiceProvider = new ServiceCollection() //.AddSingleton<IDumper, ConsoleDumper>(c => new ConsoleDumper(analysisResult)) .AddSingleton <IDumper, FileDumper>(c => new FileDumper(analysisResult, "resultlist.txt")) .BuildServiceProvider(); IDumper fileDumper = dumperServiceProvider.GetService <IDumper>(); bool operationFinished = fileDumper.Dump(); if (operationFinished) { //Console.ReadLine(); } else { Console.WriteLine("Something went wrong."); } } catch (Exception ex) { ex.Log(""); } }
public Dump Dump(IDumper dumper, bool includeType = true) { var dump = dumper.Dump(); List <object> keys = new List <object>(dump.Keys); foreach (object key in keys) { dump[key] = DumpValue(dump[key], includeType); } if (includeType) { dump.Add(TYPE_KEY, dumper.GetType().Namespace + "." + dumper.GetType().Name); } return(dump); }
public Dump Dump(IDumper dumper, bool includeType = true) { var dump = dumper.Dump(); List<object> keys = new List<object>(dump.Keys); foreach (object key in keys) { dump[key] = DumpValue(dump[key], includeType); } if (includeType) { dump.Add(TYPE_KEY, dumper.GetType().Namespace + "." + dumper.GetType().Name); } return dump; }
public void StringTest(string str) { Assert.Equal(str, _dumper.Dump(str)); }