本文整理汇总了C#中System.Function.GetParentScope方法的典型用法代码示例。如果您正苦于以下问题:C# Function.GetParentScope方法的具体用法?C# Function.GetParentScope怎么用?C# Function.GetParentScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Function
的用法示例。
在下文中一共展示了Function.GetParentScope方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Spawn
/// <summary>
/// The spawn function runs a given function or script in a different
/// thread.
/// </summary>
/// <remarks>
/// The spawn function runs a given function or script in a different
/// thread.
/// js> function g() { a = 7; }
/// js> a = 3;
/// 3
/// js> spawn(g)
/// Thread[Thread-1,5,main]
/// js> a
/// 3
/// </remarks>
public static object Spawn(Context cx, Scriptable thisObj, object[] args, Function funObj)
{
Scriptable scope = funObj.GetParentScope();
Runner runner;
if (args.Length != 0 && args[0] is Function)
{
object[] newArgs = null;
if (args.Length > 1 && args[1] is Scriptable)
{
newArgs = cx.GetElements((Scriptable)args[1]);
}
if (newArgs == null)
{
newArgs = ScriptRuntime.emptyArgs;
}
runner = new Runner(scope, (Function)args[0], newArgs);
}
else
{
if (args.Length != 0 && args[0] is Script)
{
runner = new Runner(scope, (Script)args[0]);
}
else
{
throw ReportRuntimeError("msg.spawn.args");
}
}
runner.factory = cx.GetFactory();
Sharpen.Thread thread = new Sharpen.Thread(runner);
thread.Start();
return thread;
}
示例2: GetInstance
private static Rhino.Tools.Shell.Global GetInstance(Function function)
{
Scriptable scope = function.GetParentScope();
if (!(scope is Rhino.Tools.Shell.Global))
{
throw ReportRuntimeError("msg.bad.shell.function.scope", scope.ToString());
}
return (Rhino.Tools.Shell.Global)scope;
}