Attribute
using System;
namespace Org.BouncyCastle.Asn1.Cms
{
public class Attribute : Asn1Encodable
{
private readonly DerObjectIdentifier m_attrType;
private readonly Asn1Set m_attrValues;
public DerObjectIdentifier AttrType => m_attrType;
public Asn1Set AttrValues => m_attrValues;
public static Attribute GetInstance(object obj)
{
if (obj == null)
return null;
Attribute attribute = obj as Attribute;
if (attribute != null)
return attribute;
return new Attribute(Asn1Sequence.GetInstance(obj));
}
public static Attribute GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new Attribute(Asn1Sequence.GetInstance(taggedObject, declaredExplicit));
}
public static Attribute GetTagged(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
return new Attribute(Asn1Sequence.GetTagged(taggedObject, declaredExplicit));
}
[Obsolete("Use 'GetInstance' instead")]
public Attribute(Asn1Sequence seq)
{
int count = seq.Count;
if (count != 2)
throw new ArgumentException("Bad sequence size: " + count.ToString(), "seq");
m_attrType = DerObjectIdentifier.GetInstance(seq[0]);
m_attrValues = Asn1Set.GetInstance(seq[1]);
}
public Attribute(DerObjectIdentifier attrType, Asn1Set attrValues)
{
if (attrType == null)
throw new ArgumentNullException("attrType");
m_attrType = attrType;
if (attrValues == null)
throw new ArgumentNullException("attrValues");
m_attrValues = attrValues;
}
public override Asn1Object ToAsn1Object()
{
return new DerSequence(m_attrType, m_attrValues);
}
}
}