Beispiel #1
0
        /// <summary>
        /// The IdentityArrow is much like the IdentityArrow, but calls
        /// an Action &lt;S&gt; on every accepted message/object before
        /// forwarding it.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static IdentityArrow IdentityArrow(this IArrowSender ArrowSender, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
        {
            var _IdentityArrow = new IdentityArrow(Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _IdentityArrow.ReceiveMessage;
            return(_IdentityArrow);
        }
Beispiel #2
0
        /// <summary>
        /// An active sensor.
        /// </summary>
        /// <param name="IEnumerator">An enumerator of TValues.</param>
        /// <param name="SensorId">The unique identification of the sensor.</param>
        /// <param name="SensorName">The name of the sensor.</param>
        /// <param name="ValueUnit">The unit of the value (m, m², °C, °F, MBytes, ...).</param>
        /// <param name="Recipient">A recipient of the processed measurements.</param>
        /// <param name="Autostart">Start the sniper automatically.</param>
        /// <param name="StartAsTask">Start the ActiveSensor within its own task.</param>
        /// <param name="InitialDelay">Set the initial delay of the sniper.</param>
        public ActiveSensor(IEnumerator <TValue> IEnumerator,
                            TId SensorId,
                            String SensorName,
                            String ValueUnit,
                            IArrowReceiver <TValue> Recipient,
                            Boolean Autostart   = false,
                            Boolean StartAsTask = false,
                            Nullable <TimeSpan> InitialDelay = null)

            : this(IEnumerator, SensorId, SensorName, ValueUnit, Autostart, StartAsTask, InitialDelay)

        {
            #region Initial Checks

            if (Recipient == null)
            {
                throw new ArgumentNullException("The given Recipient must not be null!");
            }

            #endregion

            lock (this)
            {
                this.OnMessageAvailable += Recipient.ReceiveMessage;
            }
        }
Beispiel #3
0
 public static void SendTo <T1, T2, T3, T4, T5>(this IArrowSender <T1, T2, T3, T4, T5> INotification,
                                                IArrowReceiver <T1, T2, T3, T4, T5> Target)
 {
     INotification.OnNotification     += Target.ProcessArrow;
     INotification.OnExceptionOccured += Target.ProcessExceptionOccured;
     INotification.OnCompleted        += Target.ProcessCompleted;
 }
Beispiel #4
0
        /// <summary>
        /// A generic Arrow transforming incoming messages into outgoing messages.
        /// </summary>
        /// <param name="Func">A generic transformation of incoming messages into outgoing messages.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public FuncArrow(Func <TMessage, TOutput> Func, IArrowReceiver <TOutput> Recipient, params IArrowReceiver <TOutput>[] Recipients)
            : base(Recipient, Recipients)
        {
            if (Func == null)
            {
                throw new ArgumentNullException("The given message transformation func must not be null!");
            }

            this.Func = Func;
        }
Beispiel #5
0
        /// <summary>
        /// Filters the consuming objects by calling a Func&lt;S, Boolean&gt;.
        /// </summary>
        /// <param name="FilterFunc">A Func&lt;S, Boolean&gt; filtering the consuming objects. True means filter (ignore).</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">The recipients of the processed messages.</param>
        public FuncFilterArrow(Func <TMessage, Boolean> FilterFunc, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
            : base(Recipient, Recipients)
        {
            if (FilterFunc == null)
            {
                throw new ArgumentNullException("The given FilterFunc must not be null!");
            }

            _FilterFunc = FilterFunc;
        }
Beispiel #6
0
        /// <summary>
        /// The ActionArrow is much like the IdentityArrow, but calls
        /// an Action &lt;S&gt; on every accepted message/object before
        /// forwarding it.
        /// </summary>
        /// <param name="Action">An Action &lt;S&gt; to invoke on every accepted message/object before forwarding it.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">The recipients of the processed messages.</param>
        public ActionArrow(Action_Object Action, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
            : base(Recipient, Recipients)
        {
            if (Action == null)
            {
                throw new ArgumentNullException("The given Action<TIn> must not be null!");
            }

            this.Action = Action;
        }
Beispiel #7
0
        /// <summary>
        /// Creates a new ActiveSensor based on the given ISensor&lt;TId, TValue&gt;.
        /// </summary>
        /// <typeparam name="TId">The type of the unique identification.</typeparam>
        /// <typeparam name="TValue">The type of the measured value.</typeparam>
        /// <param name="ISensor">An ISensor&lt;TId, TValue&gt;.</param>
        /// <param name="Recipient">A recipient of the processed measurements.</param>
        /// <param name="Autostart">Start the sniper automatically.</param>
        /// <param name="StartAsTask">Start the ActiveSensor within its own task.</param>
        /// <param name="InitialDelay">Set the initial delay of the sniper.</param>
        /// <returns>A new IActiveSensor&lt;TId, TValue&gt;.</returns>
        public static IActiveSensor <TId, TValue> ToActiveSensor <TId, TValue>(this ISensor <TId, TValue> ISensor,
                                                                               IArrowReceiver <TValue> Recipient,
                                                                               Boolean Autostart   = false,
                                                                               Boolean StartAsTask = false,
                                                                               Nullable <TimeSpan> InitialDelay = null)

            where TId : IEquatable <TId>, IComparable <TId>, IComparable

        {
            return(new ActiveSensor <TId, TValue>(ISensor, Recipient, Autostart, StartAsTask, InitialDelay));
        }
Beispiel #8
0
 /// <summary>
 /// The AggregatorArrow produces a side effect that is the provided collection
 /// filled with the contents of all the objects that have passed through it.
 /// The collection enumerator is used as the emitting enumerator. Thus, what
 /// goes into AggregatorArrow may not be the same as what comes out of
 /// AggregatorPipe.
 /// For example, duplicates removed, different order to the stream, etc.
 /// Finally, note that different Collections have different behaviors and
 /// write/read times.
 /// </summary>
 /// <param name="ICollection">An ICollection to store the passed messages/objects.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public AggregatorArrow(ICollection <TMessage> ICollection, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
     : base(Recipient, Recipients)
 {
     if (ICollection == null)
     {
         _SideEffect = new List <TMessage>();
     }
     else
     {
         _SideEffect = ICollection;
     }
 }
Beispiel #9
0
        /// <summary>
        /// Creates a new ActiveSensor fireing the content of the given IEnumerator.
        /// </summary>
        /// <typeparam name="TId">The type of the unique identification.</typeparam>
        /// <typeparam name="TValue">The type of the measured value.</typeparam>
        /// <param name="IEnumerator">An enumerator of messages/objects to send.</param>
        /// <param name="SensorId">The unique identification of the sensor.</param>
        /// <param name="SensorName">The name of the sensor.</param>
        /// <param name="ValueUnit">The unit of the value (m, m², °C, °F, MBytes, ...).</param>
        /// <param name="Recipient">A recipient of the processed measurements.</param>
        /// <param name="Autostart">Start the sniper automatically.</param>
        /// <param name="StartAsTask">Start the ActiveSensor within its own task.</param>
        /// <param name="InitialDelay">Set the initial delay of the sniper.</param>
        /// <returns>A new IActiveSensor&lt;TId, TValue&gt;.</returns>
        public static IActiveSensor <TId, TValue> ToActiveSensor <TId, TValue>(this IEnumerator <TValue> IEnumerator,
                                                                               TId SensorId,
                                                                               String SensorName,
                                                                               String ValueUnit,
                                                                               IArrowReceiver <TValue> Recipient,
                                                                               Boolean Autostart   = false,
                                                                               Boolean StartAsTask = false,
                                                                               Nullable <TimeSpan> InitialDelay = null)

            where TId : IEquatable <TId>, IComparable <TId>, IComparable

        {
            return(new ActiveSensor <TId, TValue>(IEnumerator, SensorId, SensorName, ValueUnit, Recipient, Autostart, StartAsTask, InitialDelay));
        }
Beispiel #10
0
        /// <summary>
        /// Creates a new AbstractArrow and adds the given recipients
        /// to the list of message recipients.
        /// </summary>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">The recipients of the processed messages.</param>
        public AbstractArrowSender(IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
        {
            lock (this)
            {
                if (Recipient != null)
                {
                    this.OnMessageAvailable += Recipient.ReceiveMessage;
                }

                if (Recipients != null)
                {
                    foreach (var _Recipient in Recipients)
                    {
                        this.OnMessageAvailable += _Recipient.ReceiveMessage;
                    }
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// The Sniper fetches messages/objects from the given IEnumerator
        /// and sends them to the recipients.
        /// </summary>
        /// <param name="IEnumerator">An IEnumerator&lt;S&gt; as element source.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Autostart">Start the sniper automatically.</param>
        /// <param name="StartAsTask">Start the sniper within its own task.</param>
        /// <param name="InitialDelay">Set the initial delay of the sniper in milliseconds.</param>
        public Sniper(IEnumerator <TOut> IEnumerator,
                      IArrowReceiver <TOut> Recipient,
                      Boolean Autostart   = false,
                      Boolean StartAsTask = false,
                      Nullable <TimeSpan> InitialDelay = null)

            : this(IEnumerator, Autostart, StartAsTask, InitialDelay)

        {
            #region Initial Checks

            if (Recipient == null)
            {
                throw new ArgumentNullException("The given Recipient must not be null!");
            }

            #endregion

            lock (this)
            {
                this.OnMessageAvailable += Recipient.ReceiveMessage;
            }
        }
        /// <summary>
        /// The AggregatorArrow produces a side effect that is the provided collection
        /// filled with the contents of all the objects that have passed through it.
        /// The collection enumerator is used as the emitting enumerator. Thus, what
        /// goes into AggregatorArrow may not be the same as what comes out of
        /// AggregatorPipe.
        /// For example, duplicates removed, different order to the stream, etc.
        /// Finally, note that different Collections have different behaviors and
        /// write/read times.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="ICollection">An optional ICollection to store the passed messages/objects.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static AggregatorArrow <TMessage> Aggregator <TMessage>(this IArrowSender <TMessage> ArrowSender, ICollection <TMessage> ICollection, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
        {
            var _AggregatorArrow = new AggregatorArrow <TMessage>(ICollection, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _AggregatorArrow.ReceiveMessage;
            return(_AggregatorArrow);
        }
Beispiel #13
0
        /// <summary>
        /// The ActionArrow is much like the IdentityArrow, but calls
        /// an Action &lt;S&gt; on every accepted message/object before
        /// forwarding it.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Action">An Action &lt;S&gt; to invoke on every accepted message/object before forwarding it.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static ActionArrow ActionArrow(this IArrowSender ArrowSender, Action_Object Action, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
        {
            var _ActionArrow = new ActionArrow(Action, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _ActionArrow.ReceiveMessage;
            return(_ActionArrow);
        }
Beispiel #14
0
 /// <summary>
 /// The IdentityArrow is the most basic arrow.
 /// It simply sends the incoming message to the recipients without any processing.
 /// This arrow is useful in various test case situations.
 /// </summary>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public IdentityArrow(IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
     : base(Recipient, Recipients)
 { }
Beispiel #15
0
        /// <summary>
        /// Filters the consuming objects by calling a Func&lt;S, Boolean&gt;.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="FilterFunc">A Func&lt;S, Boolean&gt; filtering the consuming objects. True means filter (ignore).</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static FuncFilterArrow <TMessage> FuncFilter <TMessage>(this IArrowSender <TMessage> ArrowSender, Func <TMessage, Boolean> FilterFunc, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
        {
            var _FuncFilterArrow = new FuncFilterArrow <TMessage>(FilterFunc, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _FuncFilterArrow.ReceiveMessage;
            return(_FuncFilterArrow);
        }
 /// <summary>
 /// Accepts a message of type TIn from a sender for further processing
 /// and delivery to the subscribers.
 /// </summary>
 /// <typeparam name="TMessage">The type of the consuming messages/objects.</typeparam>
 /// <param name="ArrowReceiver">The receiver of the message.</param>
 /// <param name="Message">The message.</param>
 /// <returns>True if the message was accepted and could be processed; False otherwise.</returns>
 public static Boolean ReceiveMessage <TMessage>(this IArrowReceiver <TMessage> ArrowReceiver, TMessage Message)
 {
     return(ArrowReceiver.ReceiveMessage(null, Message));
 }
 /// <summary>
 /// The IdentityArrow is much like the IdentityArrow, but calls
 /// an Action &lt;S&gt; on every accepted message/object before
 /// forwarding it.
 /// </summary>
 /// <param name="ArrowSender">The sender of the messages/objects.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">Further recipients of the processed messages.</param>
 public static IdentityArrow IdentityArrow(this IArrowSender ArrowSender, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
 {
     var _IdentityArrow = new IdentityArrow(Recipient, Recipients);
     ArrowSender.OnMessageAvailable += _IdentityArrow.ReceiveMessage;
     return _IdentityArrow;
 }
Beispiel #18
0
        /// <summary>
        /// Creates a new AbstractArrow and adds the given recipients
        /// to the list of message recipients.
        /// </summary>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">The recipients of the processed messages.</param>
        public AbstractArrowSender(IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
        {

            lock (this)
            {

                if (Recipient != null)
                    this.OnMessageAvailable += Recipient.ReceiveMessage;

                if (Recipients != null)
                    foreach (var _Recipient in Recipients)
                        this.OnMessageAvailable += _Recipient.ReceiveMessage;

            }

        }
 /// <summary>
 /// The StdDevSideEffectArrow produces a side effect that
 /// is the sliding standard deviation and the average of
 /// messages/objects that have passed through it.
 /// </summary>
 /// <param name="ArrowSender">The sender of the messages/objects.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">Further recipients of the processed messages.</param>
 public static StdDevSideEffectArrow StdDevSideEffectArrow(this IArrowSender<Double> ArrowSender, IArrowReceiver<Double> Recipient, params IArrowReceiver<Double>[] Recipients)
 {
     var _CountArrow = new StdDevSideEffectArrow(Recipient, Recipients);
     ArrowSender.OnMessageAvailable += _CountArrow.ReceiveMessage;
     return _CountArrow;
 }
        /// <summary>
        /// Sends a message when then received values are not within
        /// the bounding box of then given Min/Max-values.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Lower">The lower bound of the passed values.</param>
        /// <param name="Upper">The upper bound of the passed values.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static BandFilterArrow <TMessage> BandFilter <TMessage>(this IArrowSender <TMessage> ArrowSender, TMessage Lower, TMessage Upper, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
            where TMessage : IComparable <TMessage>, IComparable
        {
            var _BandFilterArrow = new BandFilterArrow <TMessage>(Lower, Upper, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _BandFilterArrow.ReceiveMessage;
            return(_BandFilterArrow);
        }
        /// <summary>
        /// The StdDevSideEffectArrow produces a side effect that
        /// is the sliding standard deviation and the average of
        /// messages/objects that have passed through it.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static StdDevSideEffectArrow StdDevSideEffectArrow(this IArrowSender <Double> ArrowSender, IArrowReceiver <Double> Recipient, params IArrowReceiver <Double>[] Recipients)
        {
            var _CountArrow = new StdDevSideEffectArrow(Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _CountArrow.ReceiveMessage;
            return(_CountArrow);
        }
Beispiel #22
0
 /// <summary>
 /// The SkipArrow simply sends the incoming message to the recipients
 /// without any processing, but skips the first n messages.
 /// </summary>
 /// <param name="ArrowSender">The sender of the messages/objects.</param>
 /// <param name="NumberOfMessagesToSkip">The number of messages to skip.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">Further recipients of the processed messages.</param>
 public static SkipArrow SkipArrow(this IArrowSender ArrowSender, UInt32 NumberOfMessagesToSkip, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
 {
     var _SkipArrow = new SkipArrow(NumberOfMessagesToSkip, Recipient, Recipients);
     ArrowSender.OnMessageAvailable += _SkipArrow.ReceiveMessage;
     return _SkipArrow;
 }
Beispiel #23
0
 /// <summary>
 /// The IdentityArrow is the most basic arrow.
 /// It simply sends the incoming message to the recipients without any processing.
 /// This arrow is useful in various test case situations.
 /// </summary>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public IdentityArrow(IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
     : base(Recipient, Recipients)
 {
 }
Beispiel #24
0
        /// <summary>
        /// The CountArrow produces a side effect that is the total
        /// number of messages/objects that have passed through it.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="InitialValue">The initial value of the counter.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static CountArrow <TMessage> Count <TMessage>(this IArrowSender <TMessage> ArrowSender, Int64 InitialValue, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
        {
            var _CountArrow = new CountArrow <TMessage>(InitialValue, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _CountArrow.ReceiveMessage;
            return(_CountArrow);
        }
Beispiel #25
0
 /// <summary>
 /// The SkipArrow simply sends the incoming message to the recipients
 /// without any processing, but skips the first n messages.
 /// </summary>
 /// <param name="NumberOfMessagesToSkip">The number of messages to skip.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public SkipArrow(UInt32 NumberOfMessagesToSkip, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
     : base(Recipient, Recipients)
 {
     this.NumberOfMessagesToSkip = NumberOfMessagesToSkip;
 }
Beispiel #26
0
        /// <summary>
        /// The MinMaxArrow produces two side effects which keep
        /// track of the Min and Max values of S.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Min">The initial minimum.</param>
        /// <param name="Max">The initial maximum.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static MinMaxArrow <TMessage> MinMax <TMessage>(this IArrowSender <TMessage> ArrowSender, TMessage Min, TMessage Max, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
            where TMessage : IComparable, IComparable <TMessage>, IEquatable <TMessage>
        {
            var _MinMaxArrow = new MinMaxArrow <TMessage>(Min, Max, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _MinMaxArrow.ReceiveMessage;
            return(_MinMaxArrow);
        }
Beispiel #27
0
        /// <summary>
        /// The SkipArrow simply sends the incoming message to the recipients
        /// without any processing, but skips the first n messages.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="NumberOfMessagesToSkip">The number of messages to skip.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static SkipArrow SkipArrow(this IArrowSender ArrowSender, UInt32 NumberOfMessagesToSkip, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
        {
            var _SkipArrow = new SkipArrow(NumberOfMessagesToSkip, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _SkipArrow.ReceiveMessage;
            return(_SkipArrow);
        }
Beispiel #28
0
 /// <summary>
 /// The SkipArrow simply sends the incoming message to the recipients
 /// without any processing, but skips the first n messages.
 /// </summary>
 /// <param name="NumberOfMessagesToSkip">The number of messages to skip.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public SkipArrow(UInt32 NumberOfMessagesToSkip, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
     : base(Recipient, Recipients)
 {
     this.NumberOfMessagesToSkip = NumberOfMessagesToSkip;
 }
Beispiel #29
0
 /// <summary>
 /// The StdDevArrow consumes doubles and emitts the
 /// sliding standard deviation and the average of
 /// messages/objects that have passed through it.
 /// </summary>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public StdDevArrow(IArrowReceiver <Tuple <Double, Double, Double> > Recipient, params IArrowReceiver <Tuple <Double, Double, Double> >[] Recipients)
     : base(Recipient, Recipients)
 {
 }
Beispiel #30
0
 /// <summary>
 /// The DuplicateFilterArrow will not allow a duplicate object to pass through it.
 /// This is accomplished by the Arrow maintaining an internal HashSet that is used
 /// to store a history of previously seen objects.
 /// Thus, the more unique objects that pass through this Arrow, the slower it
 /// becomes as a log_2 index is checked for every object.
 /// </summary>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public DuplicateFilterArrow(IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
     : base(Recipient, Recipients)
 {
     _HistorySet = new HashSet <TMessage>();
 }
Beispiel #31
0
        /// <summary>
        /// The StdDevArrow consumes doubles and emitts the
        /// sliding standard deviation and the average of
        /// messages/objects that have passed through it.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static StdDevArrow StdDevArrow(this IArrowSender <Double> ArrowSender, IArrowReceiver <Tuple <Double, Double, Double> > Recipient, params IArrowReceiver <Tuple <Double, Double, Double> >[] Recipients)
        {
            var _StdDevArrow = new StdDevArrow(Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _StdDevArrow.ReceiveMessage;
            return(_StdDevArrow);
        }
Beispiel #32
0
 /// <summary>
 /// The CountArrow produces a side effect that is the total
 /// number of messages/objects that have passed through it.
 /// </summary>
 /// <param name="InitialValue">The initial value of the counter.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public CountArrow(Int64 InitialValue, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
     : base(Recipient, Recipients)
 {
     _SideEffect = InitialValue;
 }
 /// <summary>
 /// The ActionArrow is much like the IdentityArrow, but calls
 /// an Action &lt;S&gt; on every accepted message/object before
 /// forwarding it.
 /// </summary>
 /// <param name="ArrowSender">The sender of the messages/objects.</param>
 /// <param name="Action">An Action &lt;S&gt; to invoke on every accepted message/object before forwarding it.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">Further recipients of the processed messages.</param>
 public static ActionArrow ActionArrow(this IArrowSender ArrowSender, Action_Object Action, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
 {
     var _ActionArrow = new ActionArrow(Action, Recipient, Recipients);
     ArrowSender.OnMessageAvailable += _ActionArrow.ReceiveMessage;
     return _ActionArrow;
 }
Beispiel #34
0
        /// <summary>
        /// The ActionArrow is much like the IdentityArrow, but calls
        /// an Action &lt;S&gt; on every accepted message/object before
        /// forwarding it.
        /// </summary>
        /// <param name="Action">An Action &lt;S&gt; to invoke on every accepted message/object before forwarding it.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">The recipients of the processed messages.</param>
        public ActionArrow(Action_Object Action, IArrowReceiver Recipient, params IArrowReceiver[] Recipients)
            : base(Recipient, Recipients)
        {

            if (Action == null)
                throw new ArgumentNullException("The given Action<TIn> must not be null!");

            this.Action = Action;

        }
Beispiel #35
0
        /// <summary>
        /// A generic Arrow transforming incoming messages into outgoing messages.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Func">A generic transformation of incoming messages into outgoing messages.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static FuncArrow <TIn, TOutput> FuncArrow <TIn, TOutput>(this IArrowSender <TIn> ArrowSender, Func <TIn, TOutput> Func, IArrowReceiver <TOutput> Recipient, params IArrowReceiver <TOutput>[] Recipients)
        {
            var _FuncArrow = new FuncArrow <TIn, TOutput>(Func, Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _FuncArrow.ReceiveMessage;
            return(_FuncArrow);
        }
Beispiel #36
0
 /// <summary>
 /// Filters the consuming objects by calling a Func&lt;S, Boolean&gt;.
 /// </summary>
 /// <param name="Lower">The lower bound of the passed values.</param>
 /// <param name="Upper">The upper bound of the passed values.</param>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public BandFilterArrow(TMessage Lower, TMessage Upper, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
     : base(Recipient, Recipients)
 {
     this.Lower = Lower;
     this.Upper = Upper;
 }
Beispiel #37
0
        /// <summary>
        /// The DuplicateFilterArrow will not allow a duplicate object to pass through it.
        /// This is accomplished by the Arrow maintaining an internal HashSet that is used
        /// to store a history of previously seen objects.
        /// Thus, the more unique objects that pass through this Arrow, the slower it
        /// becomes as a log_2 index is checked for every object.
        /// </summary>
        /// <param name="ArrowSender">The sender of the messages/objects.</param>
        /// <param name="Recipient">A recipient of the processed messages.</param>
        /// <param name="Recipients">Further recipients of the processed messages.</param>
        public static DuplicateFilterArrow <TMessage> DuplicateFilter <TMessage>(this IArrowSender <TMessage> ArrowSender, IArrowReceiver <TMessage> Recipient, params IArrowReceiver <TMessage>[] Recipients)
        {
            var _DuplicateFilterArrow = new DuplicateFilterArrow <TMessage>(Recipient, Recipients);

            ArrowSender.OnMessageAvailable += _DuplicateFilterArrow.ReceiveMessage;
            return(_DuplicateFilterArrow);
        }
Beispiel #38
0
 /// <summary>
 /// The StdDevSideEffectArrow produces a side effect that
 /// is the sliding standard deviation and the average of
 /// messages/objects that have passed through it.
 /// </summary>
 /// <param name="Recipient">A recipient of the processed messages.</param>
 /// <param name="Recipients">The recipients of the processed messages.</param>
 public StdDevSideEffectArrow(IArrowReceiver <Double> Recipient, params IArrowReceiver <Double>[] Recipients)
     : base(Recipient, Recipients)
 {
 }