internal static CustomFormModelInfo DeserializeCustomFormModelInfo(JsonElement element)
        {
            string modelId = default;
            CustomFormModelStatus status                    = default;
            DateTimeOffset        createdDateTime           = default;
            DateTimeOffset        lastUpdatedDateTime       = default;
            Optional <string>     modelName                 = default;
            Optional <CustomFormModelProperties> attributes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("modelId"))
                {
                    modelId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString().ToCustomFormModelStatus();
                    continue;
                }
                if (property.NameEquals("createdDateTime"))
                {
                    createdDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("lastUpdatedDateTime"))
                {
                    lastUpdatedDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("modelName"))
                {
                    modelName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("attributes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    attributes = CustomFormModelProperties.DeserializeCustomFormModelProperties(property.Value);
                    continue;
                }
            }
            return(new CustomFormModelInfo(modelId, status, createdDateTime, lastUpdatedDateTime, modelName.Value, attributes.Value));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CustomFormModel"/> class.
 /// </summary>
 /// <param name="modelId">The unique identifier of this model.</param>
 /// <param name="status">A status indicating this model's readiness for use.</param>
 /// <param name="trainingStartedOn">The date and time (UTC) when model training was started.</param>
 /// <param name="trainingCompletedOn">The date and time (UTC) when model training completed.</param>
 /// <param name="submodels">A list of submodels that are part of this model, each of which can recognize and extract fields from a different type of form.</param>
 /// <param name="trainingDocuments">A list of meta-data about each of the documents used to train the model.</param>
 /// <param name="errors">A list of errors occurred during the training operation.</param>
 /// <param name="modelName">An optional, user-defined name to associate with your model.</param>
 /// <param name="properties">Model properties, like for example, if a model is composed.</param>
 internal CustomFormModel(
     string modelId,
     CustomFormModelStatus status,
     DateTimeOffset trainingStartedOn,
     DateTimeOffset trainingCompletedOn,
     IReadOnlyList <CustomFormSubmodel> submodels,
     IReadOnlyList <TrainingDocumentInfo> trainingDocuments,
     IReadOnlyList <FormRecognizerError> errors,
     string modelName,
     CustomFormModelProperties properties)
 {
     ModelId             = modelId;
     ModelName           = modelName;
     Properties          = properties;
     Status              = status;
     TrainingStartedOn   = trainingStartedOn;
     TrainingCompletedOn = trainingCompletedOn;
     Submodels           = submodels;
     TrainingDocuments   = trainingDocuments;
     Errors              = errors;
 }
Exemplo n.º 3
0
 /// <summary> Initializes a new instance of CustomFormModelInfo. </summary>
 /// <param name="modelId"> Model identifier. </param>
 /// <param name="status"> Status of the model. </param>
 /// <param name="trainingStartedOn"> Date and time (UTC) when the model was created. </param>
 /// <param name="trainingCompletedOn"> Date and time (UTC) when the status was last updated. </param>
 /// <param name="modelName"> An optional, user-defined name to associate with your model. </param>
 /// <param name="properties">Model properties, like for example, if a model is composed.</param>
 internal CustomFormModelInfo(string modelId, CustomFormModelStatus status, DateTimeOffset trainingStartedOn, DateTimeOffset trainingCompletedOn, string modelName, CustomFormModelProperties properties)
 {
     ModelId             = modelId;
     Status              = status;
     TrainingStartedOn   = trainingStartedOn;
     TrainingCompletedOn = trainingCompletedOn;
     ModelName           = modelName;
     Properties          = properties ?? new CustomFormModelProperties();
 }