/// <summary> /// Registers multiple <see cref="IActivityMonitorClient"/>. /// Duplicate IActivityMonitorClient instances are ignored. /// </summary> /// <param name="this">This <see cref="IActivityMonitorOutput"/> object.</param> /// <param name="clients">Multiple clients to register.</param> /// <returns>This registrar to enable fluent syntax.</returns> public static IActivityMonitorOutput RegisterClients(this IActivityMonitorOutput @this, IEnumerable <IActivityMonitorClient> clients) { foreach (var c in clients) { @this.RegisterClient(c); } return(@this); }
/// <summary> /// Creates a strong bridge to another monitor's <see cref="ActivityMonitorBridgeTarget"/>. /// Only one bridge to the same monitor can exist at a time: if <see cref="FindBridgeTo"/> is not null, /// this throws a <see cref="InvalidOperationException"/>. /// A strong bridge synchronizes <see cref="IActivityMonitor.AutoTags"/> and <see cref="IActivityMonitor.Topic"/> between the two monitors. When created, the 2 properties /// of the local monitor are set to the ones of the target monitor. /// </summary> /// <param name="this">This <see cref="IActivityMonitorOutput"/>.</param> /// <param name="targetBridge">The target bridge that will receive our logs.</param> /// <returns>A <see cref="IDisposable"/> object that can be disposed to automatically call <see cref="UnbridgeTo"/>.</returns> public static IDisposable CreateStrongBridgeTo(this IActivityMonitorOutput @this, ActivityMonitorBridgeTarget targetBridge) { if (targetBridge == null) { throw new ArgumentNullException("targetBridge"); } if (@this.Clients.OfType <ActivityMonitorBridge>().Any(b => b.BridgeTarget == targetBridge)) { throw new InvalidOperationException(); } var created = @this.RegisterClient(new ActivityMonitorBridge(targetBridge, true, true)); return(Util.CreateDisposableAction(() => @this.UnregisterClient(created))); }
/// <summary> /// Registers a typed <see cref="IActivityMonitorClient"/>. /// Duplicate IActivityMonitorClient instances are ignored. /// </summary> /// <typeparam name="T">Any type that specializes <see cref="IActivityMonitorClient"/>.</typeparam> /// <param name="this">This <see cref="IActivityMonitorOutput"/> object.</param> /// <param name="client">Client to register.</param> /// <returns>The registered client.</returns> public static T RegisterClient <T>(this IActivityMonitorOutput @this, T client) where T : IActivityMonitorClient { bool added; return(@this.RegisterClient <T>(client, out added)); }
/// <summary> /// Registers an <see cref="IActivityMonitorClient"/> to the <see cref="IActivityMonitorOutput.Clients">Clients</see> list. /// Duplicates IActivityMonitorClient are silently ignored. /// </summary> /// <param name="this">This <see cref="IActivityMonitorOutput"/> object.</param> /// <param name="client">An <see cref="IActivityMonitorClient"/> implementation.</param> /// <returns>The registered client.</returns> public static IActivityMonitorClient RegisterClient(this IActivityMonitorOutput @this, IActivityMonitorClient client) { bool added; return(@this.RegisterClient(client, out added)); }