コード例 #1
0
ファイル: Utils.cs プロジェクト: wuchangqi/ifixit-microsoft
        public static async Task DoLogOut(Interfaces.IStorage storageService, Interfaces.IUxService uxService, ServicesEngine.ServiceBroker broker)
        {
            await broker.DoLogout(AppBase.Current.User);

            AppBase.Current.User = null;
            await storageService.Delete(Constants.AUTHORIZATION);
        }
コード例 #2
0
ファイル: Utils.cs プロジェクト: wuchangqi/ifixit-microsoft
        public static async Task <ObservableCollection <Models.UI.RssItem> > LoadRss(Interfaces.IUxService uxService, Interfaces.ISettings settingsService)
        {
            if (settingsService.IsConnectedToInternet())
            {
                var news    = new ObservableCollection <Models.UI.RssItem>();
                var nBroker = new NewsBroker();

                var xml = await nBroker.GetNews();

                var morenodes = (from n in xml.Descendants("rss") select n).Descendants("item").Select(x => new
                                                                                                       Models.UI.RssItem
                {
                    Title = (string)x.Element("title")
                    ,
                    Summary = (string)x.Element("description")

                    ,
                    ImageUrl = Regex.Match(((string)(x.Element("htmlcontent"))), "<img.+?src=[\"'](.+?)[\"'].+?>", RegexOptions.IgnoreCase).Groups[1].Value

                    ,
                    Url = (string)x.Element("guid")
                    ,
                    PubDate = (DateTime)x.Element("pubDate")
                    ,
                    Author = string.Format(International.Translation.RssDateAndAuthor, (string)x.Element("creator"))
                }).ToList();


                news.Clear();
                foreach (var item in morenodes)
                {
                    item.DateString = item.PubDate.ToString("MMM dd, yyyy");
                    news.Add(item);
                }
                return(news);
            }
            else
            {
                await uxService.ShowAlert(International.Translation.NoConnection);

                return(null);
            }
        }