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


C# ExecutionContext.PushFrame方法代码示例

本文整理汇总了C#中FlexWiki.ExecutionContext.PushFrame方法的典型用法代码示例。如果您正苦于以下问题:C# ExecutionContext.PushFrame方法的具体用法?C# ExecutionContext.PushFrame怎么用?C# ExecutionContext.PushFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FlexWiki.ExecutionContext的用法示例。


在下文中一共展示了ExecutionContext.PushFrame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValueOf


//.........这里部分代码省略.........
			InvocationFrame invocationFrame = new InvocationFrame();
			if (needExecutionContext)
				args.Add(ctx);
			
			ArrayList parameterPresentFlags = null;
			if (needExecutionContext)
			{
				parameterPresentFlags = new ArrayList();
				parameterPresentFlags.Add(true);		// we know for sure the first arg is supplied; it's the execution context :-)					
			}
			int offset = (needExecutionContext ? 1 : 0);
			for (int each = offset; each < parms.Length; each++)
			{
				object arg = null;
				
				if (arguments != null && (each - offset) < arguments.Count)
					arg = (ParseTreeNode)(arguments[each - offset]);
				if (!BELMember.IsOptionalParameter(parms[each]) && arg == null)
					throw new MemberInvocationException(ctx.CurrentLocation, "Missing argument " + (each - offset) + " for " + ExternalTypeName + "." + name);
				if (parameterPresentFlags != null)
					parameterPresentFlags.Add(arg != null);
				if (mi.ExposedMethod.IsCustomArgumentProcessor)
				{
					args.Add(arg);
				}
				else
				{
					if (arg == null)
						args.Add(AbsentValueForParameter(parms[each]));
					else
						args.Add(ConvertFromBELObjectIfNeeded(((ExposableParseTreeNode)arg).Expose(ctx)));
				}
			}
			invocationFrame.WasParameterSuppliedFlags = parameterPresentFlags;

			// If we have extras (beyond those needed) and they're allowed, stash them in the MIC, too
			if (mi.ExposedMethod.AllowsVariableArguments)
			{
				ArrayList extras = new ArrayList();
				int extraCount = got - need;
				if (arguments != null)
				{
					for (int i = need; i < got; i++)
					{
						object arg = arguments[i];
						if (mi.ExposedMethod.IsCustomArgumentProcessor)
						{
							extras.Add(arg);
						}
						else
						{
							if (arg == null)
								extras.Add(null);
							else
								extras.Add(ConvertFromBELObjectIfNeeded(((ExposableParseTreeNode)arg).Expose(ctx)));
						}
					}						
				}
				invocationFrame.ExtraArguments = extras;
			}

			// Check types
			for (int each = 0; each < parms.Length; each++)
			{
				bool bad = false;
				if (args[each] == null)
				{
					if (parms[each].ParameterType.IsValueType)
						bad = true;
				}
				else
				{
					if (!parms[each].ParameterType.IsAssignableFrom(args[each].GetType()))
						bad = true;
				}
				if (bad)
					throw new MemberInvocationException(ctx.CurrentLocation, "Argument " + (each + 1) + " for " + ExternalTypeName + "." + name + " is not of the correct type (was " 
						+ ExternalTypeNameForType(args[each].GetType()) + 
						", but needed " + ExternalTypeNameForType(parms[each].ParameterType) + ")");
			}

			// And now, invoke away!!
			object result = null;
			invocationFrame.PushScope(ctx.CurrentScope); // the new frame starts with the same scope as this one
			ctx.PushFrame(invocationFrame);
			if (Federation.GetPerformanceCounter(Federation.PerformanceCounterNames.MethodInvocation) != null)
				Federation.GetPerformanceCounter(Federation.PerformanceCounterNames.MethodInvocation).Increment();
			try
			{
				result = mi.MethodInfo.Invoke(this, args.ToArray());
			}
			catch (TargetInvocationException ex)
			{
				throw ex.InnerException;
			}
			ctx.PopFrame();
			if (mi.ExposedMethod.CachePolicy == ExposedMethodFlags.CachePolicyNever)
				ctx.AddCacheRule(new CacheRuleNever());
			return Wrap(result);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:101,代码来源:ReflectedValueSource.cs

示例2: ValueOf

		public override IBELObject ValueOf(string name, System.Collections.ArrayList arguments, ExecutionContext ctx)
		{
			Hashtable members = ctx.CurrentFederation.GetTopicProperties(Name);
			string val = (string)(members[name]);
			if (val == null)
				return null;
			val = val.Trim();
			bool isBlock = val.StartsWith("{");
			if (!isBlock)
				return new BELString(val);
			// It's a block, so fire up the interpreter
			if (!val.EndsWith("}"))
				throw new ExecutionException("Topic member " + name + " defined in " + Name.Fullname + " is not well-formed; missing closing '}' for code block.");
			ContentBase cb = CurrentFederation.ContentBaseForTopic(Name);
			TopicContext newContext = new TopicContext(ctx.CurrentFederation, cb, CurrentTopicInfo);
			BehaviorInterpreter interpreter = new BehaviorInterpreter(val, CurrentFederation, CurrentFederation.WikiTalkVersion, ctx.Presenter);
			if (!interpreter.Parse())
				throw new ExecutionException("Parsing error evaluating topic member " + name + " defined in " + Name.Fullname + ": " + interpreter.ErrorString);
			
			IBELObject b1 = interpreter.EvaluateToObject(newContext, ctx.ExternalWikiMap);
			if (b1 == null)
				throw new ExecutionException("Error while evaluating topic member " + name + " defined in " + Name.Fullname + ": " + interpreter.ErrorString);
			Block block = (Block)b1;
			ArrayList evaluatedArgs = new ArrayList();
			foreach (object each in arguments)
			{
				IBELObject add = null;
				if (each != null && each is IBELObject)
					add = each as IBELObject;
				else
				{
					ExposableParseTreeNode ptn = each as ExposableParseTreeNode;
					add = ptn.Expose(ctx);
				}
				evaluatedArgs.Add(add);
			}

			InvocationFrame invocationFrame = new InvocationFrame();
			ctx.PushFrame(invocationFrame);

			TopicScope topicScope = new TopicScope(null, this);
			ctx.PushScope(topicScope);		// make sure we can use local references
			IBELObject answer = block.Value(ctx, evaluatedArgs);
			ctx.PopScope();

			ctx.PopFrame();

			// make sure to transfer any new cache rules
			// BELTODO - want a test case for this 
			foreach (CacheRule r in interpreter.CacheRules)
				ctx.AddCacheRule(r);

			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:54,代码来源:DynamicTopic.cs

示例3: ValueOf

        public override IBELObject ValueOf(string name, System.Collections.ArrayList arguments, ExecutionContext ctx)
        {
            TopicPropertyCollection members = ctx.CurrentFederation.GetTopicProperties(Name);
            string val = members[name].LastValue;
            if (val == null)
                return null;
            val = val.Trim();
            bool isBlock = val.StartsWith("{");
            if (!isBlock)
                return new BELString(val);
            // It's a block, so fire up the interpreter
            if (!val.EndsWith("}"))
                throw new ExecutionException(ctx.CurrentLocation, "Topic member " + name + " defined in " + Name.DottedName + " is not well-formed; missing closing '}' for code block.");
            NamespaceManager cb = CurrentFederation.NamespaceManagerForTopic(Name);
            TopicContext newContext = new TopicContext(ctx.CurrentFederation, cb, CurrentTopicInfo);
            BehaviorInterpreter interpreter = new BehaviorInterpreter(Name.DottedName + "#" + name, val, CurrentFederation, CurrentFederation.WikiTalkVersion, ctx.Presenter);
            if (!interpreter.Parse())
                throw new ExecutionException(ctx.CurrentLocation, "Syntax error in " + interpreter.ErrorString);

            IBELObject b1 = interpreter.EvaluateToObject(newContext, ctx.ExternalWikiMap);
            if (b1 == null)
                throw new ExecutionException(ctx.CurrentLocation, "Execution error in " + interpreter.ErrorString);
            Block block = (Block) b1;
            ArrayList evaluatedArgs = new ArrayList();
            foreach (object each in arguments)
            {
                IBELObject add = null;
                if (each != null && each is IBELObject)
                    add = each as IBELObject;
                else
                {
                    ExposableParseTreeNode ptn = each as ExposableParseTreeNode;
                    add = ptn.Expose(ctx);
                }
                evaluatedArgs.Add(add);
            }

            InvocationFrame invocationFrame = new InvocationFrame();
            ctx.PushFrame(invocationFrame);

            TopicScope topicScope = new TopicScope(null, this);
            ctx.PushScope(topicScope);		// make sure we can use local references
            IBELObject answer = block.Value(ctx, evaluatedArgs);
            ctx.PopScope();

            ctx.PopFrame();

            return answer;
        }
开发者ID:nuxleus,项目名称:flexwiki,代码行数:49,代码来源:DynamicTopic.cs


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