public async Task <ScheduledRecurringMessage> ScheduleRecurringSend(IRecurringMessageScheduler scheduler, Uri destinationAddress,
                                                                            RecurringSchedule schedule, object message, IPipe <SendContext> pipe, CancellationToken cancellationToken)
        {
            if (scheduler == null)
            {
                throw new ArgumentNullException(nameof(scheduler));
            }
            if (schedule == null)
            {
                throw new ArgumentNullException(nameof(schedule));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (pipe == null)
            {
                throw new ArgumentNullException(nameof(pipe));
            }

            if (message is T msg)
            {
                return(await scheduler.ScheduleRecurringSend(destinationAddress, schedule, msg, pipe, cancellationToken).ConfigureAwait(false));
            }

            throw new ArgumentException("Unexpected message type: " + TypeMetadataCache.GetShortName(message.GetType()));
        }
        public async Task <ScheduledRecurringMessage> ScheduleRecurringSend(IRecurringMessageScheduler scheduler, Uri destinationAddress,
                                                                            RecurringSchedule schedule, object message, CancellationToken cancellationToken)
        {
            if (scheduler == null)
            {
                throw new ArgumentNullException(nameof(scheduler));
            }
            if (schedule == null)
            {
                throw new ArgumentNullException(nameof(schedule));
            }
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var msg = message as T;

            if (msg == null)
            {
                throw new ArgumentException("Unexpected message type: " + message.GetType().GetTypeName());
            }

            ScheduledRecurringMessage <T> scheduleSend = await scheduler.ScheduleRecurringSend(destinationAddress, schedule, msg, cancellationToken)
                                                         .ConfigureAwait(false);

            return(scheduleSend);
        }
 public static Task<ScheduledRecurringMessage> ScheduleRecurringSend(IRecurringMessageScheduler scheduler, Uri destinationAddress, RecurringSchedule schedule, object message,
     Type messageType, CancellationToken cancellationToken)
 {
     return Cached.Converters.Value[messageType].ScheduleRecurringSend(scheduler, destinationAddress, schedule, message, cancellationToken);
 }
 public static Task <ScheduledRecurringMessage> ScheduleRecurringSend(IRecurringMessageScheduler scheduler, Uri destinationAddress,
                                                                      RecurringSchedule schedule, object message,
                                                                      Type messageType, CancellationToken cancellationToken)
 {
     return(Cached.Converters.Value[messageType].ScheduleRecurringSend(scheduler, destinationAddress, schedule, message, cancellationToken));
 }