//|---------------------------------------------------------------|
//|                         WEB API CLIENT                        |
//|---------------------------------------------------------------|
//|                       Developed by Wonde Tadesse              |
//|                                  Copyright ©2014              |
//|---------------------------------------------------------------|
//|                         WEB API CLIENT                        |
//|---------------------------------------------------------------|
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;

namespace WebAPIClient
{
    /// <summary>
    /// Utility extension class
    /// </summary>
    public static class UtilityExtensionClasses
    {
        /// <summary>
        /// Try to get result from Task
        /// </summary>
        /// <typeparam name="T">Type value</typeparam>
        /// <param name="task">Task value</param>
        /// <returns>Object value</returns>
        public static object TryResult<T>(this Task<T> task)
        {
            if (task != null)
            {
                try
                {
                    return task.Result;
                }
                catch (Exception)
                {
                }
            }
            return task;
        }
    }
}
