forked from ahyahy/OneScriptForms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollection.cs
More file actions
130 lines (114 loc) · 3.39 KB
/
Collection.cs
File metadata and controls
130 lines (114 loc) · 3.39 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
using System;
using ScriptEngine.Machine.Contexts;
using ScriptEngine.Machine;
namespace osf
{
public class Collection : System.Collections.IEnumerable
{
public ClCollection dll_obj;
public Microsoft.VisualBasic.Collection M_Collection;
public Collection()
{
M_Collection = new Microsoft.VisualBasic.Collection();
OneScriptForms.AddToHashtable(M_Collection, this);
}
public Collection(Microsoft.VisualBasic.Collection p1)
{
M_Collection = p1;
}
public Collection(osf.Collection p1)
{
M_Collection = p1.M_Collection;
}
public int Count
{
get { return M_Collection.Count; }
}
public object this[object index]
{
get
{
if (index is int)
{
return M_Collection[checked(Convert.ToInt32(index) + 1)];
}
if (index is string)
{
return M_Collection[Convert.ToString(index)];
}
return M_Collection[index];
}
}
public void Add(object item, string key = null)
{
M_Collection.Add(item, key);
}
public System.Collections.IEnumerator GetEnumerator()
{
return M_Collection.GetEnumerator();
}
public void Remove(object index)
{
if (index is int)
{
M_Collection.Remove(checked(Convert.ToInt32(index) + 1));
}
else if (index is string)
{
M_Collection.Remove(checked(Convert.ToString(index)));
}
}
}
[ContextClass ("КлКоллекция", "ClCollection")]
public class ClCollection : AutoContext<ClCollection>
{
public ClCollection()
{
Collection Collection1 = new Collection();
Collection1.dll_obj = this;
Base_obj = Collection1;
}
public ClCollection(Collection p1)
{
Collection Collection1 = p1;
Collection1.dll_obj = this;
Base_obj = Collection1;
}
public Collection Base_obj;
[ContextProperty("Количество", "Count")]
public int Count
{
get { return Base_obj.Count; }
}
[ContextMethod("Добавить", "Add")]
public void Add(IValue p1, string p2 = null)
{
Base_obj.Add(p1, p2);
}
[ContextMethod("Удалить", "Remove")]
public void Remove(IValue p1)
{
if (p1.SystemType.Name == "Строка")
{
Base_obj.Remove(p1.AsString());
}
else if (p1.SystemType.Name == "Число")
{
Base_obj.Remove(Convert.ToInt32(p1.AsNumber()));
}
}
[ContextMethod("Элемент", "Item")]
public IValue Item(IValue p1)
{
if (p1.SystemType.Name == "Строка")
{
return (IValue)Base_obj[p1.AsString()];
}
else if (p1.SystemType.Name == "Число")
{
return (IValue)Base_obj[Convert.ToInt32(p1.AsNumber())];
}
return null;
}
}
}