Exemplo n.º 1
0
        internal static WorkingHoursReportEntryApiModel DeserializeWorkingHoursReportEntryApiModel(JsonElement element)
        {
            Optional <string> comments = default;
            Optional <string> commentsCommaSeparated = default;
            Optional <string> commentsHtmlFormatted  = default;
            Optional <IReadOnlyList <WorkHoursReportDateRangeApiModel> > dateRangeList = default;
            Optional <int>            dateRangesCount      = default;
            Optional <string>         dateRangesFormatted  = default;
            Optional <int>            dayOfWeek            = default;
            Optional <string>         dayOfWeekName        = default;
            Optional <bool>           hasUnclosedEntries   = default;
            Optional <DateTimeOffset> startTime            = default;
            Optional <int>            totalUnclosedEntries = default;
            Optional <double>         totalWorkedHours     = default;
            Optional <string>         totalWorkedHoursAndMinutesShortFormatted = default;
            Optional <DateTimeOffset> utcStartTime = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("comments"))
                {
                    comments = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("commentsCommaSeparated"))
                {
                    commentsCommaSeparated = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("commentsHtmlFormatted"))
                {
                    commentsHtmlFormatted = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dateRangeList"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <WorkHoursReportDateRangeApiModel> array = new List <WorkHoursReportDateRangeApiModel>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(WorkHoursReportDateRangeApiModel.DeserializeWorkHoursReportDateRangeApiModel(item));
                    }
                    dateRangeList = array;
                    continue;
                }
                if (property.NameEquals("dateRangesCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    dateRangesCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("dateRangesFormatted"))
                {
                    dateRangesFormatted = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dayOfWeek"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    dayOfWeek = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("dayOfWeekName"))
                {
                    dayOfWeekName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("hasUnclosedEntries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    hasUnclosedEntries = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("totalUnclosedEntries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalUnclosedEntries = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("totalWorkedHours"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    totalWorkedHours = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("totalWorkedHoursAndMinutesShortFormatted"))
                {
                    totalWorkedHoursAndMinutesShortFormatted = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("utcStartTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    utcStartTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new WorkingHoursReportEntryApiModel(comments.Value, commentsCommaSeparated.Value, commentsHtmlFormatted.Value, Optional.ToList(dateRangeList), Optional.ToNullable(dateRangesCount), dateRangesFormatted.Value, Optional.ToNullable(dayOfWeek), dayOfWeekName.Value, Optional.ToNullable(hasUnclosedEntries), Optional.ToNullable(startTime), Optional.ToNullable(totalUnclosedEntries), Optional.ToNullable(totalWorkedHours), totalWorkedHoursAndMinutesShortFormatted.Value, Optional.ToNullable(utcStartTime)));
        }
Exemplo n.º 2
0
        internal static WorkingHoursReportEntryApiModel DeserializeWorkingHoursReportEntryApiModel(XElement element)
        {
            string         comments = default;
            string         commentsCommaSeparated = default;
            string         commentsHtmlFormatted  = default;
            int?           dateRangesCount        = default;
            string         dateRangesFormatted    = default;
            int?           dayOfWeek            = default;
            string         dayOfWeekName        = default;
            bool?          hasUnclosedEntries   = default;
            DateTimeOffset?startTime            = default;
            int?           totalUnclosedEntries = default;
            double?        totalWorkedHours     = default;
            string         totalWorkedHoursAndMinutesShortFormatted = default;
            DateTimeOffset?utcStartTime = default;
            IReadOnlyList <WorkHoursReportDateRangeApiModel> dateRangeList = default;

            if (element.Element("comments") is XElement commentsElement)
            {
                comments = (string)commentsElement;
            }
            if (element.Element("commentsCommaSeparated") is XElement commentsCommaSeparatedElement)
            {
                commentsCommaSeparated = (string)commentsCommaSeparatedElement;
            }
            if (element.Element("commentsHtmlFormatted") is XElement commentsHtmlFormattedElement)
            {
                commentsHtmlFormatted = (string)commentsHtmlFormattedElement;
            }
            if (element.Element("dateRangesCount") is XElement dateRangesCountElement)
            {
                dateRangesCount = (int?)dateRangesCountElement;
            }
            if (element.Element("dateRangesFormatted") is XElement dateRangesFormattedElement)
            {
                dateRangesFormatted = (string)dateRangesFormattedElement;
            }
            if (element.Element("dayOfWeek") is XElement dayOfWeekElement)
            {
                dayOfWeek = (int?)dayOfWeekElement;
            }
            if (element.Element("dayOfWeekName") is XElement dayOfWeekNameElement)
            {
                dayOfWeekName = (string)dayOfWeekNameElement;
            }
            if (element.Element("hasUnclosedEntries") is XElement hasUnclosedEntriesElement)
            {
                hasUnclosedEntries = (bool?)hasUnclosedEntriesElement;
            }
            if (element.Element("startTime") is XElement startTimeElement)
            {
                startTime = startTimeElement.GetDateTimeOffsetValue("O");
            }
            if (element.Element("totalUnclosedEntries") is XElement totalUnclosedEntriesElement)
            {
                totalUnclosedEntries = (int?)totalUnclosedEntriesElement;
            }
            if (element.Element("totalWorkedHours") is XElement totalWorkedHoursElement)
            {
                totalWorkedHours = (double?)totalWorkedHoursElement;
            }
            if (element.Element("totalWorkedHoursAndMinutesShortFormatted") is XElement totalWorkedHoursAndMinutesShortFormattedElement)
            {
                totalWorkedHoursAndMinutesShortFormatted = (string)totalWorkedHoursAndMinutesShortFormattedElement;
            }
            if (element.Element("utcStartTime") is XElement utcStartTimeElement)
            {
                utcStartTime = utcStartTimeElement.GetDateTimeOffsetValue("O");
            }
            var array = new List <WorkHoursReportDateRangeApiModel>();

            foreach (var e in element.Elements("WorkHoursReportDateRangeApiModel"))
            {
                array.Add(WorkHoursReportDateRangeApiModel.DeserializeWorkHoursReportDateRangeApiModel(e));
            }
            dateRangeList = array;
            return(new WorkingHoursReportEntryApiModel(comments, commentsCommaSeparated, commentsHtmlFormatted, dateRangeList, dateRangesCount, dateRangesFormatted, dayOfWeek, dayOfWeekName, hasUnclosedEntries, startTime, totalUnclosedEntries, totalWorkedHours, totalWorkedHoursAndMinutesShortFormatted, utcStartTime));
        }