示例#1
0
        public static void Send <T>(this T message, bool onCallback = false, string contextName = null)
            where T : class, ISpecializedMessage
        {
            if (message == null)
            {
                return;
            }

            using (var ctx = BusFactory.CreateBusContext())
            {
                SendInternal(ctx, message, onCallback, contextName);
            }
        }
示例#2
0
        public static void SendMany <T>(this List <T> messages, bool onCallback = false, string contextName = null)
            where T : class, ISpecializedMessage
        {
            if (messages == null || messages.Count == 0)
            {
                return;
            }

            using (var ctx = BusFactory.CreateBusContext())
            {
                foreach (var message in messages)
                {
                    SendInternal(ctx, message, onCallback, contextName);
                }
            }
        }
示例#3
0
        public static void SendMany(this CacheCollection cache)
        {
            if (cache == null || cache.Count == 0)
            {
                return;
            }

            var messages = cache.ToMessages();

            using (var ctx = BusFactory.CreateBusContext())
            {
                foreach (var message in messages)
                {
                    SendInternal(ctx, message);
                }
            }
        }
示例#4
0
        public static void Send(this IDto dto, ICallbackMessage callback = null)
        {
            if (dto == null)
            {
                return;
            }

            var message = dto.ToMessage();

            bool onCallback = callback != null && callback.Token != null;

            if (onCallback)
            {
                message.Token = callback.Token;
            }

            using (var ctx = BusFactory.CreateBusContext())
            {
                SendInternal(ctx, message, onCallback);
            }
        }