/// <summary>
        /// Map Notification Data
        /// </summary>
        /// <param name="data">Mds NotificationData</param>
        /// <returns>The NotificationData</returns>
        public static NotificationData Map(mds.Model.NotificationData data)
        {
            var notificationData = new NotificationData
            {
                Path        = data.Path,
                MaxAge      = data.MaxAge,
                Payload     = data.Payload,
                DeviceId    = data.Ep,
                ContentType = data.Ct,
            };

            return(notificationData);
        }
Esempio n. 2
0
        /// <summary>
        /// Map the notification message
        /// </summary>
        /// <param name="data">Notification Message Data</param>
        /// <returns>The Notification Message</returns>
        public static NotificationMessage Map(mds.Model.NotificationMessage data)
        {
            var notificationMessage = new NotificationMessage
            {
                AsyncResponses  = data?.AsyncResponses?.Select(a => AsyncIdResponse.Map(a))?.ToList() ?? Enumerable.Empty <AsyncIdResponse>().ToList(),
                DeRegistrations = data?.DeRegistrations?.Select(r => new DeviceEventData {
                    DeviceId = r, State = DeviceEvent.DeRegistration
                })?.ToList() ?? Enumerable.Empty <DeviceEventData>().ToList(),
                RegistrationUpdates  = data?.RegUpdates?.Select(r => DeviceEventData.Map(r, DeviceEvent.RegistrationUpdate))?.ToList() ?? Enumerable.Empty <DeviceEventData>().ToList(),
                Registrations        = data?.Registrations?.Select(r => DeviceEventData.Map(r, DeviceEvent.Registration))?.ToList() ?? Enumerable.Empty <DeviceEventData>().ToList(),
                Notifications        = data?.Notifications?.Select(n => NotificationData.Map(n))?.ToList() ?? Enumerable.Empty <NotificationData>().ToList(),
                RegistrationsExpired = data?.RegistrationsExpired?.Select(r => new DeviceEventData {
                    DeviceId = r, State = DeviceEvent.ExpiredRegistration
                })?.ToList() ?? Enumerable.Empty <DeviceEventData>().ToList(),
            };

            return(notificationMessage);
        }