// /** // * File: ObjectIdentifier.cs // * Author: haraldwolff // * // * This file and it's content is copyrighted by the Author and / or copyright holder. // * Any use wihtout proper permission is illegal and may lead to legal actions. // * // * // **/ using System; using System.Linq; using ln.snmp.asn1; namespace ln.snmp.types { public class ObjectIdentifier : Variable { public int[] OIDValue { get; set; } public ObjectIdentifier() :base(new Identifier(IdentifierClass.UNIVERSAL,false,6)) { } public ObjectIdentifier(int[] oid) : this() { OIDValue = oid; } public ObjectIdentifier(string oid) : this() { int[] ioid = oid.Split(new char[] { '.' }, StringSplitOptions.None).Select((x)=> int.Parse(x)).ToArray(); OIDValue = ioid; } /* Check is b is part of the my subtree or is equal*/ public bool Contains(ObjectIdentifier b) { int[] me = OIDValue; int[] you = b.OIDValue; if (me.Length > you.Length) return false; for (int n=0;n BasicEncodingRules.EncodeOID(OIDValue); set => OIDValue = BasicEncodingRules.DecodeOID(value); } public override object Value { get => OIDValue; set => OIDValue = value as int[]; } public string AsString { get => String.Join(".", OIDValue.Select((x) => x.ToString())); } public override string ToString() { return String.Format("[ObjectIdentifier OID={0}]", AsString); } } }