private List<NetiaApp> enumrateRootObjectApps(RootObject rootObject) { var propArray = rootObject.apps.GetType().GetProperties(); List<NetiaApp> appList = new List<NetiaApp>(); foreach (var propertyInfo in propArray) { if (propertyInfo.Name == rootObject.apps.abcvod.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.abcvod.Id, Name = rootObject.apps.abcvod.Name, Description = rootObject.apps.abcvod.Description, GridImg_url = rootObject.apps.abcvod.GridImg_url, ListImg_url = rootObject.apps.abcvod.ListImg_url, isActive = rootObject.apps.abcvod.isActive }); } if (propertyInfo.Name == rootObject.apps.goon.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.goon.Id, Name = rootObject.apps.goon.Name, Description = rootObject.apps.goon.Description, GridImg_url = rootObject.apps.goon.GridImg_url, ListImg_url = rootObject.apps.goon.ListImg_url, isActive = rootObject.apps.goon.isActive }); } if (propertyInfo.Name == rootObject.apps.erowizja.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.erowizja.Id, Name = rootObject.apps.erowizja.Name, Description = rootObject.apps.erowizja.Description, GridImg_url = rootObject.apps.erowizja.GridImg_url, ListImg_url = rootObject.apps.erowizja.ListImg_url, isActive = rootObject.apps.erowizja.isActive }); } if (propertyInfo.Name == rootObject.apps.filmbox.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.filmbox.Id, Name = rootObject.apps.filmbox.Name, Description = rootObject.apps.filmbox.Description, GridImg_url = rootObject.apps.filmbox.GridImg_url, ListImg_url = rootObject.apps.filmbox.ListImg_url, isActive = rootObject.apps.filmbox.isActive }); } if (propertyInfo.Name == rootObject.apps.hbogo.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.hbogo.Id, Name = rootObject.apps.hbogo.Name, Description = rootObject.apps.hbogo.Description, GridImg_url = rootObject.apps.hbogo.GridImg_url, ListImg_url = rootObject.apps.hbogo.ListImg_url, isActive = rootObject.apps.hbogo.isActive }); } if (propertyInfo.Name == rootObject.apps.ipla.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.ipla.Id, Name = rootObject.apps.ipla.Name, Description = rootObject.apps.ipla.Description, GridImg_url = rootObject.apps.ipla.GridImg_url, ListImg_url = rootObject.apps.ipla.ListImg_url, isActive = rootObject.apps.ipla.isActive }); } if (propertyInfo.Name == rootObject.apps.kinoplex.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.kinoplex.Id, Name = rootObject.apps.kinoplex.Name, Description = rootObject.apps.kinoplex.Description, GridImg_url = rootObject.apps.kinoplex.GridImg_url, ListImg_url = rootObject.apps.kinoplex.ListImg_url, isActive = rootObject.apps.kinoplex.isActive }); } if (propertyInfo.Name == rootObject.apps.tvpsport.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.tvpsport.Id, Name = rootObject.apps.tvpsport.Name, Description = rootObject.apps.tvpsport.Description, GridImg_url = rootObject.apps.tvpsport.GridImg_url, ListImg_url = rootObject.apps.tvpsport.ListImg_url, isActive = rootObject.apps.tvpsport.isActive }); } if (propertyInfo.Name == rootObject.apps.ninateka.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.ninateka.Id, Name = rootObject.apps.ninateka.Name, Description = rootObject.apps.ninateka.Description, GridImg_url = rootObject.apps.ninateka.GridImg_url, ListImg_url = rootObject.apps.ninateka.ListImg_url, isActive = rootObject.apps.ninateka.isActive }); } if (propertyInfo.Name == rootObject.apps.netiacloud.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.netiacloud.Id, Name = rootObject.apps.netiacloud.Name, Description = rootObject.apps.netiacloud.Description, GridImg_url = rootObject.apps.netiacloud.GridImg_url, ListImg_url = rootObject.apps.netiacloud.ListImg_url, isActive = rootObject.apps.netiacloud.isActive }); } if (propertyInfo.Name == rootObject.apps.tubafm.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.tubafm.Id, Name = rootObject.apps.tubafm.Name, Description = rootObject.apps.tubafm.Description, GridImg_url = rootObject.apps.tubafm.GridImg_url, ListImg_url = rootObject.apps.tubafm.ListImg_url, isActive = rootObject.apps.tubafm.isActive }); } if (propertyInfo.Name == rootObject.apps.tvnmeteo.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.tvnmeteo.Id, Name = rootObject.apps.tvnmeteo.Name, Description = rootObject.apps.tvnmeteo.Description, GridImg_url = rootObject.apps.tvnmeteo.GridImg_url, ListImg_url = rootObject.apps.tvnmeteo.ListImg_url, isActive = rootObject.apps.tvnmeteo.isActive }); } if (propertyInfo.Name == rootObject.apps.tvnplayer.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.tvnplayer.Id, Name = rootObject.apps.tvnplayer.Name, Description = rootObject.apps.tvnplayer.Description, GridImg_url = rootObject.apps.tvnplayer.GridImg_url, ListImg_url = rootObject.apps.tvnplayer.ListImg_url, isActive = rootObject.apps.tvnplayer.isActive }); } if (propertyInfo.Name == rootObject.apps.pinkvision.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.pinkvision.Id, Name = rootObject.apps.pinkvision.Name, Description = rootObject.apps.pinkvision.Description, GridImg_url = rootObject.apps.pinkvision.GridImg_url, ListImg_url = rootObject.apps.pinkvision.ListImg_url, isActive = rootObject.apps.pinkvision.isActive }); } if (propertyInfo.Name == rootObject.apps.premiumplus.Id) { appList.Add(new NetiaApp() { Id = rootObject.apps.premiumplus.Id, Name = rootObject.apps.premiumplus.Name, Description = rootObject.apps.premiumplus.Description, GridImg_url = rootObject.apps.premiumplus.GridImg_url, ListImg_url = rootObject.apps.premiumplus.ListImg_url, isActive = rootObject.apps.premiumplus.isActive }); } } return appList; }
public async Task<List<NetiaApp>> GetAppsListAsync() { RootObject rootObject = new RootObject(); List<NetiaApp> appList = new List<NetiaApp>(); //http://epg.dms.netia.pl/xmltv/logo/black/netiaPadAppsSettings.json var address = "http://epg.dms.netia.pl/xmltv/logo/black/netiaPadAppsSettings.json"; var uri = new Uri(address, UriKind.Absolute); using (System.Net.Http.HttpClient client = new System.Net.Http.HttpClient()) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate"); client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "UTF-8"); try { System.Net.Http.HttpResponseMessage response = await client.GetAsync(uri); response.EnsureSuccessStatusCode(); var data = await response.Content.ReadAsStringAsync(); rootObject = JsonConvert.DeserializeObject<RootObject>(data); appList = enumrateRootObjectApps(rootObject); return appList; } catch (Exception) { return appList; ; //empty } } }