GraphiteConfig.cs 785 B

1234567891011121314151617181920212223242526272829303132
  1. namespace OhmGraphite
  2. {
  3. public class GraphiteConfig
  4. {
  5. public GraphiteConfig(string host, int port, bool tags)
  6. {
  7. Host = host;
  8. Port = port;
  9. Tags = tags;
  10. }
  11. public string Host { get; }
  12. public int Port { get; }
  13. public bool Tags { get; }
  14. public static GraphiteConfig ParseAppSettings(IAppConfig config)
  15. {
  16. string host = config["host"] ?? "localhost";
  17. if (!int.TryParse(config["port"], out int port))
  18. {
  19. port = 2003;
  20. }
  21. if (!bool.TryParse(config["tags"], out bool tags))
  22. {
  23. tags = false;
  24. }
  25. return new GraphiteConfig(host, port, tags);
  26. }
  27. }
  28. }