public void CanDumpDictionaryBasedObject() { // Arrange var input = new ContextDictionary("custom1", 23); input.Add("key1", "string value"); input.Add("key2", 55); // Act var actual = input.Dump(new ContextDictionaryHandler()); // Assert actual.Should().Be(@"{ ""Custom1"": ""custom1"" [System.String], ""Custom2"": 23 [System.Int32], { ""Key"": ""key1"" [System.String], ""Value"": ""string value"" [System.String], ""key"": ""key1"" [System.String], ""value"": ""string value"" [System.String] } [System.Collections.Generic.KeyValuePair<System.String,System.Object>], { ""Key"": ""key2"" [System.String], ""Value"": 55 [System.Int32], ""key"": ""key2"" [System.String], ""value"": 55 [System.Int32] } [System.Collections.Generic.KeyValuePair<System.String,System.Object>] } [CrossCutting.Utilities.ObjectDumper.Tests.Helpers.ContextDictionary]"); }
private static ThemeParserContext ParseContext(string content, ContextDictionary context) { if (string.IsNullOrWhiteSpace(content)) { throw new InvalidOperationException("@modules section cannot be empty"); } ThemeParserContext result = null; content.ParseKeyValuePair( (key, value) => { try { context.Add(key, new ThemeParserContext(Assembly.Load(value))); } catch { } //if (string.Compare(key, "Assembly", true) == 0) //{ // result = new ThemeParserContext(Assembly.Load(value)); //} }); return(result); }
public static ThemeStyle[] Parse(Stream stream) { ThemeList styles = new ThemeList(); ContextDictionary context = new ContextDictionary(); context.Add("Default", ThemeParserContext.Default); string content = null; using (StreamReader reader = new StreamReader(stream)) { content = Sanitize(reader.ReadToEnd()); } if (!string.IsNullOrEmpty(content)) { ProcessRuleset(content, context, styles, null); } return(styles.ToArray()); }