using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.FirmLib.Entity
{
    /// <summary>
    /// 数据平台参数处理相关
    /// </summary>
    public static class ParameterUtil
    {
        /// <summary>
        /// 将对象转换成相关json数组
        /// </summary>
        /// <param name="jobject"></param>
        /// <returns></returns>
        public static JArray ToArray(this JObject jobject)
        {
            JArray jArray = new JArray();
            jArray.Add(jobject);
            return jArray;
        }
        #region 获取值信息点
        /// <summary>
        /// 获取 null的值信息 
        /// </summary>
        /// <returns></returns>
        public  static  JArray CreateEmptyMbiInfo()
        {
            var jo = GetMbiInfo("");
            return jo.ToArray();
        }

        /// <summary>
        /// 获取信息点对象
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static JObject GetMbiInfo(JObject value)
        {
            JObject jobject = new JObject();
            jobject.Add("value", value);
            return jobject;
        }
        /// <summary>
        /// 获取信息点值对象
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static JObject GetMbiInfo(JToken value)
        {
            JObject jobject = new JObject();
            jobject.Add("value", value);
            return jobject;
        }
        /// <summary>
        /// 获取信息点值对象
        /// </summary>
        /// <param name="value"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public static JObject GetMbiInfo(JToken value, string time)
        {
            JObject jobject = new JObject();
            jobject.Add("value", value);
            jobject.Add("time", time);
            return jobject;
        } 
        #endregion
        public static JObject GetMbiInfo(string mbiCode, JObject jobject)
        {
            JArray jArray = new JArray();
            jArray.Add(jobject);
            return GetMbiInfo(mbiCode, jArray);
        }
        public static JObject GetMbiInfo(string mbiCode, JArray jarray)
        {
            JObject jObject = new JObject();
            jObject.Add(mbiCode, jarray);
            return jObject;
        }     
    }
}
