File: ObjectIdentifier.cs

package info (click to toggle)
lwip 2.2.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 10,008 kB
  • sloc: ansic: 109,524; cs: 6,714; sh: 115; makefile: 112; perl: 81
file content (54 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System.Collections.Generic;
using System.Text;

namespace Lextm.SharpSnmpLib.Mib
{
    public class ObjectIdentifier: List<KeyValuePair<string, uint>>
    {
        public void Add(string name, uint oid)
        {
            this.Add(new KeyValuePair<string, uint>(name, oid));
        }

        public void Prepend(string name, uint oid)
        {
            this.Insert(0, new KeyValuePair<string, uint>(name, oid));
        }

        public void Insert(int index, string name, uint oid)
        {
            this.Insert(index, new KeyValuePair<string, uint>(name, oid));
        }

        public string GetOidString()
        {
            StringBuilder result = new StringBuilder();

            foreach (KeyValuePair<string, uint> level in this)
            {
                result.Append(level.Value);
                result.Append('.');
            }

            if (result.Length > 0)
            {
                result.Length--;
            }

            return result.ToString();
        }

        public uint[] GetOidValues()
        {
            List<uint> result = new List<uint>();
            
            foreach (KeyValuePair<string, uint> level in this)
            {
                result.Add(level.Value);
            }

            return result.ToArray();
        }

    }
}