forked from florentbr/SeleniumBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionaryItem.cs
More file actions
134 lines (110 loc) · 3.48 KB
/
DictionaryItem.cs
File metadata and controls
134 lines (110 loc) · 3.48 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Selenium {
/// <summary>
/// DictionaryItem object
/// </summary>
[ProgId("Selenium.DictionaryItem")]
[Guid("0277FC34-FD1B-4616-BB19-92FC0C76E59B")]
[Description("Item object from a Dictionary")]
[ComVisible(true), ClassInterface(ClassInterfaceType.None)]
[DebuggerTypeProxy(typeof(DictionaryItem.DictionaryItemDebugView))]
[DebuggerDisplay("{Key}: {Value}")]
public class DictionaryItem : ComInterfaces._DictionaryItem, System.Collections.IEnumerable {
internal readonly int hash;
internal readonly string key;
internal object value;
internal DictionaryItem next = null;
internal DictionaryItem(string key, object value) {
this.hash = key.GetHashCode();
this.key = key;
this.value = value;
}
internal DictionaryItem(int hash, string key, object value) {
this.hash = hash;
this.key = key;
this.value = value;
}
/// <summary>
/// Dictionary key
/// </summary>
public string Key {
get {
return this.key;
}
}
/// <summary>
/// Dictionary value
/// </summary>
public object Value {
get {
return this.value;
}
set {
this.value = value;
}
}
/// <summary>
/// Returns the KeyValue enumerator
/// </summary>
/// <returns></returns>
public System.Collections.IEnumerator GetEnumerator() {
return new DictionaryItemEnumerator(this);
}
/// <summary>
/// KeyValue enumerator
/// </summary>
public class DictionaryItemEnumerator : System.Collections.IEnumerator {
private DictionaryItem _dict;
private int _index;
private object _current;
internal DictionaryItemEnumerator(DictionaryItem dict) {
_dict = dict;
_index = 0;
_current = null;
}
/// <summary>
/// Moves to the next item.
/// </summary>
/// <returns></returns>
public bool MoveNext() {
switch (_index) {
case 0: _current = _dict.key; break;
case 1: _current = _dict.value; break;
default: return false;
}
_index++;
return true;
}
/// <summary>
/// Returns the current item.
/// </summary>
public object Current {
get {
return _current;
}
}
/// <summary>
/// Sets the enumerator to its initial position.
/// </summary>
public void Reset() {
_index = 0;
_current = null;
}
}
internal class DictionaryItemDebugView {
private DictionaryItem _item;
public DictionaryItemDebugView(DictionaryItem item) {
_item = item;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public object Value {
get {
return _item.value;
}
}
}
}
}