/
FileType.cs
57 lines (51 loc) · 1.76 KB
/
FileType.cs
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
// Copyright Bastian Eicher et al.
// Licensed under the GNU Lesser Public License
namespace ZeroInstall.Model.Capabilities;
/// <summary>
/// An application's ability to open a certain file type.
/// </summary>
[Description("An application's ability to open a certain file type.")]
[Serializable, XmlRoot("file-type", Namespace = CapabilityList.XmlNamespace), XmlType("file-type", Namespace = CapabilityList.XmlNamespace)]
[Equatable]
public sealed partial class FileType : VerbCapability
{
/// <summary>
/// A list of all file extensions associated with this file type.
/// </summary>
[Browsable(false)]
[XmlElement("extension")]
[OrderedEquality]
public List<FileTypeExtension> Extensions { get; } = [];
/// <inheritdoc/>
[Browsable(false), XmlIgnore, IgnoreEquality]
public override IEnumerable<string> ConflictIDs => [$"progid:{ID}"];
#region Normalize
/// <inheritdoc/>
public override void Normalize()
{
base.Normalize();
foreach (var extension in Extensions) extension.Normalize();
}
#endregion
#region Conversion
/// <summary>
/// Returns the capability in the form "ID". Not safe for parsing!
/// </summary>
public override string ToString()
=> $"{ID}";
#endregion
#region Clone
/// <inheritdoc/>
public override Capability Clone() => new FileType
{
UnknownAttributes = UnknownAttributes,
UnknownElements = UnknownElements,
ID = ID,
ExplicitOnly = ExplicitOnly,
Descriptions = {Descriptions.CloneElements()},
Icons = {Icons.CloneElements()},
Verbs = {Verbs.CloneElements()},
Extensions = {Extensions.CloneElements()}
};
#endregion
}