public static void SetListener(this Cfg.Configuration config, object listener) { if (listener == null) { throw new ArgumentNullException("listener"); } foreach (var intf in listener.GetType().GetInterfaces()) { if (CfgHelper.ListenerDict.ContainsKey(intf)) { foreach (var t in CfgHelper.ListenerDict[intf]) { config.SetListener(t, listener); } } } }