/********************************************************************************
** auth： 陈辉
** date： 2017-01-13 16:28:50
** desc： 是否跨域
*********************************************************************************/

using System.Configuration;
using System.Web.Mvc;

namespace SouthSmart.GISService.Models
{

    /// <summary>
    /// 跨域设置
    /// </summary>
    public static class CrossDomainSetting
    {
        public static ActionResult NewJson ( this object obj )
        {
            string isCrossDomain = ConfigurationManager.AppSettings["IsCrossDomain"];
            if ( isCrossDomain == "true" )
            {
                return new JsonpResult () { Data = obj.ToJson () };
            }
            if ( isCrossDomain == "false" )
            {
                return new JsonResult () { Data = obj.ToJson () };
            }
            return null;
        }
        public static ActionResult String2Json ( this string jsonStr )
        {
            string isCrossDomain = ConfigurationManager.AppSettings["IsCrossDomain"];
            if ( isCrossDomain == "true" )
            {
                return new JsonpResult () { Data = jsonStr };
            }
            if ( isCrossDomain == "false" )
            {
                return new JsonResult () { Data = jsonStr };
            }
            return null;
        }
    }
}