public ExSerialParser(ISubscribeManager subscribeManager, IListFileParser listFileParser) { this.listFileParser = listFileParser; this.subscribeManager = subscribeManager; patern = @"href='(?<ReferensToFiles>.*?)'><img src='(?<TitleImage>.*?)'.*?alt='(?<Name>.*?)'>.*?</span></small><p>(?<Info>.*?)<p>(<a href|<small>).*?(Ф|')(?<folder>.*?)размер: (?<Size>.*?)$"; }
public SubscribeManager(IListFileParser listFileParser, DownLoadManagerModel downLoadManagerModel) { DownLoadManagerModel = downLoadManagerModel; SerialModelsCollection = new ObservableCollection<SerialModel>(); BindingOperations.EnableCollectionSynchronization(SerialModelsCollection, lockobject); cts = new CancellationTokenSource(); Task.Factory.StartNew(async () =>await AddNewSeriesToDownloadQueue(cts.Token), cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
public Controller(ISerialsSearch serialsSearch, DownLoadManagerModel downLoadManagerModel, ISubscribeManager subscribeManager, IListFileParser listFileParser) { SerialsSearch = serialsSearch; DownLoadManagerModel = downLoadManagerModel; SubscribeManager = subscribeManager; saver = new Saver((SubscribeManager)subscribeManager); SubscribeManager.SerialModelsCollection = saver.Load(listFileParser); this.listFileParser = listFileParser; Application.Current.MainWindow.Closed += MainWindow_Closed; }
public ObservableCollection<SerialModel> Load(IListFileParser listFileParser) { var temp = new ObservableCollection<SerialModel>(); if (File.Exists(cashFileName)) { try { using (var fs = new FileStream(cashFileName, FileMode.Open, FileAccess.Read)) { using (var bw = new BinaryReader(fs)) { while (bw.BaseStream.Position != bw.BaseStream.Length) { var filename = bw.ReadString(); var info = bw.ReadString(); var referenseTofile = bw.ReadString(); var size = bw.ReadString(); var title = createImage(bw.ReadBytes(bw.ReadInt32())); var countofseries = bw.ReadInt32(); List<FileModel> listofModels = new List<FileModel>(); for (int i = 0; i < countofseries; i++) { var sfName = bw.ReadString(); var sfPathToDownload = bw.ReadString(); var sfSerialName = bw.ReadString(); var sfSerialSize = bw.ReadString(); var sfDownloadStatus = (DownloadStatus)bw.ReadInt32(); listofModels.Add(new FileModel(sfName, sfPathToDownload, sfSerialSize, sfSerialName, subscribeManager.DownLoadManagerModel, sfDownloadStatus)); } var sm = new SerialModel(new SeriaInfo(referenseTofile, filename, size, title, info, true), subscribeManager, listFileParser); sm.SetSerialListFromCach(listofModels); temp.Add(sm); } } } } catch (Exception) { //TODO } } return temp; }