public void ShouldCorrectlyMarkEqualityOfImageModelAndObject(ImageModel first, object second, bool expected) { // Given // When var actual = first.Equals(second); // Then Assert.AreEqual(expected, actual); }
private async Task SaveAsync() { if (original.Equals(Model)) { return; } await Api.UpdateImageAsync(EntryId, Model); UpdateOriginal(); }
public static void GetImagesViews(string[] ext, string root, BackgroundWorker bgWorker, DoWorkEventArgs e) { List <string> directories = new List <string>(GetDirectoriesList(root)); //коллекция для списка поддиректорий типа string List <string> files = new List <string>(); //коллекция для списка файлов типа string List <ImageModel> images = new List <ImageModel>(); //коллекция для списка файлов типа ImageModel try { //поиск картинок в root foreach (string ex in ext) { foreach (string findedimage in Directory.EnumerateFiles(root, ex, SearchOption.TopDirectoryOnly)) { FileInfo fileinfo = null; try { fileinfo = new FileInfo(findedimage); ImageModel img = new ImageModel(fileinfo.Name, fileinfo.DirectoryName, fileinfo.FullName, fileinfo.LastWriteTime, fileinfo.Length); if (images.Count == 0) { images.Add(img); bgWorker.ReportProgress(-1, img); if (bgWorker.CancellationPending) { e.Cancel = true; return; } continue; } else { bool flag = false; for (int j = 0; j < images.Count; j++) { if (img.Equals(images[j])) { images[j].Copies.Add(img); bgWorker.ReportProgress(j, images[j]); if (bgWorker.CancellationPending) { e.Cancel = true; return; } flag = true; break; } } if (flag == false) { images.Add(img); bgWorker.ReportProgress(-1, img); if (bgWorker.CancellationPending) { e.Cancel = true; return; } } } } catch (Exception ex1) { MessageBox.Show(ex1.Message); } } } //поиск картинок в поддиректориях root foreach (string dir in directories) { if (File.GetAttributes(dir).HasFlag(FileAttributes.Hidden)) { continue; } else { foreach (string pattern in ext) { List <string> list = new List <string>(GetFilesList(dir, pattern)); if (list.Count > 0) { try { foreach (string f in list) { FileInfo file = new FileInfo(f); ImageModel img = new ImageModel(file.Name, file.DirectoryName, file.FullName, file.LastWriteTimeUtc, file.Length); if (images.Count == 0) { images.Add(img); bgWorker.ReportProgress(-1, img); if (bgWorker.CancellationPending) { e.Cancel = true; return; } continue; } else { bool flag = false; for (int j = 0; j < images.Count; j++) { if (img.Equals(images[j])) { images[j].Copies.Add(img); bgWorker.ReportProgress(j, images[j]); flag = true; if (bgWorker.CancellationPending) { e.Cancel = true; return; } break; } } if (!flag) { images.Add(img); bgWorker.ReportProgress(-1, img); if (bgWorker.CancellationPending) { e.Cancel = true; return; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { continue; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } images.Clear(); directories.Clear(); files.Clear(); }