/// <summary> /// Initializes a new instance of the <see cref="Signal" /> class. /// </summary> /// <param name="signalRaised"> /// The signal raised /// </param> /// <param name="signalWaver"> /// The signal waver /// </param> /// <param name="expiration"> /// The expiration /// </param> /// <param name="properties"> /// The properties /// </param> private Signal( OnRaisedDelegate signalRaised, SignalWaverDelegate signalWaver, DateTimeOffset expiration, IDictionary<string, object> properties) { if (signalRaised != null) { this.OnRaised += signalRaised; } if (signalWaver != null) { this.SignalWaver = signalWaver; } this.Expiration = expiration; this.Properties = new Dictionary<string, object>(properties); }
/// <summary> /// Creates an instance of the <see cref="Signal" /> class. /// </summary> /// <param name="onRaised">The delegate to call when this signal is raised.</param> /// <param name="signalWaver">The function that returns <c>true</c> when this signal should be waved.</param> /// <param name="expiration">The expiration of this signal.</param> /// <param name="defaultProperties">A dictionary that contents will be dumped into <see cref="Properties" /></param> /// <returns>The <see cref="Signal" /></returns> public static Signal Create( OnRaisedDelegate onRaised = null, SignalWaverDelegate signalWaver = null, DateTimeOffset expiration = default(DateTimeOffset), IDictionary <string, object> defaultProperties = null) { if (expiration == default(DateTimeOffset)) { expiration = DateTimeOffset.MaxValue; } var signal = new Signal( onRaised, signalWaver, expiration, defaultProperties ?? new Dictionary <string, object>()); SignalManager.AddSignal(signal); signal.Enabled = true; return(signal); }
/// <summary> /// Creates an instance of the <see cref="Signal" /> class. /// </summary> /// <param name="onRaised">The delegate to call when this signal is raised.</param> /// <param name="signalWaver">The function that returns <c>true</c> when this signal should be waved.</param> /// <param name="expiration">The expiration of this signal.</param> /// <param name="defaultProperties">A dictionary that contents will be dumped into <see cref="Properties" /></param> /// <returns>The <see cref="Signal" /></returns> public static Signal Create( OnRaisedDelegate onRaised = null, SignalWaverDelegate signalWaver = null, DateTimeOffset expiration = default(DateTimeOffset), IDictionary<string, object> defaultProperties = null) { if (expiration == default(DateTimeOffset)) { expiration = DateTimeOffset.MaxValue; } var signal = new Signal( onRaised, signalWaver, expiration, defaultProperties ?? new Dictionary<string, object>()); SignalManager.AddSignal(signal); signal.Enabled = true; return signal; }