public UnfoldArrow(IArrowSender <IEnumerable <T> > In = null) { if (In != null) { In.SendTo(this); } }
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; }
/// <summary> /// Sends a message when then received values are not within /// the bounding box of then given Min/Max-values. /// </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="InvertedFilter">Invert the filter behaviour.</param> /// <param name="ArrowSender">The sender of the messages/objects.</param> public BandFilterArrow(TMessage Lower, TMessage Upper, Boolean InvertedFilter = false, IArrowSender <TMessage> ArrowSender = null) : base(Message => { // Is Message < Lower? if (Message.CompareTo(Lower) < 0) { return(true); } // Is Message > Upper? if (Message.CompareTo(Upper) > 0) { return(true); } return(false); }, InvertedFilter, ArrowSender) { this.Lower = Lower; this.Upper = Upper; }
/// <summary> /// Create a new abstract concurrent arrow. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> /// <param name="MaxQueueSize">The maximum number of queued messages for both arrow senders.</param> public AbstractConcurrentArrow(UInt32 MaxQueueSize = 1000, IArrowSender <TIn> ArrowSender = null) : base(MaxQueueSize, ArrowSender) { }
/// <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> public static CountArrow <TMessage> Count <TMessage>(this IArrowSender <TMessage> ArrowSender, Int64 InitialValue = 0L) { var _CountArrow = new CountArrow <TMessage>(InitialValue); ArrowSender.OnMessageAvailable += _CountArrow.ReceiveMessage; return(_CountArrow); }
/// <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); }
Combine <TIn1, TIn2, TOut>(this IArrowSender <TIn1> ArrowSender1, IArrowSender <TIn2> ArrowSender2, Func <TIn1, TIn2, TOut> MessagesProcessor, UInt32 MaxQueueSize = 500) { return(new CombineArrow <TIn1, TIn2, TOut>(ArrowSender1, ArrowSender2, MessagesProcessor)); }
/// <summary> /// Create an new arrow for transforming two incoming messages into a single outgoing message. /// </summary> /// <param name="ArrowSender1">The first arrow sender.</param> /// <param name="ArrowSender2">The second arrow sender.</param> /// <param name="MessagesProcessor">A delegate for transforming two incoming messages into a single outgoing message.</param> /// <param name="MaxQueueSize">The maximum number of queued messages for both arrow senders.</param> public CombineArrow(IArrowSender <TIn1> ArrowSender1, IArrowSender <TIn2> ArrowSender2, Func <TIn1, TIn2, TOut> MessagesProcessor, UInt32 MaxQueueSize = 1000) { #region Initial checks if (ArrowSender1 == null) { throw new ArgumentNullException("ArrowSender1", "The parameter 'ArrowSender1' must not be null!"); } if (ArrowSender2 == null) { throw new ArgumentNullException("ArrowSender2", "The parameter 'ArrowSender2' must not be null!"); } if (MessagesProcessor == null) { throw new ArgumentNullException("MessagesProcessor", "The parameter 'MessagesProcessor' must not be null!"); } #endregion this.ArrowSender1 = ArrowSender1; this.ArrowSender2 = ArrowSender2; this.MessagesProcessor = MessagesProcessor; this.MaxQueueSize = MaxQueueSize; this.Queue1 = new ConcurrentQueue <TIn1>(); this.Queue2 = new ConcurrentQueue <TIn2>(); this.ArrowSender1.OnNotification += ReceiveMessage1; this.ArrowSender2.OnNotification += ReceiveMessage2; }
/// <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> /// The ActionArrow is much like the IdentityArrow, but calls /// an Action <S> on every accepted message/object before /// forwarding it. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> /// <param name="Action">An Action <S> 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); }
/// <summary> /// The ActionArrow is much like the IdentityArrow, but calls /// an Action <S> on every accepted message/object before /// forwarding it. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> /// <param name="Action">An Action <S> to invoke on every accepted message/object before forwarding it.</param> public static ActionArrow ActionArrow(this IArrowSender ArrowSender, Action_Object Action) { var _ActionArrow = new ActionArrow(Action); ArrowSender.OnMessageAvailable += _ActionArrow.ReceiveMessage; return(_ActionArrow); }
/// <summary> /// Filters the consuming objects by calling a Func<S, Boolean>. /// </summary> /// <param name="Include">A Func<TMessage, Boolean> filtering the consuming objects. True means forwardfilter (ignore).</param> /// <param name="ArrowSender">The sender of the messages/objects.</param> public WhereArrow(Func <TMessage, Boolean> Include, IArrowSender <TMessage> ArrowSender = null) : base(Include, false, ArrowSender) { }
/// <summary> /// Filters the consuming objects by calling a Func<S, Boolean>. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> /// <param name="FilterFunc">A Func<S, Boolean> filtering the consuming objects. True means filter (ignore).</param> public static FuncFilterArrow <TMessage> FuncFilter <TMessage>(this IArrowSender <TMessage> ArrowSender, Func <TMessage, Boolean> FilterFunc) { var _FuncFilterArrow = new FuncFilterArrow <TMessage>(FilterFunc); ArrowSender.OnMessageAvailable += _FuncFilterArrow.ReceiveMessage; return(_FuncFilterArrow); }
/// <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); }
/// <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> public static AggregatorArrow <TMessage> Aggregator <TMessage>(this IArrowSender <TMessage> ArrowSender, ICollection <TMessage> ICollection = null) { var _AggregatorArrow = new AggregatorArrow <TMessage>(ICollection); ArrowSender.OnMessageAvailable += _AggregatorArrow.ReceiveMessage; return(_AggregatorArrow); }
/// <summary> /// The MinMaxArrow produces two side effects which keep /// track of the Min and Max values of TMessage. /// </summary> /// <param name="Min">The initial minimum.</param> /// <param name="Max">The initial maximum.</param> /// <param name="ArrowSender">The sender of the messages/objects.</param> public MinMaxArrow(TMessage Min, TMessage Max, IArrowSender <TMessage> ArrowSender = null) { this.SideEffect1 = Min; this.SideEffect2 = Max; }
/// <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> public static DuplicateFilterArrow <TMessage> DuplicateFilter <TMessage>(this IArrowSender <TMessage> ArrowSender) { var _DuplicateFilterArrow = new DuplicateFilterArrow <TMessage>(); ArrowSender.OnMessageAvailable += _DuplicateFilterArrow.ReceiveMessage; return(_DuplicateFilterArrow); }
/// <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> public static FuncArrow <TIn, TOutput> FuncArrow <TIn, TOutput>(this IArrowSender <TIn> ArrowSender, Func <TIn, TOutput> Func) { var _FuncArrow = new FuncArrow <TIn, TOutput>(Func); ArrowSender.OnMessageAvailable += _FuncArrow.ReceiveMessage; return(_FuncArrow); }
/// <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); }
/// <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); }
/// <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> public static SkipArrow SkipArrow(this IArrowSender ArrowSender, UInt32 NumberOfMessagesToSkip) { var _SkipArrow = new SkipArrow(NumberOfMessagesToSkip); ArrowSender.OnMessageAvailable += _SkipArrow.ReceiveMessage; return(_SkipArrow); }
/// <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> public static StdDevArrow StdDevArrow(this IArrowSender <Double> ArrowSender) { var _StdDevArrow = new StdDevArrow(); ArrowSender.OnMessageAvailable += _StdDevArrow.ReceiveMessage; return(_StdDevArrow); }
/// <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); }
/// <summary> /// The IdentityArrow is much like the IdentityArrow, but calls /// an Action <S> 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); }
/// <summary> /// The IdentityArrow is much like the IdentityArrow, but calls /// an Action <S> on every accepted message/object before /// forwarding it. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> public static IdentityArrow IdentityArrow(this IArrowSender ArrowSender) { var _IdentityArrow = new IdentityArrow(); ArrowSender.OnMessageAvailable += _IdentityArrow.ReceiveMessage; return(_IdentityArrow); }
/// <summary> /// Filters the consuming objects by calling a Func<S, Boolean>. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> /// <param name="FilterFunc">A Func<S, Boolean> 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> /// 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, MessageRecipient <TMessage> Recipient, params MessageRecipient <TMessage>[] Recipients) { var _AggregatorArrow = new AggregatorArrow <TMessage>(ICollection, Recipient, Recipients); ArrowSender.OnMessageAvailable += _AggregatorArrow.ReceiveMessage; return(_AggregatorArrow); }
/// <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); }
/// <summary> /// Create a new abstract filter arrow. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> public AbstractFilterArrow(Func <TMessage, Boolean> Include = null, Boolean InvertedFilter = false, IArrowSender <TMessage> ArrowSender = null) : base(ArrowSender) { }
/// <summary> /// Transform the given enumeration of geo coordinates into a shape definition. /// </summary> /// <param name="ArrowSender">The sender of the messages/objects.</param> /// <param name="OnScreenUpperLeft">The upper-left screen offset.</param> /// <param name="ZoomLevel">The current zoom level of the Aegir map.</param> /// <param name="CloseShape">Whether to close the shape (polygon), or not (line).</param> /// <param name="OnError">A delegate to transform an incoming error into an outgoing error.</param> public static GeoCoordinates2ShapeDefinitionArrow ToShapeDefinition(this IArrowSender <IEnumerable <GeoCoordinate> > ArrowSender, ScreenXY OnScreenUpperLeft, UInt32 ZoomLevel, Boolean CloseShape, Func <Exception, Exception> OnError = null) { return(new GeoCoordinates2ShapeDefinitionArrow(OnScreenUpperLeft, ZoomLevel, CloseShape, OnError, ArrowSender)); }