void Awake() { // Add Data and Actions. string path = Application.dataPath + "/" + Settings.LevelDataPath; mLevelData = JsonExtend.Load <LevelData>(path); }
/// <summary> /// 系统授权接口 /// </summary> //private IAuthenticationManager AuthenticationManager //{ // get // { // return HttpContext.GetOwinContext().Authentication; // } //} //private void Authorization() //{ // string username=Request.QueryString["username"]; // if (string.IsNullOrEmpty(username)) // return; // var _identity = CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); // AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); // AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = vm.IsRember, }, _identity); // } #region 发生异常、错误信息 protected override void OnException(ExceptionContext filterContext) { RpsData rqd = new RpsData(); rqd.IsSucceed = false; rqd.ErrorCode = 200; if (filterContext.Exception.InnerException != null && filterContext.Exception is CustomException) { CustomException ex = filterContext.Exception.InnerException as CustomException; rqd = RpsData.Fail(ex.Code, ex.Message); } else { rqd = RpsData.Fail(filterContext.Exception.Message); //Log.Write(filterContext.Exception); LogHelper.Write(filterContext.Exception); } rqd.Error = filterContext.Exception.Message; filterContext.HttpContext.Response.Clear(); filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.StatusCode = 200; filterContext.HttpContext.Response.Write(JsonExtend.ToJson(rqd)); filterContext.HttpContext.Response.Flush(); filterContext.HttpContext.Response.End(); }
public override void ExecuteResult(ControllerContext context) { if (context == null) { throw new ArgumentException("context"); } HttpResponseBase response = context.HttpContext.Response; if (!String.IsNullOrEmpty(ContentType)) { response.ContentType = ContentType; } else { response.ContentType = "application/json"; } if (ContentEncoding != null) { response.ContentEncoding = ContentEncoding; } if (Data != null) { //JavaScriptSerializer serializer = new JavaScriptSerializer(); //response.Write(serializer.Serialize(Data)); RpsData rqsdata = new RpsData(); string jsonstr = ""; if (Data.GetType().Name == "DataTable") { rqsdata = RpsData.Succee((Data as DataTable).ToJArray()); jsonstr = JsonExtend.ToJson(rqsdata); } //jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject((Data as DataTable).ToJArray()); else if (Data.GetType().Name == "DataRow") { rqsdata = RpsData.Succee((Data as DataRow).ToJObject()); jsonstr = JsonExtend.ToJson(rqsdata); } //jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject((Data as DataRow).ToJObject()); else { rqsdata = RpsData.Succee(Data); jsonstr = JsonExtend.ToKonwnTypeJson(rqsdata); } //jsonstr = Newtonsoft.Json.JsonConvert.SerializeObject(Data); response.Write(jsonstr); } else { response.Write(JsonExtend.ToKonwnTypeJson(RpsData.Succee(null))); } }
public void ExtendTest() { var x = Experiments.Json.Jsonify(new { z = 1, a = new { b = new object[] { 1, 2, 3, new{ _id = 1, a = 2 }, new{ _id = 2, b = 4 } } } }); var y = Experiments.Json.Jsonify(new { b = 1, z = "_remove_", a = new { c = 2, b = new object[] { 4, 5, new{ _remove = 1 }, new{ _id = 1, b = 3 }, new{ _remove = new{ _id = 2 } } } } }); var merged = Experiments.Json.Stringify(JsonExtend.Extend(x, y)).Simplify(SimplifyOptions.SingleQuotes); Console.WriteLine(merged); Assert.AreEqual(@"{'a':{'b':[2,3,4,5,{'_id':1,'a':2,'b':3}],'c':2},'b':1}", merged); }
public virtual void Merge(IItem src) { if (string.IsNullOrWhiteSpace(this.Id)) { Id = src.Id; } if (Version < src.Version) { Version = src.Version; } CheckRoled(this, src); if (null != src.Custom && 0 != src.Custom.Count) { Custom = Custom ?? new Dictionary <string, object>(); JsonExtend.Extend(Custom, src.Custom); } }
/// <summary> /// 删除自定义菜单 /// </summary> /// <param name="accessToken"></param> /// <returns></returns> public Hashtable MenuDelete(string accessToken) { Hashtable retHash = new Hashtable(); string wxurl = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=" + accessToken; string result = Web.WebHelper.GetPage(wxurl, "", "GET"); Hashtable resHash = JsonExtend <Hashtable> .ToObject(result); if (resHash["errcode"].GetInt() == 0) { retHash.Add("state", "success"); } else { retHash.Add("state", "error"); retHash.Add("errcode", resHash["errcode"]); retHash.Add("errmsg", resHash["errmsg"]); } return(retHash); }
/// <summary> /// 自定义菜单查询 /// </summary> /// <param name="accessToken"></param> /// <returns></returns> public List <MenuButton> GetMenu(string accessToken) { string wxurl = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=" + accessToken; string result = Web.WebHelper.GetPage(wxurl, "", "GET"); object[] firstBtnArr = (JsonExtend <Hashtable> .ToObject(result)["menu"] as Dictionary <string, object>)["button"] as object[]; List <MenuButton> list = new List <MenuButton>(); foreach (Dictionary <string, object> firstItem in firstBtnArr) { MenuButton firstBtn = new MenuButton(); firstBtn.Name = firstItem["name"].ToString(); if (firstItem.ContainsKey("sub_button")) { object[] secondBtnArr = firstItem["sub_button"] as object[]; List <MenuButton> secondBtnList = new List <MenuButton>(); foreach (Dictionary <string, object> secondItem in secondBtnArr) { MenuButton secondBtn = new MenuButton(); secondBtn.Name = secondItem["name"].ToString(); if (secondItem.ContainsKey("sub_button")) { object[] thirdBtnArr = secondItem["sub_button"] as object[]; List <MenuButton> thirdBtnList = new List <MenuButton>(); foreach (Dictionary <string, object> thirdItem in thirdBtnArr) { MenuButton thirdBtn = new MenuButton(); thirdBtn.Name = thirdItem["name"].ToString(); thirdBtn.ButtonType = thirdItem["type"].ToString(); if (secondBtn.ButtonType == "view") { secondBtn.Url = thirdItem["url"].ToString(); } else { secondBtn.Key = thirdItem["key"].ToString(); } } secondBtn.SubButtonList = thirdBtnList; } else { secondBtn.ButtonType = secondItem["type"].ToString(); if (secondBtn.ButtonType == "view") { secondBtn.Url = secondItem["url"].ToString(); } else { secondBtn.Key = secondItem["key"].ToString(); } } secondBtnList.Add(secondBtn); } firstBtn.SubButtonList = secondBtnList; } else { firstBtn.ButtonType = firstItem["type"].ToString(); if (firstBtn.ButtonType == "view") { firstBtn.Url = firstItem["url"].ToString(); } else { firstBtn.Key = firstItem["key"].ToString(); } } list.Add(firstBtn); } return(list); }
public void Apply(IUser targetUser) { if (ChangedActive(targetUser)) { targetUser.Active = Active.Value; } if (ChangedLogable(targetUser)) { targetUser.Logable = Logable.Value; } if (ChangedCustom(targetUser)) { var target = targetUser.Custom ?? new Dictionary <string, object>(); JsonExtend.Extend(target, Custom); } if (ChangedEmail(targetUser)) { targetUser.Email = Email; } if (ChangedPublicKey(targetUser)) { targetUser.PublicKey = PublicKey; } if (ChangedExpire(targetUser)) { targetUser.Expire = Expire.Value.ToUniversalTime(); } if (ChangedGroups(targetUser)) { foreach (var item in AddGroups) { targetUser.Groups.Remove(item); targetUser.Groups.Add(item); } foreach (var item in RemoveGroups) { targetUser.Groups.Remove(item); } } if (ChangedRoles(targetUser)) { foreach (var item in AddRoles) { targetUser.Roles.Remove(item); targetUser.Roles.Add(item); } foreach (var item in RemoveRoles) { targetUser.Roles.Remove(item); } } if (ChangedIsAdmin(targetUser)) { targetUser.IsAdmin = IsAdmin.Value; } if (ChangedIsGroup(targetUser)) { targetUser.IsGroup = IsGroup.Value; } if (ChangedDomain(targetUser)) { targetUser.Domain = Domain; } if (ChangedPassword(targetUser)) { var pwd = new PasswordManager(); pwd.SetPassword(targetUser, Password, true); } if (ChangedName(targetUser)) { targetUser.Name = Name; ; } }