Beispiel #1
0
        internal DocumentPage(int pageNumber, float angle, float width, float height, V3LengthUnit unitPrivate, IEnumerable <DocumentSpan> spans, IEnumerable <DocumentWord> words, IEnumerable <DocumentLine> lines)
        {
            if (spans == null)
            {
                throw new ArgumentNullException(nameof(spans));
            }
            if (words == null)
            {
                throw new ArgumentNullException(nameof(words));
            }
            if (lines == null)
            {
                throw new ArgumentNullException(nameof(lines));
            }

            PageNumber     = pageNumber;
            Angle          = angle;
            Width          = width;
            Height         = height;
            UnitPrivate    = unitPrivate;
            Spans          = spans.ToList();
            Words          = words.ToList();
            SelectionMarks = new ChangeTrackingList <DocumentSelectionMark>();
            Lines          = lines.ToList();
        }
Beispiel #2
0
 internal DocumentPage(int pageNumber, float angle, float width, float height, V3LengthUnit unitPrivate, IReadOnlyList <DocumentSpan> spans, IReadOnlyList <DocumentWord> words, IReadOnlyList <DocumentSelectionMark> selectionMarks, IReadOnlyList <DocumentLine> lines)
 {
     PageNumber     = pageNumber;
     Angle          = angle;
     Width          = width;
     Height         = height;
     UnitPrivate    = unitPrivate;
     Spans          = spans;
     Words          = words;
     SelectionMarks = selectionMarks;
     Lines          = lines;
 }
Beispiel #3
0
        internal static DocumentPage DeserializeDocumentPage(JsonElement element)
        {
            DocumentPageKind kind = default;
            int pageNumber        = default;
            Optional <float>                                  angle          = default;
            Optional <float>                                  width          = default;
            Optional <float>                                  height         = default;
            Optional <V3LengthUnit>                           unit           = default;
            IReadOnlyList <DocumentSpan>                      spans          = default;
            Optional <IReadOnlyList <DocumentWord> >          words          = default;
            Optional <IReadOnlyList <DocumentSelectionMark> > selectionMarks = default;
            Optional <IReadOnlyList <DocumentImage> >         images         = default;
            Optional <IReadOnlyList <DocumentLine> >          lines          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = new DocumentPageKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("pageNumber"))
                {
                    pageNumber = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("angle"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    angle = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("width"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    width = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("height"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    height = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    unit = new V3LengthUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("spans"))
                {
                    List <DocumentSpan> array = new List <DocumentSpan>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentSpan.DeserializeDocumentSpan(item));
                    }
                    spans = array;
                    continue;
                }
                if (property.NameEquals("words"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentWord> array = new List <DocumentWord>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentWord.DeserializeDocumentWord(item));
                    }
                    words = array;
                    continue;
                }
                if (property.NameEquals("selectionMarks"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentSelectionMark> array = new List <DocumentSelectionMark>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentSelectionMark.DeserializeDocumentSelectionMark(item));
                    }
                    selectionMarks = array;
                    continue;
                }
                if (property.NameEquals("images"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentImage> array = new List <DocumentImage>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentImage.DeserializeDocumentImage(item));
                    }
                    images = array;
                    continue;
                }
                if (property.NameEquals("lines"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentLine> array = new List <DocumentLine>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentLine.DeserializeDocumentLine(item));
                    }
                    lines = array;
                    continue;
                }
            }
            return(new DocumentPage(kind, pageNumber, Optional.ToNullable(angle), Optional.ToNullable(width), Optional.ToNullable(height), Optional.ToNullable(unit), spans, Optional.ToList(words), Optional.ToList(selectionMarks), Optional.ToList(images), Optional.ToList(lines)));
        }
Beispiel #4
0
        internal static DocumentPage DeserializeDocumentPage(JsonElement element)
        {
            int          pageNumber            = default;
            float        angle                 = default;
            float        width                 = default;
            float        height                = default;
            V3LengthUnit unit                  = default;
            IReadOnlyList <DocumentSpan> spans = default;
            IReadOnlyList <DocumentWord> words = default;
            Optional <IReadOnlyList <DocumentSelectionMark> > selectionMarks = default;
            IReadOnlyList <DocumentLine> lines = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("pageNumber"))
                {
                    pageNumber = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("angle"))
                {
                    angle = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("width"))
                {
                    width = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("height"))
                {
                    height = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = new V3LengthUnit(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("spans"))
                {
                    List <DocumentSpan> array = new List <DocumentSpan>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentSpan.DeserializeDocumentSpan(item));
                    }
                    spans = array;
                    continue;
                }
                if (property.NameEquals("words"))
                {
                    List <DocumentWord> array = new List <DocumentWord>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentWord.DeserializeDocumentWord(item));
                    }
                    words = array;
                    continue;
                }
                if (property.NameEquals("selectionMarks"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DocumentSelectionMark> array = new List <DocumentSelectionMark>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentSelectionMark.DeserializeDocumentSelectionMark(item));
                    }
                    selectionMarks = array;
                    continue;
                }
                if (property.NameEquals("lines"))
                {
                    List <DocumentLine> array = new List <DocumentLine>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DocumentLine.DeserializeDocumentLine(item));
                    }
                    lines = array;
                    continue;
                }
            }
            return(new DocumentPage(pageNumber, angle, width, height, unit, spans, words, Optional.ToList(selectionMarks), lines));
        }