STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
MibTreeNode.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
5 
6 namespace Lextm.SharpSnmpLib.Mib
7 {
8  [Flags]
9  public enum MibTreeNodeType
10  {
11  Unknown = 0,
12  Container = (1 << 0),
13  Scalar = (1 << 1),
14  Table = (1 << 2),
15  TableRow = (1 << 3),
16  TableCell = (1 << 4),
17  NotificationRelated = (1 << 5),
18  ConformanceRelated = (1 << 6)
19  }
20 
21 
22  public class MibTreeNode
23  {
24  private MibTreeNode _parent = null;
25  private List<MibTreeNode> _childNodes = new List<MibTreeNode>();
26  private IEntity _entity = null;
27  private MibTreeNodeType _nodeType = MibTreeNodeType.Unknown;
28 
29  public MibTreeNode(MibTreeNode parent, IEntity entity)
30  {
31  _parent = parent;
32  _entity = entity;
33  }
34 
35  public MibTreeNode Parent
36  {
37  get { return _parent; }
38  }
39 
40  public IEntity Entity
41  {
42  get { return _entity; }
43  }
44 
45  public MibTreeNodeType NodeType
46  {
47  get { return _nodeType; }
48  }
49 
50  public List<MibTreeNode> ChildNodes
51  {
52  get { return _childNodes; }
53  }
54 
55  public MibTreeNode AddChild(IEntity element)
56  {
57  MibTreeNode result = new MibTreeNode(this, element);
58  this.ChildNodes.Add(result);
59 
60  return result;
61  }
62 
63  public void UpdateNodeType()
64  {
65  _nodeType = MibTreeNodeType.Unknown;
66 
67  if (_entity != null)
68  {
69  if ((_entity is OidValueAssignment) || (_entity is ObjectIdentity))
70  {
71  _nodeType |= MibTreeNodeType.Container;
72  return;
73  }
74  else if (_childNodes.Count > 0)
75  {
76  _nodeType |= MibTreeNodeType.Container;
77  }
78 
79  if (_entity is ObjectType)
80  {
81  ObjectType ot = _entity as ObjectType;
82 
83  if (ot.Syntax is SequenceOf)
84  {
85  _nodeType |= MibTreeNodeType.Table;
86  }
87  else if (ot.Syntax is Sequence)
88  {
89  _nodeType |= MibTreeNodeType.TableRow;
90  }
91  else if ((_parent != null) && ((_parent.NodeType & MibTreeNodeType.TableRow) != 0))
92  {
93  _nodeType |= MibTreeNodeType.TableCell;
94  _nodeType |= MibTreeNodeType.Scalar;
95  }
96  else
97  {
98  _nodeType |= MibTreeNodeType.Scalar;
99  }
100  }
101  else if ((_entity is ModuleCompliance) || (_entity is ObjectGroup) || (_entity is NotificationGroup))
102  {
103  _nodeType |= MibTreeNodeType.ConformanceRelated;
104  }
105  else if ((_entity is NotificationGroup) || (_entity is NotificationType))
106  {
107  _nodeType |= MibTreeNodeType.NotificationRelated;
108  }
109  }
110  }
111  }
112 }
MibTreeNode(MibTreeNode parent, IEntity entity)
Definition: MibTreeNode.cs:29
The SEQUENCE type represents a set of specified types. This is roughtly analogous to a ...
Definition: Sequence.cs:16
MibTreeNode AddChild(IEntity element)
Definition: MibTreeNode.cs:55
Basic interface for all elements building up the MIB tree, thus having an OID as value.
Definition: IEntity.cs:34
The SEQUENCE OF type represents a list of data sets..
Definition: SequenceOf.cs:8