/// <summary>
/// Processes the batch result.
/// </summary>
/// <param name="result">
/// The json result.
/// </param>
/// <returns>
/// Batch result.
/// </returns>
internal static object ProcessBatchResult(object result)
{
Contract.Requires(result != null);
Contract.Ensures(Contract.Result <object>() != null);
IList <object> list = new JsonArray();
var resultList = (IList <object>)result;
foreach (var row in resultList)
{
var body = (string)((IDictionary <string, object>)row)["body"];
var exception = ExceptionFactory.GetGraphException(body);
object jsonObject = null;
if (exception == null)
{
// check for rest exception
jsonObject = JsonSerializer.Current.DeserializeObject(body);
exception = ExceptionFactory.GetRestException(jsonObject);
}
list.Add(exception ?? jsonObject);
}
return(list);
}