Appccelerate.EventBroker.Internals.EventTopic.ThrowIfSubscriptionHandlerDoesNotMatchHandlerRestrictionOfPublisher C# (CSharp) Method

ThrowIfSubscriptionHandlerDoesNotMatchHandlerRestrictionOfPublisher() private static method

private static ThrowIfSubscriptionHandlerDoesNotMatchHandlerRestrictionOfPublisher ( ISubscription subscription, IPublication publication ) : void
subscription ISubscription
publication IPublication
return void
        private static void ThrowIfSubscriptionHandlerDoesNotMatchHandlerRestrictionOfPublisher(ISubscription subscription, IPublication publication)
        {
            if (publication.HandlerRestriction == HandlerRestriction.None)
            {
                return;
            }

            if ((int)subscription.Handler.Kind == (int)publication.HandlerRestriction)
            {
                return;
            }

            using (var writer = new StringWriter(CultureInfo.InvariantCulture))
            {
                writer.Write("Publication ");
                writer.WriteLine();
                publication.DescribeTo(writer);
                writer.WriteLine();
                writer.Write("does not allow subscription ");
                writer.WriteLine();
                subscription.DescribeTo(writer);
                writer.WriteLine();
                writer.Write(" because publisher requires the subscription handler to be ");
                writer.Write(publication.HandlerRestriction);

                throw new EventTopicException(writer.GetStringBuilder().ToString());
            }
        }