public static bool TryParse(string json, out Configuration error) { try { error = ParseCore(DynamicJsonHelper.ToDynamicJson(json)); } catch (Exception ex) { ex.Write(); error = null; } return error != null; }
internal static Configuration ParseCore(dynamic djson) { var result = new Configuration { CharactersReservedPerMedia = (int)Convert.ToDouble(djson.characters_reserved_per_media), MaxMediaPerUpload = (int)Convert.ToDouble(djson.max_media_per_upload), NonUsernamePaths = ((object[])djson.non_username_paths).Select(_ => _.ToString()).ToList(), PhotoSizeLimit = (int)Convert.ToDouble(djson.photo_size_limit), ShortUrlLengthHttps = (int)Convert.ToDouble(djson.short_url_length_https), ShortUrlLength = (int)Convert.ToDouble(djson.short_url_length), }; return result; }
private async void GetConfiguration(TwitterAccount account) { if (this.Configuration == Configuration.Default) { try { this.Configuration = await account.CurrentToken.GetConfiguration(); } catch (Exception ex) { ex.Report("設定情報を取得できませんでした。", () => this.GetConfiguration(account)); } } }