コード例 #1
0
ファイル: Oid.cs プロジェクト: timematcher/SnmpSharpNet
        /// <summary>
        ///     Return child components of the leaf OID.
        /// </summary>
        /// <param name="root">Root Oid</param>
        /// <param name="leaf">Leaf Oid</param>
        /// <returns>Returns int array of child OIDs, if there was an error or no child IDs are present, returns null.</returns>
        public static uint[] GetChildIdentifiers(Oid root, Oid leaf)
        {
            uint[] tmp;
            if ((object)leaf == null || leaf.IsNull)
            {
                return(null);
            }
            if (((object)root == null || root.IsNull) && (object)leaf != null)
            {
                tmp = new uint[leaf.Length];
                Array.Copy(leaf.GetData(), tmp, leaf.Length);
                return(tmp);
            }
            if (!root.IsRootOf(leaf))
            {
                return(null);
            }
            if (leaf.Length <= root.Length)
            {
                return(null); // There are not child ids if this oid is longer
            }
            var leafLen = leaf.Length - root.Length;

            tmp = new uint[leafLen];
            Array.Copy(leaf.GetData(), root.Length, tmp, 0, leafLen);
            return(tmp);
        }
コード例 #2
0
ファイル: Oid.cs プロジェクト: jxun1985/SnmpSharpNet
        /// <summary>
        /// Return child components of the leaf OID.
        /// </summary>
        /// <param name="root">Root Oid</param>
        /// <param name="leaf">Leaf Oid</param>
        /// <returns>Returns int array of child OIDs, if there was an error or no child IDs are present, returns null.</returns>
        public static UInt32[] GetChildIdentifiers(Oid root, Oid leaf)
        {
            UInt32[] tmp;
            if (((Object)leaf) == null || leaf.IsNull)
            {
                return(null);
            }
            else if ((((Object)root) == null || root.IsNull) && ((Object)leaf) != null)
            {
                tmp = new UInt32[leaf.Length];
                Array.Copy(leaf.GetData(), tmp, leaf.Length);
                return(tmp);
            }
            if (!root.IsRootOf(leaf))
            {
                // Has to be a child OID
                return(null);
            }
            if (leaf.Length <= root.Length)
            {
                return(null);                // There are not child ids if this oid is longer
            }
            int leafLen = leaf.Length - root.Length;

            tmp = new UInt32[leafLen];
            Array.Copy(leaf.GetData(), root.Length, tmp, 0, leafLen);
            return(tmp);
        }
コード例 #3
0
 /// <summary>Compare objectId values</summary>
 /// <param name="cmp">ObjectId to Compare with</param>
 /// <returns>0 if equal, -1 if less then and 1 if greater then.</returns>
 public virtual int Compare(Oid cmp)
 {
     if (cmp.GetData() == null && _data == null)
     {
         return(0);
     }
     else if (cmp.GetData() != null && _data == null)
     {
         return(1);
     }
     else if (cmp.GetData() == null && _data != null)
     {
         return(-1);
     }
     return(Compare(cmp.GetData()));
 }
コード例 #4
0
ファイル: Oid.cs プロジェクト: timematcher/SnmpSharpNet
 /// <summary>
 ///     Set class value from another Oid class.
 /// </summary>
 /// <param name="value">Oid class</param>
 /// <exception cref="ArgumentNullException">Thrown when parameter is null</exception>
 public void Set(Oid value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     Set(value.GetData());
 }
コード例 #5
0
        /// <summary>
        /// Return child components of the leaf OID.
        /// </summary>
        /// <param name="root">Root Oid</param>
        /// <param name="leaf">Leaf Oid</param>
        /// <returns>Returns int array of child OIDs, if there was an error or no child IDs are present, returns null.</returns>
        public static int[] GetChildIdentifiers(Oid root, Oid leaf)
        {
            if (!root.IsRootOf(leaf))
            {
                // Has to be a child OID
                return(null);
            }
            if (leaf.Length <= root.Length)
            {
                return(null);                // There are not child ids if this oid is longer
            }
            int leafLen = leaf.Length - root.Length;

            int[] tmp = new int[leafLen];
            Array.Copy(leaf.GetData(), root.Length, tmp, 0, leafLen);
            return(tmp);
        }
コード例 #6
0
ファイル: Oid.cs プロジェクト: timematcher/SnmpSharpNet
 /// <summary>
 ///     Exact comparison of two Oid values
 /// </summary>
 /// <param name="oid">Oid to compare against</param>
 /// <returns>1 if class is greater then argument, -1 if class value is less then argument, 0 if the same</returns>
 public int CompareExact(Oid oid)
 {
     return(CompareExact(oid.GetData()));
 }
コード例 #7
0
ファイル: Oid.cs プロジェクト: timematcher/SnmpSharpNet
 /// <summary>
 ///     Appends the passed Oid object to
 ///     self.
 /// </summary>
 /// <param name="second">
 ///     The object to Append to self
 /// </param>
 public virtual void Add(Oid second)
 {
     Add(second.GetData());
 }