Duplicate File Locator 1.0
Loading...
Searching...
No Matches
DuplicatedFile.cs
Go to the documentation of this file.
2using Newtonsoft.Json;
3using System;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text;
7using System.Threading.Tasks;
8
10{
12 {
13 #region Private Attributes
14
15 private string _hash;
16 private string _originalPath;
17 private List<string> _duplicatePaths;
18
19 #endregion
20
21 #region Public Attributes
22
23 [JsonProperty("Hash")]
24 public string Hash
25 {
26 get { return _hash; }
27 private set { _hash = value; }
28 }
29
30 [JsonProperty("OriginalPath")]
31 public string OriginalPath
32 {
33 get { return _originalPath; }
34 set { _originalPath = value; }
35 }
36
37 [JsonProperty("DuplicatePaths")]
38 public List<string> DuplicatePaths
39 {
40 get { return _duplicatePaths; }
41 private set { _duplicatePaths = value; }
42 }
43
44 #endregion
45
46 #region Constructors
47
49 {
50 Hash = string.Empty;
51 OriginalPath = string.Empty;
52 DuplicatePaths = new List<string>();
53 }
54
55 public DuplicatedFile(string hash) : this()
56 {
57 Hash = hash;
58 }
59
60 public DuplicatedFile(string hash, string duplicatePath) : this(hash)
61 {
62 DuplicatePaths.Add(duplicatePath);
63 }
64
65 [JsonConstructor]
66 public DuplicatedFile(string hash, string originalPath, List<string> duplicatePaths) : this(hash)
67 {
68 OriginalPath = originalPath;
69 if(duplicatePaths != null)
70 {
71 foreach (var path in duplicatePaths)
72 {
73 DuplicatePaths.Add(path);
74 }
75 }
76 }
77
78 #endregion
79
80 #region Public Methods
81
82 public void AddDuplicatePath(string path)
83 {
84 if (!DuplicatePaths.Contains(path))
85 DuplicatePaths.Add(path);
86 }
87
88 public override string ToString()
89 {
90 string output = "Hash : " + Hash + "\nOriginal : " + OriginalPath + "\nDuplicates : \n";
91 foreach (string image in DuplicatePaths)
92 {
93 output += "\t\t" + image + "\n";
94 }
95 return output;
96 }
97
98 #endregion
99 }
100}
void AddDuplicatePath(string path)
Method adds path to DuplicatePaths.
List< string > DuplicatePaths
List of paths to duplicate files.
DuplicatedFile(string hash, string originalPath, List< string > duplicatePaths)
DuplicatedFile(string hash, string duplicatePath)