Exemplo n.º 1
0
        public void Save(string filePath)
        {
            var myJsonHelper = MyJsonHelper.Resolve();
            var json         = myJsonHelper.SerializeObject(this, true);

            File.WriteAllText(filePath, json, Encoding.UTF8);
        }
Exemplo n.º 2
0
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!CheckPermissions())
            {
                var exception = new NoAccessToPageException();

                if (!filterContext.HttpContext.Request.IsAjaxRequest())
                {
                    var controllerName = (string)filterContext.RouteData.Values["controller"];
                    var actionName     = (string)filterContext.RouteData.Values["action"];
                    var model          = new HandleErrorInfo(exception, controllerName, actionName);

                    filterContext.Result = new ViewResult
                    {
                        ViewName = "~/Views/Errors/AccessDeniedError.cshtml",
                        ViewData = new ViewDataDictionary <HandleErrorInfo>(model),
                        TempData = filterContext.Controller.TempData
                    };
                }
                else
                {
                    var response = MyJsonHelper.GetErrorResponse(exception);
                    filterContext.Result = new JsonResult()
                    {
                        Data = response,
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                }
            }
        }
Exemplo n.º 3
0
        private EmDataModel GetEmDataModelByUrl(string url)
        {
            var         html     = HttpHelper.DownloadCommodity(url, "UTF8");
            var         datajson = ReBuildData(html);
            EmDataModel data     = MyJsonHelper.Json2ObjectByString <EmDataModel>(datajson);

            return(data);
        }
Exemplo n.º 4
0
        public void Load(string filePath)
        {
            var myJsonHelper   = MyJsonHelper.Resolve();
            var json           = File.ReadAllText(filePath);
            var repositoryInfo = myJsonHelper.DeserializeObject <ReleaseManageInfo>(json, null);

            if (repositoryInfo != null)
            {
                this.Products          = repositoryInfo.Products;
                this.ConfigItems       = repositoryInfo.ConfigItems;
                this.ReleaseManifests  = repositoryInfo.ReleaseManifests;
                this.ConfigItemCommits = repositoryInfo.ConfigItemCommits;
            }
        }
    private static void ReadSmartHelmetPreferences()
    {
        string jsonString;

        if (File.Exists(THOR_PREFERENCES))
        {
            jsonString = File.ReadAllText(THOR_PREFERENCES);
            string thorPreferences = MyJsonHelper.GetJsonObject(jsonString, "SmartHelmetPreferences");
            thorPref = JsonUtility.FromJson <SmartHelmetPreferences>(thorPreferences);
        }
        else
        {
            UnityEngine.Debug.LogError("Invalid path or filename");
        }
    }
        static SichuanCuisineModel()
        {
            Type type = typeof(SichuanCuisineModel);

            SichuanCuisines = MyJsonHelper.Json2Object <Dictionary <int, BasicModel.FoodModel> >(type.Name);
        }
Exemplo n.º 7
0
        static GuangdongCuisineModel()
        {
            Type type = typeof(GuangdongCuisineModel);

            GuangDongCuisines = MyJsonHelper.Json2Object <Dictionary <int, BasicModel.FoodModel> >(type.Name);
        }
Exemplo n.º 8
0
 public object Get()
 {
     return(MyJsonHelper.GetFileJson("~/js/areas.json"));
 }
Exemplo n.º 9
0
        public JsonResult GetErrorJsonResponse(Exception exception)
        {
            var response = MyJsonHelper.GetErrorResponse(exception);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 10
0
        public JsonResult GetSuccessJsonResponse(object data = null)
        {
            var response = MyJsonHelper.GetSuccessResponse(data);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }