public void DownloadVideo(int id) { if (videoService == null) { videoService = new VideoService(); } if (!videoService.GetListVideo().Exists(x => x == id)) { videoService.DownloadVideo(id); } else { Console.WriteLine("Видео уже загружено"); } }
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(); }