public void AddFormatter(Formatter f) { if (!Formatters.ContainsKey(f.PropertyName)) { Formatters.Add(f.PropertyName, new List <Formatter>()); } Formatters[f.PropertyName].Add(f); }
public Log ResolveLog(string name) { LogDefinition log = Logs[name]; TypeCreator creator = new TypeCreator(log.Type); foreach (var formatterProperty in log.Properties) { creator.MemberValues.Add(formatterProperty.Key, formatterProperty.Value); } var value = (Log)creator.Create(); foreach (var logListenerName in log.ListenerNames) { if (Listeners.ContainsKey(logListenerName)) { value.AddListener(ResolveListener(logListenerName)); continue; } else { bool added = false; foreach (var configuration in Imports) { if (configuration.Listeners.ContainsKey(logListenerName)) { value.AddListener(configuration.ResolveListener(logListenerName)); added = true; break; } } if (added) { continue; } } throw new KeyNotFoundException("Listener '" + logListenerName + "' not found in configuration or imports."); } if (Formatters.ContainsKey(log.FormatterName)) { value.Formatter = ResolveFormatter(log.FormatterName); } else { foreach (var configuration in Imports) { if (configuration.Formatters.ContainsKey(log.FormatterName)) { value.Formatter = configuration.ResolveFormatter(log.FormatterName); break; } } } return(value); }
private static IFormatter GetFormatter(string name) { if (!Formatters.ContainsKey(name)) { throw new InvalidOperationException($"Formatter '{name}' not found"); } return(Formatters[name]); }
public void ListPositions(string formatter) { if (Formatters.ContainsKey(formatter)) { Company.Head.AcceptFormatter(Formatters[formatter]); } else { throw new UnknownTypeException("Unknown formatter type!"); } }