/// <summary> /// Returns a <see cref="String"/> that represents this <see cref="Opaque"/>. /// </summary> /// <returns></returns> public override string ToString() { return(ByteTool.Convert(_raw)); }
/// <summary> /// Gets that raw bytes. /// </summary> /// <returns></returns> internal byte[] GetRaw() { return(_raw ?? (_raw = ByteTool.GetRawBytes(BitConverter.GetBytes(_count), false))); }
/// <summary> /// Gets that raw bytes. /// </summary> /// <returns></returns> private byte[] GetRaw() { return(ByteTool.GetRawBytes(BitConverter.GetBytes(_count), false)); }
/// <summary> /// Creates an <see cref="ISnmpData"/> instance from stream. /// </summary> /// <param name="stream">Stream.</param> /// <param name="type">Type code.</param> /// <returns></returns> public static ISnmpData CreateSnmpData(int type, Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } int length = ByteTool.ReadPayloadLength(stream); switch ((SnmpType)type) { case SnmpType.Counter32: return(new Counter32(length, stream)); case SnmpType.Counter64: return(new Counter64(length, stream)); case SnmpType.Gauge32: return(new Gauge32(length, stream)); case SnmpType.ObjectIdentifier: return(new ObjectIdentifier(length, stream)); case SnmpType.Null: ByteTool.IgnoreBytes(stream, length); return(new Null()); case SnmpType.NoSuchInstance: ByteTool.IgnoreBytes(stream, length); return(new NoSuchInstance()); case SnmpType.NoSuchObject: ByteTool.IgnoreBytes(stream, length); return(new NoSuchObject()); case SnmpType.EndOfMibView: ByteTool.IgnoreBytes(stream, length); return(new EndOfMibView()); case SnmpType.Integer32: return(new Integer32(length, stream)); case SnmpType.OctetString: return(new OctetString(length, stream)); case SnmpType.IPAddress: return(new IP(length, stream)); case SnmpType.TimeTicks: return(new TimeTicks(length, stream)); case SnmpType.Sequence: return(new Sequence(length, stream)); case SnmpType.TrapV1Pdu: return(new TrapV1Pdu(stream)); case SnmpType.TrapV2Pdu: return(new TrapV2Pdu(stream)); case SnmpType.GetRequestPdu: return(new GetRequestPdu(stream)); case SnmpType.ResponsePdu: return(new ResponsePdu(stream)); case SnmpType.GetBulkRequestPdu: return(new GetBulkRequestPdu(stream)); case SnmpType.GetNextRequestPdu: return(new GetNextRequestPdu(stream)); case SnmpType.SetRequestPdu: return(new SetRequestPdu(stream)); case SnmpType.InformRequestPdu: return(new InformRequestPdu(stream)); case SnmpType.ReportPdu: return(new ReportPdu(stream)); case SnmpType.EndMarker: return(null); default: throw new SnmpException(string.Format(CultureInfo.InvariantCulture, "unsupported data type: {0}", (SnmpType)type)); } }