Exemple #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Прокси Сервиса");
            IVideoService service = new ProxyVideoService();

            Console.WriteLine(service.GetVideoInfo(5));
            service.DownloadVideo(45);
            service.DownloadVideo(2);
            service.DownloadVideo(45);
            service.DownloadVideo(8);
            Console.WriteLine(service.GetVideoInfo(8));
            service.GetListVideo().ForEach(item => Console.WriteLine("item: " + item));

            Console.WriteLine("Сервис");
            service = new VideoService();
            Console.WriteLine(service.GetVideoInfo(5));

            Console.Read();
        }
Exemple #2
0
        public int GetVideoInfo(int id)
        {
            try
            {
                if (videoService == null)
                {
                    throw new NullReferenceException("Сервис не инициализирован");
                }

                if (videoService.GetListVideo().Exists(x => x == id))
                {
                    return(videoService.GetVideoInfo(id));
                }
                else
                {
                    Console.WriteLine("Нет данного видео в списке загруженных");
                    return(-1);
                }
            } catch (NullReferenceException ex)
            {
                Console.WriteLine(ex.Message);
                return(-1);
            }
        }