-
Notifications
You must be signed in to change notification settings - Fork 158
/
Copy pathDataType.cs
87 lines (72 loc) · 2.51 KB
/
DataType.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
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
namespace Microsoft.PowerShell.PlatyPS.MAML
{
/// <summary>
/// Represents a "dev:type" element in a Powershell MAML help document.
/// </summary>
[XmlRoot("dataType", Namespace = Constants.XmlNamespace.Dev)]
public class DataType
{
/// <summary>
/// The data-type name.
/// </summary>
[XmlElement("name", Namespace = Constants.XmlNamespace.MAML, Order = 0)]
public string Name { get; set; } = string.Empty;
/// <summary>
/// The data-type URI (unused, for the most part).
/// </summary>
// [XmlElement("uri", Namespace = Constants.XmlNamespace.MAML, Order = 1)]
[XmlIgnore]
public string Uri { get; set; } = string.Empty;
/// <summary>
/// The data-type's detailed description (one or more paragraphs; "maml:description/maml:para").
/// </summary>
// [XmlArray("description", Namespace = Constants.XmlNamespace.MAML, Order = 2)]
// [XmlArrayItem("para", Namespace = Constants.XmlNamespace.MAML)]
[XmlIgnore]
public List<string> Description { get; set; } = new List<string>();
public bool Equals(DataType other)
{
if (other is null)
return false;
return (
string.Compare(Name, other.Name) == 0 &&
string.Compare(Uri, other.Uri) == 0 &&
Description.SequenceEqual(other.Description)
);
}
public override bool Equals(object other)
{
if (other is DataType dataType2)
{
return Equals(dataType2);
}
return false;
}
public override int GetHashCode()
{
// Valid?
return Name.GetHashCode() ^ Uri.GetHashCode();
}
public static bool operator == (DataType dataType1, DataType dataType2)
{
if (dataType1 is not null && dataType2 is not null)
{
return dataType1.Equals(dataType2);
}
return false;
}
public static bool operator != (DataType dataType1, DataType dataType2)
{
if (dataType1 is not null && dataType2 is not null)
{
return ! dataType1.Equals(dataType2);
}
return false;
}
}
}