Example #1
0
        // TODO: Put strings into the resources.
        //
        static async Task <IList <ILocalSubscription> > P_PublicationFilterAsync(IRunControl publisherRunControl, ILocalMessage msg, IList <ILocalSubscription> sourceSubscriptions)
        {
            publisherRunControl.EnsureNotNull(nameof(publisherRunControl));
            msg.EnsureNotNull(nameof(msg));
            sourceSubscriptions.EnsureNotNull(nameof(sourceSubscriptions));
            //
            if (sourceSubscriptions.Count < 1 || publisherRunControl.HasStopRequested)
            {
                return(new ILocalSubscription[0]);
            }
            else
            {
                var sourceSubscriptionsList = new List <ILocalSubscription>();
                var length = sourceSubscriptions.Count;
                for (var offset = 0; offset < length; offset++)
                {
                    var subscription = sourceSubscriptions[offset];
                    if (subscription is null)
                    {
                        throw
                            new ArgumentException(
                                paramName: $"{nameof(sourceSubscriptions)}[{offset:d}]",
                                message: FormatXResource(typeof(Array), "CanNotContainNull/NullAt", offset.ToString("d")));
                    }
                    sourceSubscriptionsList.Add(subscription);
                }
                //
                var filterResultList = new List <ILocalSubscription>();
                for (var i = 0; i < sourceSubscriptionsList.Count; i++)
                {
                    if (publisherRunControl.HasStopRequested)
                    {
                        break;
                    }
                    //
                    var subscription             = sourceSubscriptionsList[i];
                    var subscriptionFilterResult = await subscription.PublicationFilterAsync(state : new LocalPublicationFilterState(message: msg, subscription: subscription)).ConfigureAwait(false);

                    if (!subscriptionFilterResult.CancelPublication)
                    {
                        filterResultList.Add(subscription);
                    }
                }
                //
                if (publisherRunControl.HasStopRequested)
                {
                    return(new ILocalSubscription[0]);
                }
                else
                {
                    return(filterResultList);
                }
            }
        }
Example #2
0
		// TODO: Put strings into the resources.
		//
		protected RunControlAttemptPropertiesBase(IRunControl runControl, bool isStart, int attemptNumber, int succeededAttemptCountBefore, XFullCorrelationId correlationId = default, object tag = default) {
			runControl.EnsureNotNull(nameof(runControl));
			attemptNumber.Arg(nameof(attemptNumber)).EnsureNotLessThanZero();
			succeededAttemptCountBefore.Arg(nameof(succeededAttemptCountBefore)).EnsureNotLessThanZero().EnsureNotGreaterThan(attemptNumber);
			if (correlationId?.IsEmpty == true)
				throw new ArgumentException(message: "Value cann't be an empty.", paramName: nameof(correlationId));
			//
			CorrelationId = correlationId;
			RunControl = runControl;
			IsStart = isStart;
			AttemptNumber = attemptNumber;
			SucceededAttemptCountBefore = succeededAttemptCountBefore;
			Tag = tag;
		}
Example #3
0
 public RunControlEventArgs(IRunControl runControl)
 {
     runControl.EnsureNotNull(nameof(runControl));
     //
     RunControl = runControl;
 }