FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
ClearScriptForUnity3d/ClearScript/Extensions.cs at Unity3D · vovgou/ClearScriptForUnity3d · GitHub
vovgou
/
ClearScriptForUnity3d
Public
forked from
ClearFoundry/ClearScript
Notifications
You must be signed in to change notification settings
Fork
2
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
ClearScriptForUnity3d
/
ClearScript
/
Extensions.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (61 loc) · 3 KB
Breadcrumbs
ClearScriptForUnity3d
/
ClearScript
/
Extensions.cs
Copy path
File metadata and controls
66 lines (61 loc) · 3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using
System
;
using
Microsoft
.
ClearScript
.
Util
;
namespace
Microsoft
.
ClearScript
{
/// <summary>
/// Defines extension methods for use with all script engines.
/// </summary>
public
static
class
Extensions
{
/// <summary>
/// Converts a type to a host type for use with script code currently running on the
/// calling thread.
/// </summary>
/// <param name="type">The type to convert to a host type.</param>
/// <returns>A host type for use with script code.</returns>
public
static
object
ToHostType
(
this
Type
type
)
{
return
type
.
ToHostType
(
ScriptEngine
.
Current
)
;
}
/// <summary>
/// Converts a type to a host type for use with script code running in the specified
/// script engine.
/// </summary>
/// <param name="type">The type to convert to a host type.</param>
/// <param name="engine">The script engine in which the host type will be used.</param>
/// <returns>A host type for use with script code.</returns>
public
static
object
ToHostType
(
this
Type
type
,
ScriptEngine
engine
)
{
MiscHelpers
.
VerifyNonNullArgument
(
type
,
nameof
(
type
)
)
;
MiscHelpers
.
VerifyNonNullArgument
(
engine
,
nameof
(
engine
)
)
;
return
HostItem
.
Wrap
(
engine
,
HostType
.
Wrap
(
type
)
)
;
}
/// <summary>
/// Converts an object to a host object with the specified type restriction, for use with
/// script code currently running on the calling thread.
/// </summary>
/// <typeparam name="T">The type whose members are to be made accessible from script code.</typeparam>
/// <param name="target">The object to convert to a host object for use with script code.</param>
/// <returns>A host object with the specified type restriction.</returns>
public
static
object
ToRestrictedHostObject
<
T
>
(
this
T
target
)
{
return
target
.
ToRestrictedHostObject
(
ScriptEngine
.
Current
)
;
}
/// <summary>
/// Converts an object to a host object with the specified type restriction, for use with
/// script code running in the specified script engine.
/// </summary>
/// <typeparam name="T">The type whose members are to be made accessible from script code.</typeparam>
/// <param name="target">The object to convert to a host object for use with script code.</param>
/// <param name="engine">The script engine in which the host object will be used.</param>
/// <returns>A host object with the specified type restriction.</returns>
public
static
object
ToRestrictedHostObject
<
T
>
(
this
T
target
,
ScriptEngine
engine
)
{
MiscHelpers
.
VerifyNonNullArgument
(
target
,
nameof
(
target
)
)
;
MiscHelpers
.
VerifyNonNullArgument
(
engine
,
nameof
(
engine
)
)
;
return
HostItem
.
Wrap
(
engine
,
target
,
typeof
(
T
)
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL