mirrored from https://www.bouncycastle.org/repositories/bc-csharp
-
Notifications
You must be signed in to change notification settings - Fork 602
Expand file tree
/
Copy pathPgpUserAttributeSubpacketVector.cs
More file actions
64 lines (49 loc) · 1.86 KB
/
Copy pathPgpUserAttributeSubpacketVector.cs
File metadata and controls
64 lines (49 loc) · 1.86 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
using System;
using Org.BouncyCastle.Bcpg.Attr;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Bcpg.OpenPgp
{
/// <summary>Container for a list of user attribute subpackets.</summary>
public class PgpUserAttributeSubpacketVector
: IUserDataPacket
{
public static PgpUserAttributeSubpacketVector FromSubpackets(UserAttributeSubpacket[] packets) =>
new PgpUserAttributeSubpacketVector(packets ?? Array.Empty<UserAttributeSubpacket>());
private readonly UserAttributeSubpacket[] m_packets;
internal PgpUserAttributeSubpacketVector(UserAttributeSubpacket[] packets)
{
m_packets = packets;
}
public UserAttributeSubpacket GetSubpacket(UserAttributeSubpacketTag type)
{
for (int i = 0; i != m_packets.Length; i++)
{
if (m_packets[i].SubpacketType == type)
return m_packets[i];
}
return null;
}
public ImageAttrib GetImageAttribute()
{
UserAttributeSubpacket p = GetSubpacket(UserAttributeSubpacketTag.ImageAttribute);
return p == null ? null : (ImageAttrib)p;
}
internal UserAttributeSubpacket[] ToSubpacketArray() => m_packets;
public override bool Equals(object obj)
{
if (obj == this)
return true;
if (!(obj is PgpUserAttributeSubpacketVector that))
return false;
if (this.m_packets.Length != that.m_packets.Length)
return false;
for (int i = 0; i != m_packets.Length; i++)
{
if (!this.m_packets[i].Equals(that.m_packets[i]))
return false;
}
return true;
}
public override int GetHashCode() => Arrays.GetHashCode(m_packets);
}
}