source: azure_iot_hub_f767zi/trunk/asp_baseplatform/lwip/contrib-2.1.0/apps/LwipMibCompiler/SharpSnmpLib/Mib/ValueRange.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: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3
4namespace Lextm.SharpSnmpLib.Mib
5{
6 public class ValueRanges: List<ValueRange>
7 {
8 public bool IsSizeDeclaration { get; internal set; }
9
10 public ValueRanges(bool isSizeDecl = false)
11 {
12 IsSizeDeclaration = isSizeDecl;
13 }
14
15 public bool Contains(Int64 value)
16 {
17 foreach (ValueRange range in this)
18 {
19 if (range.Contains(value))
20 {
21 return true;
22 }
23 }
24
25 return false;
26 }
27 }
28
29 public class ValueRange
30 {
31 private readonly Int64 _start;
32 private readonly Int64? _end;
33
34 public ValueRange(Int64 first, Int64? second)
35 {
36 _start = first;
37 _end = second;
38 }
39
40 public Int64 Start
41 {
42 get { return _start; }
43 }
44
45 public Int64? End
46 {
47 get { return _end; }
48 }
49
50 public bool IntersectsWith(ValueRange other)
51 {
52 if (this._end == null)
53 {
54 return other.Contains(this._start);
55 }
56 else if (other._end == null)
57 {
58 return this.Contains(other._start);
59 }
60
61 return (this._start <= other.End) && (this._end >= other._start);
62 }
63
64 public bool Contains(Int64 value)
65 {
66 if (_end == null)
67 {
68 return value == _start;
69 }
70 else
71 {
72 return (_start <= value) && (value <= _end);
73 }
74 }
75 }
76}
Note: See TracBrowser for help on using the repository browser.