internal static SelectionMark DeserializeSelectionMark(JsonElement element)
        {
            IReadOnlyList <float> boundingBox = default;
            float confidence         = default;
            SelectionMarkState state = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("boundingBox"))
                {
                    List <float> array = new List <float>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetSingle());
                    }
                    boundingBox = array;
                    continue;
                }
                if (property.NameEquals("confidence"))
                {
                    confidence = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("state"))
                {
                    state = new SelectionMarkState(property.Value.GetString());
                    continue;
                }
            }
            return(new SelectionMark(boundingBox, confidence, state));
        }
Beispiel #2
0
        internal SelectionMark(IEnumerable <float> boundingBox, float confidence, SelectionMarkState state)
        {
            if (boundingBox == null)
            {
                throw new ArgumentNullException(nameof(boundingBox));
            }

            BoundingBox = boundingBox.ToList();
            Confidence  = confidence;
            State       = state;
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldValue"/> structure. This constructor
 /// is intended to be used for mocking only.
 /// </summary>
 /// <param name="value">The actual field value.</param>
 internal FieldValue(SelectionMarkState value)
     : this()
 {
     ValueType          = FieldValueType.SelectionMark;
     ValueSelectionMark = value;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormRecognizer.Models.FormSelectionMark"/> class.
 /// </summary>
 /// <param name="boundingBox">The quadrilateral bounding box that outlines the element.</param>
 /// <param name="pageNumber">The 1-based number of the page in which this element is present.</param>
 /// <param name="text">The text of selection mark value.</param>
 /// <param name="confidence">Measures the degree of certainty of the recognition result.</param>
 /// <param name="state">Selection mark state value.</param>
 /// <returns>A new <see cref="FormRecognizer.Models.FormSelectionMark"/> instance for mocking.</returns>
 public static FormSelectionMark FormSelectionMark(FieldBoundingBox boundingBox, int pageNumber, string text, float confidence, SelectionMarkState state) =>
 new FormSelectionMark(boundingBox, pageNumber, text, confidence, state);
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FieldValue"/> structure.
 /// </summary>
 /// <param name="value">The actual field value.</param>
 /// <returns>A new <see cref="FieldValue"/> instance for mocking.</returns>
 public static FieldValue FieldValueWithSelectionMarkValueType(SelectionMarkState value) =>
 new FieldValue(value);
Beispiel #6
0
 public static string ToSerialString(this SelectionMarkState value) => value switch
 {
Beispiel #7
0
 internal SelectionMark(IReadOnlyList <float> boundingBox, float confidence, SelectionMarkState state)
 {
     BoundingBox = boundingBox;
     Confidence  = confidence;
     State       = state;
 }