예제 #1
0
        public async Task <AsyncResult <IList <ISchedule> > > GetSchedulesAsync()
        {
            // TODO: lookup by ID cannot guess which server might be adressed, so we force the first one.
            int serverIndex = 0;

            if (!CheckConnection(serverIndex))
            {
                return(new AsyncResult <IList <ISchedule> >(false, null));
            }

            try
            {
                ITVAccessService tvAccessService = TvServer(serverIndex);
                var webSchedules = tvAccessService.GetSchedules();
                var schedules    = webSchedules.Select(s => new Schedule(s, serverIndex)).Cast <ISchedule>().ToList();
                return(new AsyncResult <IList <ISchedule> >(true, schedules));
            }
            catch
            {
                return(new AsyncResult <IList <ISchedule> >(false, null));
            }
        }
        public bool GetSchedules(out IList <ISchedule> schedules)
        {
            schedules = new List <ISchedule>();

            // TODO: lookup by ID cannot guess which server might be adressed, so we force the first one.
            int serverIndex = 0;

            if (!CheckConnection(serverIndex))
            {
                return(false);
            }

            try
            {
                ITVAccessService tvAccessService = TvServer(serverIndex);
                var webSchedules = tvAccessService.GetSchedules();
                schedules = webSchedules.Select(s => new Schedule(s, serverIndex)).Cast <ISchedule>().ToList();
            }
            catch
            {
                return(false);
            }
            return(true);
        }