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


C# Function.GetParentScope方法代码示例

本文整理汇总了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&gt; function g() { a = 7; }
		/// js&gt; a = 3;
		/// 3
		/// js&gt; spawn(g)
		/// Thread[Thread-1,5,main]
		/// js&gt; 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;
		}
开发者ID:hazzik,项目名称:Rhino.Net,代码行数:48,代码来源:Global.cs

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


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