本文整理汇总了C#中Oid.decode方法的典型用法代码示例。如果您正苦于以下问题:C# Oid.decode方法的具体用法?C# Oid.decode怎么用?C# Oid.decode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oid
的用法示例。
在下文中一共展示了Oid.decode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: decode
/// <summary>Decode BER encoded variable binding.
/// </summary>
/// <param name="buffer">BER encoded buffer
/// </param>
/// <param name="offset">Offset in the data buffer from where to start decoding. Offset is
/// passed by reference and will contain the offset of the byte immediately after the parsed
/// variable binding.
/// </param>
/// <returns>Buffer position after the decoded value</returns>
public override int decode(byte[] buffer, int offset)
{
int headerLength;
byte asnType = ParseHeader(buffer, ref offset, out headerLength);
if (asnType != Type)
throw new SnmpException(string.Format("Invalid ASN.1 type. Expected 0x{0:x2} received 0x{1:x2}", Type, asnType));
// verify the length
if ((buffer.Length - offset) < headerLength)
throw new OverflowException("Buffer underflow error");
_oid = new Oid();
offset = _oid.decode(buffer, offset);
int saveOffset = offset;
// Look ahead in the header to see the data type we need to parse
asnType = ParseHeader(buffer, ref saveOffset, out headerLength);
_value = SnmpConstants.GetSyntaxObject(asnType);
if (_value == null)
throw new SnmpDecodingException(String.Format("Invalid ASN.1 type encountered 0x{0:x2}. Unable to continue decoding.", asnType));
offset = _value.decode(buffer, offset);
return offset;
}