source: azure_iot_hub_f767zi/trunk/asp_baseplatform/lwip/contrib-2.1.0/apps/LwipMibCompiler/SharpSnmpLib/Mib/DisplayHint.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: 2.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Collections;
4
5namespace Lextm.SharpSnmpLib.Mib
6{
7 public class DisplayHint
8 {
9 private enum NumType {
10 dec,
11 hex,
12 oct,
13 bin,
14 str
15 }
16
17 private string _str;
18 private NumType _type;
19 private int _decimalPoints = 0;
20
21 public DisplayHint(string str)
22 {
23 _str = str;
24 if (str.StartsWith("d"))
25 {
26 _type = NumType.dec;
27 if (str.StartsWith("d-"))
28 {
29 _decimalPoints = Convert.ToInt32(str.Substring(2));
30 }
31 }
32 else if (str.StartsWith("o"))
33 {
34 _type = NumType.oct;
35 }
36 else if (str.StartsWith("h"))
37 {
38 _type = NumType.hex;
39 }
40 else if (str.StartsWith("b"))
41 {
42 _type = NumType.bin;
43 }
44 else
45 {
46 _type = NumType.str;
47 foreach (char c in str)
48 {
49
50 }
51 }
52
53 }
54
55 public override string ToString()
56 {
57 return _str;
58 }
59
60 internal object Decode(int i)
61 {
62 switch (_type)
63 {
64 case NumType.dec:
65 if (_decimalPoints == 0)
66 {
67 return i;
68 }
69 else
70 {
71 return i / Math.Pow(10.0, _decimalPoints);
72 }
73 case NumType.hex:
74 return System.Convert.ToString(i, 16);
75 case NumType.oct:
76 return System.Convert.ToString(i, 8);
77 case NumType.bin:
78 return System.Convert.ToString(i, 2);
79 default:
80 return null;
81 }
82 }
83 }
84}
Note: See TracBrowser for help on using the repository browser.