Example #1
0
        internal static SystemData DeserializeSystemData(JsonElement element)
        {
            Optional <string>         createdBy          = default;
            Optional <CreatedByType>  createdByType      = default;
            Optional <DateTimeOffset> createdAt          = default;
            Optional <string>         lastModifiedBy     = default;
            Optional <CreatedByType>  lastModifiedByType = default;
            Optional <DateTimeOffset> lastModifiedAt     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("createdBy"))
                {
                    createdBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdByType"))
                {
                    createdByType = new CreatedByType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdAt"))
                {
                    createdAt = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lastModifiedBy"))
                {
                    lastModifiedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("lastModifiedByType"))
                {
                    lastModifiedByType = new CreatedByType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lastModifiedAt"))
                {
                    lastModifiedAt = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new SystemData(createdBy.Value, Optional.ToNullable(createdByType), Optional.ToNullable(createdAt), lastModifiedBy.Value, Optional.ToNullable(lastModifiedByType), Optional.ToNullable(lastModifiedAt)));
        }
        internal static SystemData DeserializeSystemData(JsonElement element)
        {
            string         createdBy          = default;
            CreatedByType? createdByType      = default;
            DateTimeOffset?createdAt          = default;
            string         lastModifiedBy     = default;
            CreatedByType? lastModifiedByType = default;
            DateTimeOffset?lastModifiedAt     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("createdBy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    createdBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdByType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    createdByType = new CreatedByType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdAt"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    createdAt = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lastModifiedBy"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastModifiedBy = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("lastModifiedByType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastModifiedByType = new CreatedByType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lastModifiedAt"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastModifiedAt = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new SystemData(createdBy, createdByType, createdAt, lastModifiedBy, lastModifiedByType, lastModifiedAt));
        }