private static Profile upgradeXmlProfile(XmlNode a_profil, Profile a_profileObj) { XmlNodeList t_YTchannelsNodes = a_profil.SelectNodes("./YoutubeSetting/Channel"); foreach (XmlNode t_channelNode in t_YTchannelsNodes) { try { YoutubeEntry t_YTEntry = new YoutubeEntry(); t_YTEntry.Name = (t_channelNode.SelectSingleNode("./Name")).InnerText; t_YTEntry.Link = (t_channelNode.SelectSingleNode("./Link")).InnerText; t_YTEntry.Image = t_channelNode.SelectSingleNode("./Image").InnerText; t_YTEntry.ProfileID = a_profileObj.Id; a_profileObj.YoutubeChannels.Add(t_YTEntry); } catch (Exception e) { } } XmlNodeList t_subredditsNodes = a_profil.SelectNodes("./RedditSetting/SubReddit"); foreach (XmlNode t_SubRedditNode in t_subredditsNodes) { try { RedditEntry t_RedditEntry = new RedditEntry(); t_RedditEntry.Name = (t_SubRedditNode.SelectSingleNode("./Name")).InnerText; t_RedditEntry.Link = (t_SubRedditNode.SelectSingleNode("./Link")).InnerText; t_RedditEntry.ProfileID = a_profileObj.Id; a_profileObj.SubReddits.Add(t_RedditEntry); } catch (Exception e) { } } XmlNodeList t_TwitchChannelNodes = a_profil.SelectNodes("./TwitchSetting/Channel"); foreach (XmlNode t_Node in t_TwitchChannelNodes) { try { TwitchEntry t_TwitchEntry = new TwitchEntry(); t_TwitchEntry.Link = t_Node.SelectSingleNode("./Link").InnerText; t_TwitchEntry.Image = t_Node.SelectSingleNode("./Image").InnerText; t_TwitchEntry.ProfileID = a_profileObj.Id; a_profileObj.TwitchLives.Add(t_TwitchEntry); } catch (Exception e) { } } return(a_profileObj); }
public async static Task <IEnumerable <RedditEntry> > ParseTopEntriesResponse(string jsonResponse) { TopRedditEntriesResponse redditApiResponse = null; ObservableCollection <RedditEntry> result = null; try { redditApiResponse = JsonConvert.DeserializeObject <TopRedditEntriesResponse>(jsonResponse); } catch (Exception ex) { } if (redditApiResponse?.data?.children != null) { result = new ObservableCollection <RedditEntry>(); foreach (var child in redditApiResponse.data.children) { Uri thumbnailUri = null; Uri image = null; bool hasImage = false; Uri.TryCreate(child.data.thumbnail, UriKind.Absolute, out thumbnailUri); if (hasImage = child.data.domain.Contains("imgur")) { Uri.TryCreate(child.data.url, UriKind.Absolute, out image); } var newEntry = new RedditEntry() { Author = child.data.author, CommentsNumber = child.data.num_comments, Thumbnail = thumbnailUri, Createdutc = child.data.created_utc.UnixTimeStampToDateTime(), Title = child.data.title, Image = image, Name = child.data.name, HasImage = hasImage }; result.Add(newEntry); } } return(result); }
public static void saveProfile(List <YoutubeChannel> a_yts, List <TwitchLive> a_twitchs, List <SubReddit> a_reddits, string a_ProfileName, Profile a_ProfileActu) { Profile t_profile = new Profile(); t_profile.Name = a_ProfileName; foreach (YoutubeChannel t_yts in a_yts) { try { if (t_yts.ChannelLink == "https://www.youtube.com/feeds/videos.xml?user=NAME") { continue; } YoutubeEntry t_YTEntry = new YoutubeEntry(); t_YTEntry.Id = t_yts.id; t_YTEntry.Name = t_yts.ChannelName; t_YTEntry.Link = t_yts.ChannelLink; t_YTEntry.Image = t_yts.ChannelImageLink; t_YTEntry.ProfileID = a_ProfileActu.Id; t_profile.YoutubeChannels.Add(t_YTEntry); } catch (Exception e) { } } foreach (SubReddit t_reddits in a_reddits) { try { if (t_reddits.SubRedditLink == "https://www.reddit.com/r/NAME/.rss") { continue; } RedditEntry t_RedditEntry = new RedditEntry(); t_RedditEntry.Id = t_reddits.id; t_RedditEntry.Name = t_reddits.SubRedditName; t_RedditEntry.Link = t_reddits.SubRedditLink; t_RedditEntry.ProfileID = a_ProfileActu.Id; t_profile.SubReddits.Add(t_RedditEntry); } catch (Exception e) { } } foreach (TwitchLive t_twitchs in a_twitchs) { try { if (t_twitchs.Link == null) { continue; } TwitchEntry t_TwitchEntry = new TwitchEntry(); t_TwitchEntry.Id = t_twitchs.id; t_TwitchEntry.Link = t_twitchs.Link; t_TwitchEntry.Image = t_twitchs.Thumbnail.UriSource.ToString(); t_TwitchEntry.ProfileID = a_ProfileActu.Id; t_profile.TwitchLives.Add(t_TwitchEntry); } catch (Exception e) { } } saveProfile(t_profile, a_ProfileActu); }