internal DocumentSelectionMark(V3SelectionMarkState statePrivate, IReadOnlyList <float> boundingBoxPrivate, DocumentSpan span, float confidence)
 {
     StatePrivate       = statePrivate;
     BoundingBoxPrivate = boundingBoxPrivate;
     Span       = span;
     Confidence = confidence;
 }
 internal DocumentSelectionMark(V3SelectionMarkState statePrivate, DocumentSpan span, float confidence)
 {
     StatePrivate       = statePrivate;
     BoundingBoxPrivate = new ChangeTrackingList <float>();
     Span       = span;
     Confidence = confidence;
 }
Exemplo n.º 3
0
 internal DocumentSelectionMark(V3SelectionMarkState statePrivate, IReadOnlyList <float> polygon, DocumentSpan span, float confidence)
 {
     StatePrivate = statePrivate;
     Polygon      = polygon;
     Span         = span;
     Confidence   = confidence;
 }
        internal DocumentSelectionMark(V3SelectionMarkState statePrivate, DocumentSpan span, float confidence)
        {
            if (span == null)
            {
                throw new ArgumentNullException(nameof(span));
            }

            StatePrivate       = statePrivate;
            BoundingBoxPrivate = new ChangeTrackingList <float>();
            Span       = span;
            Confidence = confidence;
        }
Exemplo n.º 5
0
        internal static DocumentSelectionMark DeserializeDocumentSelectionMark(JsonElement element)
        {
            V3SelectionMarkState state = default;
            Optional <IReadOnlyList <float> > boundingBox = default;
            DocumentSpan span       = default;
            float        confidence = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("state"))
                {
                    state = new V3SelectionMarkState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("boundingBox"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <float> array = new List <float>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetSingle());
                    }
                    boundingBox = array;
                    continue;
                }
                if (property.NameEquals("span"))
                {
                    span = DocumentSpan.DeserializeDocumentSpan(property.Value);
                    continue;
                }
                if (property.NameEquals("confidence"))
                {
                    confidence = property.Value.GetSingle();
                    continue;
                }
            }
            return(new DocumentSelectionMark(state, Optional.ToList(boundingBox), span, confidence));
        }
        internal static DocumentField DeserializeDocumentField(JsonElement element)
        {
            DocumentFieldType                         type                      = default;
            Optional <string>                         valueString               = default;
            Optional <DateTimeOffset>                 valueDate                 = default;
            Optional <TimeSpan>                       valueTime                 = default;
            Optional <string>                         valuePhoneNumber          = default;
            Optional <double>                         valueNumber               = default;
            Optional <int>                            valueInteger              = default;
            Optional <V3SelectionMarkState>           valueSelectionMark        = default;
            Optional <DocumentSignatureType>          valueSignature            = default;
            Optional <string>                         valueCountryRegion        = default;
            Optional <IReadOnlyList <DocumentField> > valueArray                = default;
            Optional <IReadOnlyDictionary <string, DocumentField> > valueObject = default;
            Optional <CurrencyValue> valueCurrency = default;
            Optional <string>        content       = default;
            Optional <IReadOnlyList <BoundingRegion> > boundingRegions = default;
            Optional <IReadOnlyList <DocumentSpan> >   spans           = default;
            Optional <float> confidence = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString().ToDocumentFieldType();
                    continue;
                }
                if (property.NameEquals("valueString"))
                {
                    valueString = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("valueDate"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueDate = property.Value.GetDateTimeOffset("D");
                    continue;
                }
                if (property.NameEquals("valueTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueTime = property.Value.GetTimeSpan("T");
                    continue;
                }
                if (property.NameEquals("valuePhoneNumber"))
                {
                    valuePhoneNumber = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("valueNumber"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueNumber = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("valueInteger"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueInteger = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("valueSelectionMark"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueSelectionMark = new V3SelectionMarkState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("valueSignature"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueSignature = new DocumentSignatureType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("valueCountryRegion"))
                {
                    valueCountryRegion = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("valueArray"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentField> array = new List <DocumentField>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeserializeDocumentField(item));
                    }
                    valueArray = array;
                    continue;
                }
                if (property.NameEquals("valueObject"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, DocumentField> dictionary = new Dictionary <string, DocumentField>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, DeserializeDocumentField(property0.Value));
                    }
                    valueObject = dictionary;
                    continue;
                }
                if (property.NameEquals("valueCurrency"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    valueCurrency = CurrencyValue.DeserializeCurrencyValue(property.Value);
                    continue;
                }
                if (property.NameEquals("content"))
                {
                    content = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("boundingRegions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <BoundingRegion> array = new List <BoundingRegion>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(BoundingRegion.DeserializeBoundingRegion(item));
                    }
                    boundingRegions = array;
                    continue;
                }
                if (property.NameEquals("spans"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentSpan> array = new List <DocumentSpan>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentSpan.DeserializeDocumentSpan(item));
                    }
                    spans = array;
                    continue;
                }
                if (property.NameEquals("confidence"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    confidence = property.Value.GetSingle();
                    continue;
                }
            }
            return(new DocumentField(type, valueString.Value, Optional.ToNullable(valueDate), Optional.ToNullable(valueTime), valuePhoneNumber.Value, Optional.ToNullable(valueNumber), Optional.ToNullable(valueInteger), Optional.ToNullable(valueSelectionMark), Optional.ToNullable(valueSignature), valueCountryRegion.Value, Optional.ToList(valueArray), Optional.ToDictionary(valueObject), Optional.ToNullable(valueCurrency), content.Value, Optional.ToList(boundingRegions), Optional.ToList(spans), Optional.ToNullable(confidence)));
        }