Exemple #1
0
        internal static TaskAddResult DeserializeTaskAddResult(JsonElement element)
        {
            TaskAddStatus  status       = default;
            string         taskId       = default;
            string         eTag         = default;
            DateTimeOffset?lastModified = default;
            string         location     = default;
            BatchError     error        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString().ToTaskAddStatus();
                    continue;
                }
                if (property.NameEquals("taskId"))
                {
                    taskId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("eTag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    eTag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("lastModified"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastModified = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    error = BatchError.DeserializeBatchError(property.Value);
                    continue;
                }
            }
            return(new TaskAddResult(status, taskId, eTag, lastModified, location, error));
        }
Exemple #2
0
 internal TaskAddResult(TaskAddStatus status, string taskId, string eTag, DateTimeOffset?lastModified, string location, BatchError error)
 {
     Status       = status;
     TaskId       = taskId;
     ETag         = eTag;
     LastModified = lastModified;
     Location     = location;
     Error        = error;
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the TaskAddResult class.
 /// </summary>
 /// <param name="status">The status of the add task request.</param>
 /// <param name="taskId">The id of the task for which this is the
 /// result.</param>
 /// <param name="eTag">The ETag of the task, if the task was
 /// successfully added.</param>
 /// <param name="lastModified">The last modified time of the
 /// task.</param>
 /// <param name="location">The URL of the task, if the task was
 /// successfully added.</param>
 /// <param name="error">The error encountered while attempting to add
 /// the task.</param>
 public TaskAddResult(TaskAddStatus status, string taskId, string eTag = default(string), System.DateTime?lastModified = default(System.DateTime?), string location = default(string), BatchError error = default(BatchError))
 {
     Status       = status;
     TaskId       = taskId;
     ETag         = eTag;
     LastModified = lastModified;
     Location     = location;
     Error        = error;
 }
Exemple #4
0
        internal TaskAddResult(TaskAddStatus status, string taskId)
        {
            if (taskId == null)
            {
                throw new ArgumentNullException(nameof(taskId));
            }

            Status = status;
            TaskId = taskId;
        }
        internal static string ToSerializedValue(this TaskAddStatus value)
        {
            switch (value)
            {
            case TaskAddStatus.Success:
                return("success");

            case TaskAddStatus.ClientError:
                return("clienterror");

            case TaskAddStatus.ServerError:
                return("servererror");
            }
            return(null);
        }
 public static string ToSerialString(this TaskAddStatus value) => value switch
 {