Exemplo n.º 1
0
        /// <summary>
        /// Maps to EndpointData
        /// </summary>
        /// <param name="data">Mds Endpoint Data</param>
        /// <param name="state">The device state</param>
        /// <returns>The EndpointData</returns>
        public static DeviceEventData Map(mds.Model.EndpointData data, DeviceEvent state)
        {
            var endpointData = new DeviceEventData
            {
                QueueMode            = data.Q,
                EndpointType         = data.Ept,
                OriginalEndpointType = data.OriginalEp,
                Resources            = data?.Resources?.Select(r => ResourcesData.Map(r))?.ToList(),
                DeviceId             = data.Ep,
                State = state,
            };

            return(endpointData);
        }
Exemplo 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);
        }