| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 190210d commit 3fb8b8f
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,54 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT license. | ||
| 3 | + | ||
| 4 | + System = clr.System; | ||
| 5 | + | ||
| 6 | + TestObject = host.type('Microsoft.ClearScript.Test.GeneralTestObject', 'ClearScriptTest'); | ||
| 7 | + tlist = host.newObj(System.Collections.Generic.List(TestObject)); | ||
| 8 | + tlist.Add(host.newObj(TestObject, 'Eóin', 20)); | ||
| 9 | + tlist.Add(host.newObj(TestObject, 'Shane', 16)); | ||
| 10 | + tlist.Add(host.newObj(TestObject, 'Cillian', 8)); | ||
| 11 | + tlist.Add(host.newObj(TestObject, 'Sasha', 6)); | ||
| 12 | + tlist.Add(host.newObj(TestObject, 'Brian', 3)); | ||
| 13 | + | ||
| 14 | + olist = host.newObj(System.Collections.Generic.List(System.Object)); | ||
| 15 | + olist.Add({ name: 'Brian', age: 3 }); | ||
| 16 | + olist.Add({ name: 'Sasha', age: 6 }); | ||
| 17 | + olist.Add({ name: 'Cillian', age: 8 }); | ||
| 18 | + olist.Add({ name: 'Shane', age: 16 }); | ||
| 19 | + olist.Add({ name: 'Eóin', age: 20 }); | ||
| 20 | + | ||
| 21 | + dict = host.newObj(System.Collections.Generic.Dictionary(System.String, System.String)); | ||
| 22 | + dict.Add('foo', 'bar'); | ||
| 23 | + dict.Add('baz', 'qux'); | ||
| 24 | + value = host.newVar(System.String); | ||
| 25 | + result = dict.TryGetValue('foo', value.out); | ||
| 26 | + | ||
| 27 | + bag = host.newObj(); | ||
| 28 | + bag.method = function (x) { System.Console.WriteLine(x * x); }; | ||
| 29 | + bag.proc = host.del(System.Action(System.Object), bag.method); | ||
| 30 | + | ||
| 31 | + expando = host.newObj(System.Dynamic.ExpandoObject); | ||
| 32 | + expandoCollection = host.cast(System.Collections.Generic.ICollection(System.Collections.Generic.KeyValuePair(System.String, System.Object)), expando); | ||
| 33 | + | ||
| 34 | + function onChange(s, e) { | ||
| 35 | + System.Console.WriteLine('Property changed: {0}; new value: {1}', e.PropertyName, s[e.PropertyName]); | ||
| 36 | + }; | ||
| 37 | + function onStaticChange(s, e) { | ||
| 38 | + System.Console.WriteLine('Property changed: {0}; new value: {1} (static event)', e.PropertyName, e.PropertyValue); | ||
| 39 | + }; | ||
| 40 | + eventCookie = tlist.Item(0).Change.connect(onChange); | ||
| 41 | + staticEventCookie = TestObject.StaticChange.connect(onStaticChange); | ||
| 42 | + tlist.Item(0).Name = 'Jerry'; | ||
| 43 | + tlist.Item(1).Name = 'Ellis'; | ||
| 44 | + tlist.Item(0).Name = 'Eóin'; | ||
| 45 | + tlist.Item(1).Name = 'Shane'; | ||
| 46 | + eventCookie.disconnect(); | ||
| 47 | + staticEventCookie.disconnect(); | ||
| 48 | + tlist.Item(0).Name = 'Jerry'; | ||
| 49 | + tlist.Item(1).Name = 'Ellis'; | ||
| 50 | + tlist.Item(0).Name = 'Eóin'; | ||
| 51 | + tlist.Item(1).Name = 'Shane'; | ||
| 52 | + | ||
| 53 | + // ReSharper disable once WrongExpressionStatement | ||
| 54 | + Math.round(Math.sin(Math.PI) * 1000e16); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,14 +2,18 @@ | |||
| 2 | 2 | // Licensed under the MIT license. | |
| 3 | 3 | ||
| 4 | 4 | import * as Arithmetic from '../Arithmetic/Arithmetic.js'; | |
| 5 | + import * as Self from 'Geometry.js'; | ||
| 5 | 6 | ||
| 6 | 7 | export class Rectangle { | |
| 7 | 8 | constructor(width, height) { | |
| 8 | 9 | this.width = width; | |
| 9 | 10 | this.height = height; | |
| 10 | 11 | } | |
| 11 | 12 | get Area() { | |
| 12 | - return Arithmetic.Multiply(this.width, this.height); | ||
| 13 | + return Self.Rectangle.CalculateArea(this.width, this.height); | ||
| 14 | + } | ||
| 15 | + static CalculateArea(width, height) { | ||
| 16 | + return Arithmetic.Multiply(width, height); | ||
| 13 | 17 | } | |
| 14 | 18 | } | |
| 15 | 19 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,13 +7,18 @@ let Arithmetic; | |||
| 7 | 7 | Arithmetic = await import('../Arithmetic/Arithmetic.js'); | |
| 8 | 8 | })(); | |
| 9 | 9 | ||
| 10 | + import * as Self from 'Geometry.js'; | ||
| 11 | + | ||
| 10 | 12 | export class Rectangle { | |
| 11 | 13 | constructor(width, height) { | |
| 12 | 14 | this.width = width; | |
| 13 | 15 | this.height = height; | |
| 14 | 16 | } | |
| 15 | 17 | get Area() { | |
| 16 | - return Arithmetic.Multiply(this.width, this.height); | ||
| 18 | + return Self.Rectangle.CalculateArea(this.width, this.height); | ||
| 19 | + } | ||
| 20 | + static CalculateArea(width, height) { | ||
| 21 | + return Arithmetic.Multiply(width, height); | ||
| 17 | 22 | } | |
| 18 | 23 | } | |
| 19 | 24 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,14 +2,18 @@ | |||
| 2 | 2 | // Licensed under the MIT license. | |
| 3 | 3 | ||
| 4 | 4 | import * as Arithmetic from 'Arithmetic.js'; | |
| 5 | + import * as Self from 'Geometry.js'; | ||
| 5 | 6 | ||
| 6 | 7 | export class Rectangle { | |
| 7 | 8 | constructor(width, height) { | |
| 8 | 9 | this.width = width; | |
| 9 | 10 | this.height = height; | |
| 10 | 11 | } | |
| 11 | 12 | get Area() { | |
| 12 | - return Arithmetic.Multiply(this.width, this.height); | ||
| 13 | + return Self.Rectangle.CalculateArea(this.width, this.height); | ||
| 14 | + } | ||
| 15 | + static CalculateArea(width, height) { | ||
| 16 | + return Arithmetic.Multiply(width, height); | ||
| 13 | 17 | } | |
| 14 | 18 | } | |
| 15 | 19 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + // Licensed under the MIT license. | ||
| 3 | + | ||
| 4 | + import * as Geometry from 'Geometry/Geometry.js'; | ||
| 5 | + | ||
| 6 | + // ReSharper disable once WrongExpressionStatement | ||
| 7 | + new Geometry.Square(25).Area; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + CLng(Sin(4 * atn(1)) * 1000e16) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,65 @@ | |||
| 1 | + ' Copyright (c) Microsoft Corporation. All rights reserved. | ||
| 2 | + ' Licensed under the MIT license. | ||
| 3 | + | ||
| 4 | + set System = clr.System | ||
| 5 | + | ||
| 6 | + set TestObjectT = host.type("Microsoft.ClearScript.Test.GeneralTestObject", "ClearScriptTest") | ||
| 7 | + set tlist = host.newObj(System.Collections.Generic.List(TestObjectT)) | ||
| 8 | + call tlist.Add(host.newObj(TestObjectT, "Eóin", 20)) | ||
| 9 | + call tlist.Add(host.newObj(TestObjectT, "Shane", 16)) | ||
| 10 | + call tlist.Add(host.newObj(TestObjectT, "Cillian", 8)) | ||
| 11 | + call tlist.Add(host.newObj(TestObjectT, "Sasha", 6)) | ||
| 12 | + call tlist.Add(host.newObj(TestObjectT, "Brian", 3)) | ||
| 13 | + | ||
| 14 | + class VBTestObject | ||
| 15 | + public name | ||
| 16 | + public age | ||
| 17 | + end class | ||
| 18 | + | ||
| 19 | + function createTestObject(name, age) | ||
| 20 | + dim testObject | ||
| 21 | + set testObject = new VBTestObject | ||
| 22 | + testObject.name = name | ||
| 23 | + testObject.age = age | ||
| 24 | + set createTestObject = testObject | ||
| 25 | + end function | ||
| 26 | + | ||
| 27 | + set olist = host.newObj(System.Collections.Generic.List(System.Object)) | ||
| 28 | + call olist.Add(createTestObject("Brian", 3)) | ||
| 29 | + call olist.Add(createTestObject("Sasha", 6)) | ||
| 30 | + call olist.Add(createTestObject("Cillian", 8)) | ||
| 31 | + call olist.Add(createTestObject("Shane", 16)) | ||
| 32 | + call olist.Add(createTestObject("Eóin", 20)) | ||
| 33 | + | ||
| 34 | + set dict = host.newObj(System.Collections.Generic.Dictionary(System.String, System.String)) | ||
| 35 | + call dict.Add("foo", "bar") | ||
| 36 | + call dict.Add("baz", "qux") | ||
| 37 | + set value = host.newVar(System.String) | ||
| 38 | + result = dict.TryGetValue("foo", value.out) | ||
| 39 | + | ||
| 40 | + set expando = host.newObj(System.Dynamic.ExpandoObject) | ||
| 41 | + set expandoCollection = host.cast(System.Collections.Generic.ICollection(System.Collections.Generic.KeyValuePair(System.String, System.Object)), expando) | ||
| 42 | + | ||
| 43 | + set onEventRef = GetRef("onEvent") | ||
| 44 | + sub onEvent(s, e) | ||
| 45 | + call System.Console.WriteLine("Property changed: {0}; new value: {1}", e.PropertyName, eval("s." + e.PropertyName)) | ||
| 46 | + end sub | ||
| 47 | + | ||
| 48 | + set onStaticEventRef = GetRef("onStaticEvent") | ||
| 49 | + sub onStaticEvent(s, e) | ||
| 50 | + call System.Console.WriteLine("Property changed: {0}; new value: {1} (static event)", e.PropertyName, e.PropertyValue) | ||
| 51 | + end sub | ||
| 52 | + | ||
| 53 | + set eventCookie = tlist.Item(0).Change.connect(onEventRef) | ||
| 54 | + set staticEventCookie = TestObjectT.StaticChange.connect(onStaticEventRef) | ||
| 55 | + tlist.Item(0).Name = "Jerry" | ||
| 56 | + tlist.Item(1).Name = "Ellis" | ||
| 57 | + tlist.Item(0).Name = "Eóin" | ||
| 58 | + tlist.Item(1).Name = "Shane" | ||
| 59 | + | ||
| 60 | + call eventCookie.disconnect() | ||
| 61 | + call staticEventCookie.disconnect() | ||
| 62 | + tlist.Item(0).Name = "Jerry" | ||
| 63 | + tlist.Item(1).Name = "Ellis" | ||
| 64 | + tlist.Item(0).Name = "Eóin" | ||
| 65 | + tlist.Item(1).Name = "Shane" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments