Ejemplo n.º 1
0
        /// <summary>
        ///     Resets the signal.
        /// </summary>
        public void Reset()
        {
            Enabled       = true;
            Raised        = false;
            CalledExpired = false;

            // Add signal back to manager
            SignalManager.AddSignal(this);
        }
Ejemplo n.º 2
0
        /// <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></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);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Enables this signal.
        /// </summary>
        public void Enable()
        {
            Enabled = true;

            // Get the caller of the this method.
            var callFrame     = new StackFrame(1);
            var declaringType = callFrame.GetMethod().DeclaringType;

            if (declaringType == null)
            {
                return;
            }

            var caller = declaringType.FullName + "." + callFrame.GetMethod().Name;

            TriggerEnabledStatusChanged(caller, true);

            SignalManager.AddSignal(this);
        }