本文整理汇总了C#中Rhino.Context类的典型用法代码示例。如果您正苦于以下问题:C# Context类的具体用法?C# Context怎么用?C# Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Context类属于Rhino命名空间,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public object Run(Context cx)
{
Scriptable scope = cx.InitStandardObjects();
object rep = cx.EvaluateString(scope, source, "test.js", 0, null);
NUnit.Framework.Assert.AreEqual(expected, rep);
return null;
}
示例2: Action
public virtual object Action(Context cx, Scriptable scope, Scriptable thisObj, object[] args, int actionType)
{
GlobData data = new GlobData();
data.mode = actionType;
switch (actionType)
{
case RegExpProxyConstants.RA_MATCH:
{
object rval;
data.optarg = 1;
rval = MatchOrReplace(cx, scope, thisObj, args, this, data, false);
return data.arrayobj == null ? rval : data.arrayobj;
}
case RegExpProxyConstants.RA_SEARCH:
{
data.optarg = 1;
return MatchOrReplace(cx, scope, thisObj, args, this, data, false);
}
case RegExpProxyConstants.RA_REPLACE:
{
object arg1 = args.Length < 2 ? Undefined.instance : args[1];
string repstr = null;
Function lambda = null;
if (arg1 is Function)
{
lambda = (Function)arg1;
}
else
{
repstr = ScriptRuntime.ToString(arg1);
}
data.optarg = 2;
data.lambda = lambda;
data.repstr = repstr;
data.dollar = repstr == null ? -1 : repstr.IndexOf('$');
data.charBuf = null;
data.leftIndex = 0;
object val = MatchOrReplace(cx, scope, thisObj, args, this, data, true);
if (data.charBuf == null)
{
if (data.global || val == null || !val.Equals(true))
{
return data.str;
}
SubString lc = this.leftContext;
Replace_glob(data, cx, scope, this, lc.index, lc.length);
}
SubString rc = this.rightContext;
data.charBuf.AppendRange(rc.str, rc.index, rc.index + rc.length);
return data.charBuf.ToString();
}
default:
{
throw Kit.CodeBug();
}
}
}
示例3: RunFileIfExists
private static void RunFileIfExists(Context cx, Scriptable global, FilePath f)
{
if (f.IsFile())
{
Main.ProcessFileNoThrow(cx, global, f.GetPath());
}
}
示例4: Construct
public override Scriptable Construct(Context cx, Scriptable scope, object[] args)
{
NativeRegExp re = new NativeRegExp();
re.Compile(cx, scope, args);
ScriptRuntime.SetBuiltinProtoAndParent(re, scope, TopLevel.Builtins.RegExp);
return re;
}
示例5: Run
public object Run(Context cx)
{
cx.GetWrapFactory().SetJavaPrimitiveWrap(false);
NUnit.Framework.Assert.AreEqual("string[]", cx.EvaluateString(cx.InitStandardObjects(), "new org.mozilla.javascript.tests.Bug496585Test().method('one', 'two', 'three')", "<test>", 1, null));
NUnit.Framework.Assert.AreEqual("string+function", cx.EvaluateString(cx.InitStandardObjects(), "new org.mozilla.javascript.tests.Bug496585Test().method('one', function() {})", "<test>", 1, null));
return null;
}
示例6: Run
public object Run(Context _cx)
{
ScriptableObject scope = _cx.InitStandardObjects();
object result = _cx.EvaluateString(scope, script, "test script", 0, null);
NUnit.Framework.Assert.AreEqual("b1,b2,a0,a1,,a3", Context.ToString(result));
return null;
}
示例7: HasFeature
protected internal override bool HasFeature(Context cx, int featureIndex)
{
switch (featureIndex)
{
case Context.FEATURE_STRICT_VARS:
case Context.FEATURE_STRICT_EVAL:
case Context.FEATURE_STRICT_MODE:
{
return strictMode;
}
case Context.FEATURE_RESERVED_KEYWORD_AS_IDENTIFIER:
{
return allowReservedKeywords;
}
case Context.FEATURE_WARNING_AS_ERROR:
{
return warningAsError;
}
case Context.FEATURE_LOCATION_INFORMATION_IN_ERROR:
{
return generatingDebug;
}
}
return base.HasFeature(cx, featureIndex);
}
示例8: CreateSpecial
internal static Ref CreateSpecial(Context cx, object @object, string name)
{
Scriptable target = ScriptRuntime.ToObjectOrNull(cx, @object);
if (target == null)
{
throw ScriptRuntime.UndefReadError(@object, name);
}
int type;
if (name.Equals("__proto__"))
{
type = SPECIAL_PROTO;
}
else
{
if (name.Equals("__parent__"))
{
type = SPECIAL_PARENT;
}
else
{
throw new ArgumentException(name);
}
}
if (!cx.HasFeature(Context.FEATURE_PARENT_PROTO_PROPERTIES))
{
// Clear special after checking for valid name!
type = SPECIAL_NONE;
}
return new Rhino.SpecialRef(target, type, name);
}
示例9: Get
public override object Get(Context cx)
{
switch (type)
{
case SPECIAL_NONE:
{
return ScriptRuntime.GetObjectProp(target, name, cx);
}
case SPECIAL_PROTO:
{
return target.GetPrototype();
}
case SPECIAL_PARENT:
{
return target.GetParentScope();
}
default:
{
throw Kit.CodeBug();
}
}
}
示例10: Run
public object Run(Context cx)
{
ScriptableObject top = cx.InitStandardObjects();
ScriptableObject.PutProperty(top, "foo", foo);
cx.EvaluateString(top, script, "script", 0, null);
return null;
}
示例11: CreateFunction
/// <summary>Create function compiled from Function(...) constructor.</summary>
/// <remarks>Create function compiled from Function(...) constructor.</remarks>
internal static Rhino.InterpretedFunction CreateFunction(Context cx, Scriptable scope, InterpreterData idata, object staticSecurityDomain)
{
Rhino.InterpretedFunction f;
f = new Rhino.InterpretedFunction(idata, staticSecurityDomain);
f.InitScriptFunction(cx, scope);
return f;
}
示例12: Call
/// <seealso cref="Function.Call(Context, Scriptable, Scriptable, object[])">Function.Call(Context, Scriptable, Scriptable, object[])</seealso>
public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args)
{
object sync = syncObject != null ? syncObject : thisObj;
lock (sync is Wrapper ? ((Wrapper)sync).Unwrap() : sync)
{
return ((Function)obj).Call(cx, scope, thisObj, args);
}
}
示例13: Construct
public override Scriptable Construct(Context cx, Scriptable scope, object[] extraArgs)
{
if (targetFunction is Function)
{
return ((Function)targetFunction).Construct(cx, scope, Concat(boundArgs, extraArgs));
}
throw ScriptRuntime.TypeError0("msg.not.ctor");
}
示例14: Call
public override object Call(Context cx, Scriptable scope, Scriptable thisObj, object[] args)
{
if (script != null)
{
return script.Exec(cx, scope);
}
return Undefined.instance;
}
示例15: Run
public object Run(Context cx)
{
Scriptable scope1 = cx.InitStandardObjects(new PrimitiveTypeScopeResolutionTest.MySimpleScriptableObject("scope1"));
Scriptable scope2 = cx.InitStandardObjects(new PrimitiveTypeScopeResolutionTest.MySimpleScriptableObject("scope2"));
cx.EvaluateString(scope2, scriptScope2, "source2", 1, null);
scope1.Put("scope2", scope1, scope2);
return cx.EvaluateString(scope1, scriptScope1, "source1", 1, null);
}