/// <summary>
        /// Adds a <see cref="DeliveryConstraint" /> to a <see cref="ContextBag" />.
        /// </summary>
        public static void AddDeliveryConstraint(this ContextBag context, DeliveryConstraint constraint)
        {
            List <DeliveryConstraint> constraints;

            if (!context.TryGet(out constraints))
            {
                constraints = new List <DeliveryConstraint>();

                context.Set(constraints);
            }

            if (constraints.Any(c => c.GetType() == constraint.GetType()))
            {
                throw new InvalidOperationException("Constraint of type " + constraint.GetType().FullName + " already exists");
            }

            constraints.Add(constraint);
        }
Example #2
0
        static void AddDeliveryConstraintInternal(IBehaviorContext context, DeliveryConstraint constraint)
        {
            List <DeliveryConstraint> constraints;

            if (!context.Extensions.TryGet(out constraints))
            {
                constraints = new List <DeliveryConstraint>();

                context.Extensions.Set(constraints);
            }

            if (constraints.Any(c => c.GetType() == constraint.GetType()))
            {
                throw new InvalidOperationException("Constraint of type " + constraint.GetType().FullName + " already exists");
            }

            constraints.Add(constraint);
        }