public static IObservable <Report> Build(HostConfig conf) { switch (conf) { case PingConfig p: return(Pinger.Create(p)); case TcpConfig t: switch (t) { case HttpConfig h: return(HttpConnector.Create(h)); default: return(TcpConnector.Create(t)); } default: throw new ArgumentException($"Unsupported HostConfig type: {conf.GetType()}"); } }