示例#1
0
        internal static ApiListResultNotificationApiModel DeserializeApiListResultNotificationApiModel(JsonElement element)
        {
            Optional <long> count = default;
            Optional <IReadOnlyList <NotificationApiModel> > data = default;
            Optional <long> totalCount = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("count"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    count = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("data"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <NotificationApiModel> array = new List <NotificationApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(NotificationApiModel.DeserializeNotificationApiModel(item));
                    }
                    data = array;
                    continue;
                }
                if (property.NameEquals("totalCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalCount = property.Value.GetInt64();
                    continue;
                }
            }
            return(new ApiListResultNotificationApiModel(Optional.ToNullable(count), Optional.ToList(data), Optional.ToNullable(totalCount)));
        }
        internal static ApiResultNotificationApiModel DeserializeApiResultNotificationApiModel(JsonElement element)
        {
            Optional <NotificationApiModel> data = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("data"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    data = NotificationApiModel.DeserializeNotificationApiModel(property.Value);
                    continue;
                }
            }
            return(new ApiResultNotificationApiModel(data.Value));
        }
        internal static NotificationsAndMessagesApiModel DeserializeNotificationsAndMessagesApiModel(JsonElement element)
        {
            Optional <IReadOnlyList <MessageApiModel> >      messages      = default;
            Optional <IReadOnlyList <NotificationApiModel> > notifications = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("messages"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <MessageApiModel> array = new List <MessageApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MessageApiModel.DeserializeMessageApiModel(item));
                    }
                    messages = array;
                    continue;
                }
                if (property.NameEquals("notifications"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <NotificationApiModel> array = new List <NotificationApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(NotificationApiModel.DeserializeNotificationApiModel(item));
                    }
                    notifications = array;
                    continue;
                }
            }
            return(new NotificationsAndMessagesApiModel(Optional.ToList(messages), Optional.ToList(notifications)));
        }
示例#4
0
        internal static ApiListResultNotificationApiModel DeserializeApiListResultNotificationApiModel(XElement element)
        {
            long?count      = default;
            long?totalCount = default;
            IReadOnlyList <NotificationApiModel> data = default;

            if (element.Element("count") is XElement countElement)
            {
                count = (long?)countElement;
            }
            if (element.Element("totalCount") is XElement totalCountElement)
            {
                totalCount = (long?)totalCountElement;
            }
            var array = new List <NotificationApiModel>();

            foreach (var e in element.Elements("NotificationApiModel"))
            {
                array.Add(NotificationApiModel.DeserializeNotificationApiModel(e));
            }
            data = array;
            return(new ApiListResultNotificationApiModel(count, data, totalCount));
        }