-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPayloadSetProfile.cs
More file actions
160 lines (125 loc) · 4.25 KB
/
PayloadSetProfile.cs
File metadata and controls
160 lines (125 loc) · 4.25 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System.ComponentModel.DataAnnotations;
using S7Tools.Core.Interfaces.Services;
namespace S7Tools.Core.Models.Jobs;
/// <summary>
/// Defines the configuration for bootloader payload files.
/// Specifies the base path where stager and dumper payloads are located.
/// </summary>
/// <remarks>
/// PayloadSetProfile is a profile that defines the location of bootloader payloads (stager and dumper).
/// It implements IProfileBase to participate in the unified profile management system.
/// </remarks>
public class PayloadSetProfile : IProfileBase
{
#region IProfileBase Core Identity
/// <inheritdoc/>
public int Id { get; set; }
/// <inheritdoc/>
public string Name { get; set; } = string.Empty;
/// <inheritdoc/>
public string Description { get; set; } = string.Empty;
#endregion
#region IProfileBase Status and Behavior
/// <inheritdoc/>
public bool IsDefault { get; set; }
/// <inheritdoc/>
public bool IsReadOnly { get; set; }
#endregion
#region IProfileBase Command and Configuration
/// <inheritdoc/>
public string Options { get; set; } = string.Empty;
/// <inheritdoc/>
public string Flags { get; set; } = string.Empty;
#endregion
#region IProfileBase Audit and Versioning
/// <inheritdoc/>
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
/// <inheritdoc/>
public DateTime ModifiedAt { get; set; } = DateTime.UtcNow;
/// <inheritdoc/>
public string Version { get; set; } = "1.0";
#endregion
#region IProfileBase Extensibility
/// <inheritdoc/>
public Dictionary<string, string>? Metadata { get; set; }
#endregion
#region Payload-Specific Properties
/// <summary>
/// Gets or sets the base directory path containing payload files.
/// </summary>
/// <value>The base directory path where stager and dumper binaries are located.</value>
/// <remarks>
/// This path should contain:
/// - stager.bin: First-stage bootloader payload
/// - dumper.bin: Memory dumper payload
/// Path can be absolute or relative to the application directory.
/// </remarks>
[Display(Name = "Payload Base Path", Order = 1)]
public string BasePath { get; set; } = string.Empty;
#endregion
#region IProfileBase Business Methods
/// <inheritdoc/>
public bool CanModify()
{
return !IsReadOnly;
}
/// <inheritdoc/>
public bool CanDelete()
{
return !IsReadOnly && !IsDefault;
}
/// <inheritdoc/>
public void Touch()
{
ModifiedAt = DateTime.UtcNow;
}
/// <inheritdoc/>
public string GetSummary()
{
return $"Payloads at: {BasePath}";
}
#endregion
#region Factory Methods
/// <summary>
/// Creates a default payload set profile pointing to the standard payload directory.
/// </summary>
/// <returns>A new PayloadSetProfile with default settings.</returns>
public static PayloadSetProfile CreateDefault()
{
return new PayloadSetProfile
{
Id = 0,
Name = "Default Payloads",
Description = "Default payload set profile",
BasePath = "bootloader-payloads/payloads",
IsDefault = true,
IsReadOnly = false,
CreatedAt = DateTime.UtcNow,
ModifiedAt = DateTime.UtcNow,
Version = "1.0"
};
}
/// <summary>
/// Creates a user-defined payload set profile with specified name and path.
/// </summary>
/// <param name="name">The profile name.</param>
/// <param name="basePath">The base directory path.</param>
/// <param name="description">Optional description.</param>
/// <returns>A new PayloadSetProfile with user-specified settings.</returns>
public static PayloadSetProfile CreateUser(string name, string basePath, string? description = null)
{
return new PayloadSetProfile
{
Id = 0,
Name = name,
Description = description ?? $"User payload set: {name}",
BasePath = basePath,
IsDefault = false,
IsReadOnly = false,
CreatedAt = DateTime.UtcNow,
ModifiedAt = DateTime.UtcNow,
Version = "1.0"
};
}
#endregion
}