forked from BornToBeRoot/NETworkManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfileFileInfo.cs
More file actions
138 lines (119 loc) · 3.54 KB
/
Copy pathProfileFileInfo.cs
File metadata and controls
138 lines (119 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.Security;
using NETworkManager.Utilities;
namespace NETworkManager.Profiles;
public class ProfileFileInfo : PropertyChangedBase
{
/// <summary>
/// Private field for the <see cref="IsEncrypted" /> property.
/// </summary>
private bool _isEncrypted;
/// <summary>
/// Private field for the <see cref="IsPasswordValid" /> property.
/// </summary>
private bool _isPasswordValid;
/// <summary>
/// Private field for the <see cref="Name" /> property.
/// </summary>
private string _name;
/// <summary>
/// Private field for the <see cref="Path" /> property.
/// </summary>
private string _path;
/// <summary>
/// Profile file info contains all necessary information's about the profile file and location.
/// </summary>
/// <param name="name"><see cref="Name" /> of the profile file.</param>
/// <param name="path"><see cref="Path" /> of the profile file.</param>
/// <param name="isEncrypted"><see cref="IsEncrypted" /> indicates if the file is encrypted.</param>
public ProfileFileInfo(string name, string path, bool isEncrypted = false)
{
ID = Guid.NewGuid();
Name = name;
Path = path;
IsEncrypted = isEncrypted;
}
/// <summary>
/// Make object unique.
/// </summary>
private Guid ID { get; }
/// <summary>
/// Name of the profile. This is the filename without extension.
/// </summary>
public string Name
{
get => _name;
set
{
if (value == _name)
return;
_name = value;
OnPropertyChanged();
}
}
/// <summary>
/// Full path of the profile file.
/// </summary>
public string Path
{
get => _path;
set
{
if (value == _path)
return;
_path = value;
OnPropertyChanged();
}
}
/// <summary>
/// Indicates if the profile file is encrypted.
/// </summary>
public bool IsEncrypted
{
get => _isEncrypted;
set
{
if (value == _isEncrypted)
return;
_isEncrypted = value;
OnPropertyChanged();
}
}
/// <summary>
/// Password to encrypt and decrypt the profile file.
/// </summary>
public SecureString Password { get; set; }
/// <summary>
/// Indicates if the password is valid and can be used for encryption or decryption.
/// </summary>
public bool IsPasswordValid
{
get => _isPasswordValid;
set
{
if (value == _isPasswordValid)
return;
_isPasswordValid = value;
OnPropertyChanged();
}
}
/// <summary>
/// Overrides the default <see cref="Equals(object)" /> method.
/// </summary>
/// <param name="obj">Object from type <see cref="ProfileFileInfo" />.</param>
/// <returns>Returns true if the <see cref="ProfileFileInfo" /> is equal to another <see cref="ProfileFileInfo" />.</returns>
public override bool Equals(object obj)
{
if (obj is not ProfileFileInfo info)
return false;
return info.ID == ID;
}
/// <summary>
/// Overrides the default GetHashCode() method.
/// </summary>
/// <returns>Return the hashcode generated by the path of the <see cref="ProfileFileInfo" />.</returns>
public override int GetHashCode()
{
return ID.GetHashCode();
}
}