Beispiel #1
0
        public SerializedNotification ToJson(INotification notification)
        {
            SerializedNotification serialized = new SerializedNotification()
            {
                NotificationClassName = notificationTypeCache.GetNotificationTypeName(notification.GetType()),
                NotificationJson      = JsonConvert.SerializeObject(notification, JsonSerializerSettings)
            };

            return(serialized);
        }
Beispiel #2
0
        private async Task AddNotification(INotification notification)
        {
            T tNotification = notification as T;

            if (tNotification == null)
            {
                throw new ArgumentException(
                          $"Invalid notification passed to {this.GetType().FullName}.PushNotificationAsync: {notification.GetType().FullName}");
            }

            SerializedNotification serialized = notificationSerializer.ToJson(notification);

            Guid bufferId = await bufferSelector.SelectBufferIdAsync(tNotification);

            await bufferedNotificationStore.Add(serialized, bufferId, Clock.Current.Now,
                                                bufferGovernor.Id, notificationPipeline.Id);
        }
        public async Task Add(SerializedNotification serializedNotification, Guid bufferId,
                              DateTimeOffset timeQueued, Guid bufferGovernorId, Guid notificationPipelineId)
        {
            NotificationBuffer buffer = await crudRepository.FindAsync <NotificationBuffer>(bufferId);

            if (buffer == null)
            {
                buffer = new NotificationBuffer(bufferId, bufferGovernorId, notificationPipelineId);
                crudRepository.Add(buffer); // TODO race condition - use AddOrUpdate instead
            }

            BufferedNotification notification = new BufferedNotification(
                id: Guid.NewGuid(),
                buffer: buffer,
                notificationClassName: serializedNotification.NotificationClassName,
                notificationJson: serializedNotification.NotificationJson,
                timeQueued: timeQueued
                );

            crudRepository.Add(notification);
        }
Beispiel #4
0
        public INotification FromJson(SerializedNotification serializedNotification)
        {
            Type notificationType = notificationTypeCache.GetClrNotificationType(serializedNotification.NotificationClassName);

            return((INotification)JsonConvert.DeserializeObject(serializedNotification.NotificationJson, notificationType, JsonSerializerSettings));
        }