source: azure_iot_hub_f767zi/trunk/asp_baseplatform/lwip/contrib-2.1.0/apps/LwipMibCompiler/SharpSnmpLib/Mib/MibTreeNode.cs@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csharp;charset=UTF-8
File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using Lextm.SharpSnmpLib.Mib.Elements.Entities;
4using Lextm.SharpSnmpLib.Mib.Elements.Types;
5
6namespace 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}
Note: See TracBrowser for help on using the repository browser.