-
Notifications
You must be signed in to change notification settings - Fork 160
Expand file tree
/
Copy pathGeneral.vbs
More file actions
65 lines (54 loc) · 2.32 KB
/
General.vbs
File metadata and controls
65 lines (54 loc) · 2.32 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
' Copyright (c) Microsoft Corporation. All rights reserved.
' Licensed under the MIT license.
set System = clr.System
set TestObjectT = host.type("Microsoft.ClearScript.Test.GeneralTestObject", "ClearScriptTest")
set tlist = host.newObj(System.Collections.Generic.List(TestObjectT))
call tlist.Add(host.newObj(TestObjectT, "Eóin", 20))
call tlist.Add(host.newObj(TestObjectT, "Shane", 16))
call tlist.Add(host.newObj(TestObjectT, "Cillian", 8))
call tlist.Add(host.newObj(TestObjectT, "Sasha", 6))
call tlist.Add(host.newObj(TestObjectT, "Brian", 3))
class VBTestObject
public name
public age
end class
function createTestObject(name, age)
dim testObject
set testObject = new VBTestObject
testObject.name = name
testObject.age = age
set createTestObject = testObject
end function
set olist = host.newObj(System.Collections.Generic.List(System.Object))
call olist.Add(createTestObject("Brian", 3))
call olist.Add(createTestObject("Sasha", 6))
call olist.Add(createTestObject("Cillian", 8))
call olist.Add(createTestObject("Shane", 16))
call olist.Add(createTestObject("Eóin", 20))
set dict = host.newObj(System.Collections.Generic.Dictionary(System.String, System.String))
call dict.Add("foo", "bar")
call dict.Add("baz", "qux")
set value = host.newVar(System.String)
result = dict.TryGetValue("foo", value.out)
set expando = host.newObj(System.Dynamic.ExpandoObject)
set expandoCollection = host.cast(System.Collections.Generic.ICollection(System.Collections.Generic.KeyValuePair(System.String, System.Object)), expando)
set onEventRef = GetRef("onEvent")
sub onEvent(s, e)
call System.Console.WriteLine("Property changed: {0}; new value: {1}", e.PropertyName, eval("s." + e.PropertyName))
end sub
set onStaticEventRef = GetRef("onStaticEvent")
sub onStaticEvent(s, e)
call System.Console.WriteLine("Property changed: {0}; new value: {1} (static event)", e.PropertyName, e.PropertyValue)
end sub
set eventCookie = tlist.Item(0).Change.connect(onEventRef)
set staticEventCookie = TestObjectT.StaticChange.connect(onStaticEventRef)
tlist.Item(0).Name = "Jerry"
tlist.Item(1).Name = "Ellis"
tlist.Item(0).Name = "Eóin"
tlist.Item(1).Name = "Shane"
call eventCookie.disconnect()
call staticEventCookie.disconnect()
tlist.Item(0).Name = "Jerry"
tlist.Item(1).Name = "Ellis"
tlist.Item(0).Name = "Eóin"
tlist.Item(1).Name = "Shane"