public static void SaveSetting(T setting, string settingPath = null) { if (string.IsNullOrEmpty(settingPath)) { settingPath = SettingsPath; } Storage.SaveText(settingPath, NewtonJsonSerializer.ToJSON(setting)); }
public string GetFormHelpInfo(string formName) { var helpInfoService = StaticServiceFactory.Create <IHelpInformationService>(); var formHelpInfo = helpInfoService.GetHelps(formName); NewtonJsonSerializer ser = new NewtonJsonSerializer(); return(ser.SerializeToString(formHelpInfo)); }
async Task LoginUser(Account account) { var request = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, account); var response = await request.GetResponseAsync(); if (response != null) { string userJson = await response.GetResponseTextAsync(); var user = NewtonJsonSerializer.ParseJSON <BaobaoUser>(userJson); if (!string.IsNullOrEmpty(user?.name)) { OnUserLogin?.Invoke(this, new UserLoginEventArgs(user, account)); } } }
protected HanziStrokeController() { HanziSvgTemplate = LoadTextFromResource("hanzi.svg"); using (var stream = LoadStreamFromResource("all.txt")) { if (stream != null) { using (var reader = new StreamReader(stream)) { string allZi = reader.ReadToEnd(); HanZi = NewtonJsonSerializer.ParseJSON <Dictionary <string, ChineseHanZi> >(allZi); } } } using (var stream = LoadStreamFromResource("dictionary.txt")) { if (stream != null) { using (var reader = new StreamReader(stream)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); var hanzi = NewtonJsonSerializer.ParseJSON <ChineseHanZi>(line); if (HanZi.ContainsKey(hanzi.character)) { HanZi[hanzi.character].character = hanzi.character; HanZi[hanzi.character].decomposition = hanzi.decomposition; HanZi[hanzi.character].definition = hanzi.definition; HanZi[hanzi.character].pinyin = hanzi.pinyin; HanZi[hanzi.character].radical = hanzi.radical; } } } } } }
public static T LoadSetting(string settingPath = null) { T setting = default(T); try { if (string.IsNullOrEmpty(settingPath)) { settingPath = SettingsPath; } var settingContent = Storage.LoadText(settingPath); setting = NewtonJsonSerializer.ParseJSON <T>(settingContent); } catch (Exception) { } if (setting == null) { setting = new T(); } return(setting); }
public void Save(string userEmail, SpellingList spelling) { var content = NewtonJsonSerializer.ToJSON(spelling); AWSHelper.Instance.UploadString(GetSpellingListRemotePath(spelling.Title), content).Forget(); }