public void Save(string filePath) { var myJsonHelper = MyJsonHelper.Resolve(); var json = myJsonHelper.SerializeObject(this, true); File.WriteAllText(filePath, json, Encoding.UTF8); }
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 }; } } }
private EmDataModel GetEmDataModelByUrl(string url) { var html = HttpHelper.DownloadCommodity(url, "UTF8"); var datajson = ReBuildData(html); EmDataModel data = MyJsonHelper.Json2ObjectByString <EmDataModel>(datajson); return(data); }
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); }
static GuangdongCuisineModel() { Type type = typeof(GuangdongCuisineModel); GuangDongCuisines = MyJsonHelper.Json2Object <Dictionary <int, BasicModel.FoodModel> >(type.Name); }
public object Get() { return(MyJsonHelper.GetFileJson("~/js/areas.json")); }
public JsonResult GetErrorJsonResponse(Exception exception) { var response = MyJsonHelper.GetErrorResponse(exception); return(Json(response, JsonRequestBehavior.AllowGet)); }
public JsonResult GetSuccessJsonResponse(object data = null) { var response = MyJsonHelper.GetSuccessResponse(data); return(Json(response, JsonRequestBehavior.AllowGet)); }