Skip to content

Commit 018a2a2

Browse files
Updated documentation.
1 parent 53a74ba commit 018a2a2

37 files changed

Lines changed: 1980 additions & 259 deletions

Build.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ NOTE: The first time you open the solution, Visual Studio may prompt you to
8585
upgrade one or more projects to the latest platform toolset or .NET Framework.
8686
We recommend that you select "Cancel" or "Don't Upgrade".
8787

88-
OPTIONAL: The ClearScript distribution includes a copy of the ClearScript
89-
Library Reference in Compiled HTML (.CHM) format. If you'd like to rebuild this
90-
file, use Sandcastle Help File Builder (SHFB, http://shfb.codeplex.com) with
91-
the provided SHFB project file (ClearScript\doc\Reference.shfbproj).
88+
OPTIONAL: The ClearScript repository includes the ClearScript Library Reference
89+
in HTML and Compiled HTML (.CHM) formats. If you'd like to rebuild these files,
90+
use Sandcastle Help File Builder (SHFB, https://github.com/EWSoftware/SHFB)
91+
with the provided SHFB project files (ClearScript\doc\[Web]Reference.shfbproj).
9292

9393
------------------------------------------------------------
9494
III. Building strong-named ClearScript assemblies (optional)

ClearScript/ScriptEngine.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ public ScriptAccess DefaultAccess
126126
/// <remarks>
127127
/// When this property is set to <c>true</c>, script code running in the current script
128128
/// engine is permitted to use reflection. This affects
129-
/// <see cref="System.Object.GetType"/>, <see cref="System.Exception.GetType"/>,
130-
/// <see cref="System.Delegate.Method"/>, <see cref="HostFunctions.typeOf(object)"/> and
131-
/// <see cref="HostFunctions.typeOf{T}"/>. By default, any attempt to invoke these methods
132-
/// from script code results in an exception.
129+
/// <see cref="System.Object.GetType">Object.GetType()</see>,
130+
/// <see cref="System.Exception.GetType">Exception.GetType()</see>,
131+
/// <see cref="System.Delegate.Method">Delegate.Method</see>,
132+
/// <see cref="HostFunctions.typeOf(object)"/> and <see cref="HostFunctions.typeOf{T}"/>.
133+
/// By default, any attempt to invoke these members from script code results in an
134+
/// exception.
133135
/// </remarks>
134136
public bool AllowReflection { get; set; }
135137

ClearScript/doc/FAQtorial.docx

-3.46 KB
Binary file not shown.

ClearScript/doc/FAQtorial.pdf

96 KB
Binary file not shown.

ClearScript/doc/Reference.chm

-12 Bytes
Binary file not shown.

ReadMe.md

Lines changed: 5 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -17,102 +17,8 @@ ClearScript is a library that makes it easy to add scripting to your .NET applic
1717
* The host can invoke script functions and access script objects directly
1818
* Full support for script debugging
1919

20-
# Examples
21-
``` C#
22-
using System;
23-
using Microsoft.ClearScript;
24-
using Microsoft.ClearScript.JavaScript;
25-
using Microsoft.ClearScript.V8;
26-
27-
// create a script engine
28-
using (var engine = new V8ScriptEngine())
29-
{
30-
// expose a host type
31-
engine.AddHostType("Console", typeof(Console));
32-
engine.Execute("Console.WriteLine('{0} is an interesting number.', Math.PI)");
33-
34-
// expose a host object
35-
engine.AddHostObject("random", new Random());
36-
engine.Execute("Console.WriteLine(random.NextDouble())");
37-
38-
// expose entire assemblies
39-
engine.AddHostObject("lib", new HostTypeCollection("mscorlib", "System.Core"));
40-
engine.Execute("Console.WriteLine(lib.System.DateTime.Now)");
41-
42-
// create a host object from script
43-
engine.Execute(@"
44-
birthday = new lib.System.DateTime(2007, 5, 22);
45-
Console.WriteLine(birthday.ToLongDateString());
46-
");
47-
48-
// use a generic class from script
49-
engine.Execute(@"
50-
Dictionary = lib.System.Collections.Generic.Dictionary;
51-
dict = new Dictionary(lib.System.String, lib.System.Int32);
52-
dict.Add('foo', 123);
53-
");
54-
55-
// call a host method with an output parameter
56-
engine.AddHostObject("host", new HostFunctions());
57-
engine.Execute(@"
58-
intVar = host.newVar(lib.System.Int32);
59-
found = dict.TryGetValue('foo', intVar.out);
60-
Console.WriteLine('{0} {1}', found, intVar);
61-
");
62-
63-
// create and populate a host array
64-
engine.Execute(@"
65-
numbers = host.newArr(lib.System.Int32, 20);
66-
for (var i = 0; i < numbers.Length; i++) { numbers[i] = i; }
67-
Console.WriteLine(lib.System.String.Join(', ', numbers));
68-
");
69-
70-
// create a script delegate
71-
engine.Execute(@"
72-
Filter = lib.System.Func(lib.System.Int32, lib.System.Boolean);
73-
oddFilter = new Filter(function(value) {
74-
return (value & 1) ? true : false;
75-
});
76-
");
77-
78-
// use LINQ from script
79-
engine.Execute(@"
80-
oddNumbers = numbers.Where(oddFilter);
81-
Console.WriteLine(lib.System.String.Join(', ', oddNumbers));
82-
");
83-
84-
// use a dynamic host object
85-
engine.Execute(@"
86-
expando = new lib.System.Dynamic.ExpandoObject();
87-
expando.foo = 123;
88-
expando.bar = 'qux';
89-
delete expando.foo;
90-
");
91-
92-
// call a script function
93-
engine.Execute("function print(x) { Console.WriteLine(x); }");
94-
engine.Script.print(DateTime.Now.DayOfWeek);
95-
96-
// examine a script object
97-
engine.Execute("person = { name: 'Fred', age: 5 }");
98-
Console.WriteLine(engine.Script.person.name);
99-
100-
// read a JavaScript typed array
101-
engine.Execute("values = new Int32Array([1, 2, 3, 4, 5])");
102-
var values = (ITypedArray<int>)engine.Script.values;
103-
Console.WriteLine(string.Join(", ", values.ToArray()));
104-
}
105-
```
106-
107-
# Tutorial
108-
A [PDF](https://en.wikipedia.org/wiki/Portable_Document_Format) tutorial is available [here](https://github.com/Microsoft/ClearScript/blob/master/ClearScript/doc/FAQtorial.pdf).
109-
110-
Click [here](https://github.com/Microsoft/ClearScript/raw/master/ClearScript/doc/FAQtorial.docx) to download a copy in [Word](https://en.wikipedia.org/wiki/Microsoft_Word) format.
111-
112-
# Reference
113-
Browse the ClearScript Library Reference [here](https://microsoft.github.io/ClearScript/Reference/index.html).
114-
115-
Click [here](https://github.com/Microsoft/ClearScript/raw/master/ClearScript/doc/Reference.chm) to download the reference in [CHM](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) format. If you get a security warning when you open this file, uncheck "Always ask before opening this file".
116-
117-
# Project Details
118-
See [here](https://github.com/Microsoft/ClearScript/blob/master/Build.txt) for information about building, integrating, and deploying ClearScript.
20+
# Documentation
21+
* [Examples](https://microsoft.github.io/ClearScript/Examples/Examples.html)
22+
* [Tutorial](https://microsoft.github.io/ClearScript/FAQtorial/FAQtorial.html)
23+
* [API reference](https://microsoft.github.io/ClearScript/Reference/index.html)
24+
* [Building, integrating, and deploying ClearScript](https://github.com/Microsoft/ClearScript/blob/master/Build.txt)

0 commit comments

Comments
 (0)