本文整理汇总了C#中Rhino.Context.GetElements方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetElements方法的具体用法?C# Context.GetElements怎么用?C# Context.GetElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rhino.Context
的用法示例。
在下文中一共展示了Context.GetElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunCommand
//.........这里部分代码省略.........
{
throw ReportRuntimeError("msg.runCommand.bad.env");
}
Scriptable envHash = (Scriptable)envObj;
object[] ids = ScriptableObject.GetPropertyIds(envHash);
environment = new string[ids.Length];
for (int i = 0; i != ids.Length; ++i)
{
object keyObj = ids[i];
object val;
string key;
if (keyObj is string)
{
key = (string)keyObj;
val = ScriptableObject.GetProperty(envHash, key);
}
else
{
int ikey = System.Convert.ToInt32(((Number)keyObj));
key = Sharpen.Extensions.ToString(ikey);
val = ScriptableObject.GetProperty(envHash, ikey);
}
if (val == ScriptableObject.NOT_FOUND)
{
val = Undefined.instance;
}
environment[i] = key + '=' + ScriptRuntime.ToString(val);
}
}
}
object inObj = ScriptableObject.GetProperty(@params, "input");
if (inObj != ScriptableConstants.NOT_FOUND)
{
@in = ToInputStream(inObj);
}
outObj = ScriptableObject.GetProperty(@params, "output");
if (outObj != ScriptableConstants.NOT_FOUND)
{
@out = ToOutputStream(outObj);
if (@out == null)
{
outBytes = new MemoryStream();
@out = outBytes;
}
}
errObj = ScriptableObject.GetProperty(@params, "err");
if (errObj != ScriptableConstants.NOT_FOUND)
{
err = ToOutputStream(errObj);
if (err == null)
{
errBytes = new MemoryStream();
err = errBytes;
}
}
object addArgsObj = ScriptableObject.GetProperty(@params, "args");
if (addArgsObj != ScriptableConstants.NOT_FOUND)
{
Scriptable s = Context.ToObject(addArgsObj, GetTopLevelScope(thisObj));
addArgs = cx.GetElements(s);
}
}
Rhino.Tools.Shell.Global global = GetInstance(funObj);
if (@out == null)
{
@out = (global != null) ? global.GetOut() : System.Console.Out;
}
if (err == null)
{
err = (global != null) ? global.GetErr() : System.Console.Error;
}
// If no explicit input stream, do not send any input to process,
// in particular, do not use System.in to avoid deadlocks
// when waiting for user input to send to process which is already
// terminated as it is not always possible to interrupt read method.
string[] cmd = new string[(addArgs == null) ? L : L + addArgs.Length];
for (int i_1 = 0; i_1 != L; ++i_1)
{
cmd[i_1] = ScriptRuntime.ToString(args[i_1]);
}
if (addArgs != null)
{
for (int i = 0; i_1 != addArgs.Length; ++i_1)
{
cmd[L + i_1] = ScriptRuntime.ToString(addArgs[i_1]);
}
}
int exitCode = RunProcess(cmd, environment, @in, @out, err);
if (outBytes != null)
{
string s = ScriptRuntime.ToString(outObj) + outBytes.ToString();
ScriptableObject.PutProperty(@params, "output", s);
}
if (errBytes != null)
{
string s = ScriptRuntime.ToString(errObj) + errBytes.ToString();
ScriptableObject.PutProperty(@params, "err", s);
}
return exitCode;
}
示例2: GetApplyArguments
internal static object[] GetApplyArguments(Context cx, object arg1)
{
if (arg1 == null || arg1 == Undefined.instance)
{
return ScriptRuntime.emptyArgs;
}
else
{
if (arg1 is NativeArray || arg1 is Arguments)
{
return cx.GetElements((Scriptable)arg1);
}
else
{
throw ScriptRuntime.TypeError0("msg.arg.isnt.array");
}
}
}
示例3: 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;
}