public void GetUserConfig() { string jsonString = Links.GetUserConfig.ExecuteRequest(Account); JsonConfig.RootObject config = JsonConvert.DeserializeObject <JsonConfig.RootObject>(jsonString); List <User.Experiment> experiments = new List <User.Experiment>(config.experiments.Count); experiments.AddRange(config.experiments.Select(experiment => new User.Experiment(experiment.name, experiment.@group, experiment.features))); List <Channel> channels = new List <Channel>(config.followed_hashtags.Count); channels.AddRange(config.followed_channels.Select(channelname => new Channel(channelname, true))); Account.ChannelsFollowLimit = config.channels_follow_limit; Account.Experiments = experiments; Account.HomeName = config.home_name; Account.HomeSet = config.home_set; Account.FollowedHashtags = config.followed_hashtags; Account.Location = config.location; Account.Moderator = config.moderator; Account.TripleFeedEnabled = config.triple_feed_enabled; Account.UserType = config.user_type; Account.Verified = config.verified; Account.FollowedChannels = channels; }
/// <summary> /// Gets the UserConfig /// </summary> public User.UserConfig GetUserConfig() { string plainJson; using (var client = new MyWebClient()) { client.Encoding = Encoding.UTF8; plainJson = client.DownloadString(Constants.LinkConfig.ToLink()); } JsonConfig.RootObject config = JsonConvert.DeserializeObject <JsonConfig.RootObject>(plainJson); List <User.Experiment> experiments = new List <User.Experiment>(config.experiments.Count); foreach (JsonConfig.Experiment experiment in config.experiments) { experiments.Add(new User.Experiment { Features = experiment.features, Group = experiment.group, Name = experiment.name }); } List <Channel> channels = new List <Channel>(config.followed_hashtags.Count); foreach (string channelname in config.followed_channels) { channels.Add(new Channel(channelname)); } User.UserConfig uconfig = new User.UserConfig { ChannelsFollowLimit = config.channels_follow_limit, Experiments = experiments, HomeName = config.home_name, HomeSet = config.home_set, FollowedHashtags = config.followed_hashtags, Location = config.location, Moderator = config.moderator, TripleFeedEnabled = config.triple_feed_enabled, UserType = config.user_type, Verified = config.verified, FollowedChannels = channels }; _user.Config = uconfig; return(uconfig); }
/// <summary> /// Determines whether the specified token is from a moderator. /// </summary> /// <param name="token">The token.</param> /// <returns><c>true</c> if the specified token is moderator; otherwise, <c>false</c>.</returns> public bool IsModerator(string token) { string plainJson; using (var client = new MyWebClient()) { client.Encoding = Encoding.UTF8; plainJson = client.DownloadString(Constants.LinkConfig.ToLink()); } JsonConfig.RootObject config = JsonConvert.DeserializeObject <JsonConfig.RootObject>(plainJson); if (config.moderator) { return(true); } return(false); }