当前位置: 首页>>代码示例>>C#>>正文


C# Rhino.Context类代码示例

本文整理汇总了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;
			}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:FunctionTest.cs

示例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();
				}
			}
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:60,代码来源:RegExpImpl.cs

示例3: RunFileIfExists

		private static void RunFileIfExists(Context cx, Scriptable global, FilePath f)
		{
			if (f.IsFile())
			{
				Main.ProcessFileNoThrow(cx, global, f.GetPath());
			}
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:ShellTest.cs

示例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;
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:NativeRegExpCtor.cs

示例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;
			}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:Bug496585Test.cs

示例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;
			}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:ArrayConcatTest.cs

示例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);
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:28,代码来源:ShellContextFactory.cs

示例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);
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:30,代码来源:SpecialRef.cs

示例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();
				}
			}
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:25,代码来源:SpecialRef.cs

示例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;
			}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:7,代码来源:WriteReadOnlyPropertyTest.cs

示例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;
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:9,代码来源:InterpretedFunction.cs

示例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);
			}
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:9,代码来源:Synchronizer.cs

示例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");
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:BoundFunction.cs

示例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;
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:NativeScript.cs

示例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);
			}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:8,代码来源:PrimitiveTypeScopeResolutionTest.cs


注:本文中的Rhino.Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。