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


C# FlexWiki.ExecutionContext类代码示例

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


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

示例1: Expose

		public override IBELObject Expose(ExecutionContext ctx)
		{
			BELArray a = new BELArray();
			foreach (ExposableParseTreeNode each in _Array)
				a.Add(each.Expose(ctx));
			return a;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:7,代码来源:ArrayPTN.cs

示例2: ValueOf

		public IBELObject ValueOf(string symbol, ArrayList args, ExecutionContext ctx)
		{
			IBELObject answer = (IBELObject)_Table[symbol];
			if (answer == null)
				return null;		// not found
			if (args != null && args.Count > 0)
				throw new ExecutionException(symbol + " is a temporary variable, not a function; no arguments allowed");
			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:9,代码来源:BlockScope.cs

示例3: ValueOf

		public override IBELObject ValueOf(string name, System.Collections.ArrayList arguments, ExecutionContext ctx)
		{
			IBELObject answer = DynamicTopicFor(name);
			if (answer == null)
				return null;
			if (arguments != null && arguments.Count > 0)
				throw new ArgumentException("Arguments not allowed for topic names in namespaces");
			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:9,代码来源:DynamicNamespace.cs

示例4: ValueOf

 public IBELObject ValueOf(string symbol, ArrayList args, ExecutionContext ctx)
 {
     IBELObject answer;
     foreach (IValueSource each in _With)
     {
         answer = each.ValueOf(symbol, args,ctx);
         if (answer != null)
             return answer;
     }
     return null;
 }
开发者ID:nuxleus,项目名称:flexwikicore,代码行数:11,代码来源:WithScope.cs

示例5: 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

示例6: Expose

 public override IBELObject Expose(ExecutionContext ctx)
 {
     try
     {
         ctx.PushLocation(Location);
         return new BELString(Value);
     }
     finally
     {
         ctx.PopLocation();
     }
 }
开发者ID:nuxleus,项目名称:flexwikicore,代码行数:12,代码来源:StringPTN.cs

示例7: ValueOf

        public override IBELObject ValueOf(string name, System.Collections.ArrayList arguments, ExecutionContext ctx)
        {
            TopicPropertyCollection members = ctx.CurrentFederation.GetTopicProperties(Name);
            if (!members.Contains(name))
            {
                return null;
            }
            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,项目名称:flexwikicore,代码行数:53,代码来源:DynamicTopic.cs

示例8: Value

		public IBELObject Value(ExecutionContext ctx, ArrayList args)
		{
			if (ParseTree == null)
				return UndefinedObject.Instance;
			BlockScope blockScope = new BlockScope(ContainingScope);
			if (args != null)
			{
				if (args.Count != ParameterCount)
					throw new ArgumentException("Incorrect number of parameters for block.  Need " + ParameterCount + "; got " + args.Count);
				// Determine desired types
				ArrayList neededTypes = new ArrayList();
				foreach (BlockParameter parm in Parameters)
				{
					if (parm.TypeName == null) 
					{
						neededTypes.Add(null);	 // they said it could be anything
						continue;
					}
					BELType t = (BELType)(ctx.TypeRegistry.Registry[parm.TypeName]);
					if (t == null)
						throw new ArgumentException("Block parameter (" + parm.Identifier + ") requires unknown type (" + parm.TypeName + ")");
					neededTypes.Add(t);
				}

				// Check types, as requested
				ArrayList convertedArgs = new ArrayList();
				for(int i = 0; i < ParameterCount; i++)
				{
					BlockParameter bp = (BlockParameter)(Parameters[i]);
					convertedArgs.Add(BELType.ConvertToBELObjectIfNeeded(args[i]));
					if (bp.TypeName == null)
						continue; 	 // they said it could be anything
					IBELObject arg = (IBELObject)(convertedArgs[i]); 
					Type parmType = ((BELType)(neededTypes[i])).CLRType;
					if (!parmType.IsAssignableFrom(arg.GetType()))
						throw new MemberInvocationException(ctx.CurrentLocation, "Block parameter " + bp.Identifier + " is not of the correct type (was " 
							+ ExternalTypeNameForType(arg.GetType()) + 
							", but needed " + ExternalTypeNameForType(parmType) + ")");
				}
				
				// OK, we have them and they're type correct and converted to CLR types where needed.  Add them into the block scope
				for(int i = 0; i < ParameterCount; i++)
				{
					BlockParameter bp = (BlockParameter)(Parameters[i]);
					blockScope.AddParameter(bp.Identifier, (IBELObject)(convertedArgs[i]));
				}
			}
			ctx.PushScope(blockScope);
			IBELObject answer = ParseTree.Expose(ctx);
			ctx.PopScope();
			return answer;
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:52,代码来源:Block.cs

示例9: ComboSelectField

		public static FormSelectFieldPresentation ComboSelectField(ExecutionContext context, string fieldName, ArrayList options,
			[ExposedParameter(true)] string selectedOption, [ExposedParameter(true)] ArrayList values,
			[ExposedParameter(true)] object selectedValue)
		{
			if (true == context.TopFrame.WasParameterSupplied(4))
			{
				if (options.Count != values.Count)
				{
					throw new ArgumentException("The values array does not contain the same number of items as the options array", "values");
				}
			}
			return new FormSelectFieldPresentation(fieldName, 1, false, options, selectedOption, values, selectedValue);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:13,代码来源:Presentations.cs

示例10: Expose

		public override IBELObject Expose(ExecutionContext ctx)
		{
			ArrayList parameters = null;

			if (Parameters != null)
			{
				parameters = new ArrayList();
				foreach (BlockParameterPTN p in Parameters.Parameters)
				{
					parameters.Add(new BlockParameter(p.Type, p.Identifier));
				}
			}
			return new Block(ParseTree, parameters, ctx.CurrentScope);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:14,代码来源:BlockPTN.cs

示例11: Instance

		public static DateTime Instance(ExecutionContext ctx, int year, int month, int day, 
			[ExposedParameter(true)] int hour, [ExposedParameter(true)] int minute, 
			[ExposedParameter(true)] int second, [ExposedParameter(true)] int millisecond)
		{
			if (false == ctx.TopFrame.WasParameterSupplied(4))
				hour = 0;
			if (false == ctx.TopFrame.WasParameterSupplied(5))
				minute = 0;
			if (false == ctx.TopFrame.WasParameterSupplied(6))
				second = 0;
			if (false == ctx.TopFrame.WasParameterSupplied(7))
				millisecond = 0;
			return Instance2(year, month, day, hour, minute, second, millisecond);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:14,代码来源:BELDateTime.cs

示例12: Instance

		public static TimeSpan Instance(ExecutionContext ctx, [ExposedParameter(true)] int days, 
			[ExposedParameter(true)] int hours, [ExposedParameter(true)] int minutes, 
			[ExposedParameter(true)] int seconds, [ExposedParameter(true)]int milliseconds)
		{
			if (false == ctx.TopFrame.WasParameterSupplied(1))
				days = 0;
			if (false == ctx.TopFrame.WasParameterSupplied(2))
				hours = 0;
			if (false == ctx.TopFrame.WasParameterSupplied(3))
				minutes = 0;
			if (false == ctx.TopFrame.WasParameterSupplied(4))
				seconds = 0;
			if (false == ctx.TopFrame.WasParameterSupplied(5))
				milliseconds = 0;

			return Instance2(days, hours, minutes, seconds, milliseconds);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:17,代码来源:BELTimeSpan.cs

示例13: button3_Click

		private void button3_Click(object sender, System.EventArgs e)
		{
			Federation fed = new Federation(textBoxFederationPath.Text, OutputFormat.Testing, null);
			BehaviorInterpreter interpreter = new BehaviorInterpreter("Input Form", textBoxInput.Text, CurrentFederation, 1, this);
					
			ClearCacheView();

			if (Parse(interpreter) == null)
			{
				Fail("Unable to run; parse failed:" + interpreter.ErrorString);
				tabControl.SelectedTab = tabParser;
			}

			// Begin execution
			tabControl.SelectedTab = tabOutput;
			ExecutionContext ctx = new ExecutionContext(CurrentTopicContext);
			string final = null;
			if (!interpreter.EvaluateToPresentation(CurrentTopicContext, new Hashtable()))
			{
				Fail(interpreter.ErrorString);
				return;
			}
			WikiOutput output = WikiOutput.ForFormat(OutputFormat.Testing, null);
			interpreter.Value.ToPresentation(this).OutputTo(output);
			final = output.ToString();
			Success(final);
			UpdateCacheView(interpreter.CacheRules);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:28,代码来源:Form1.cs

示例14: ValueOf

		public IBELObject ValueOf(string name, ArrayList arguments, ExecutionContext ctx)
		{
			BELMember mi = Type.BELMembers[name] as BELMember;
			if (mi== null)
				return null;

			ParameterInfo []parms = mi.MethodInfo.GetParameters();
			int need = parms.Length;
			int got = (arguments == null) ? 0 : arguments.Count;
			bool needExecutionContext = mi.NeedsExecutionContext;
			if (needExecutionContext && (parms.Length == 0 || parms[0].ParameterType != typeof(ExecutionContext)))
				throw new ImplementationException("Incorrectly defined ExposedMethod property or function.  First parameter of " + mi.MethodInfo.DeclaringType.FullName + "." + mi.MethodInfo.Name + " must be an ExecutionContext");
			if (needExecutionContext)
				need--;
			if (got > need && !(mi.ExposedMethod.AllowsVariableArguments))
				throw new MemberInvocationException(ctx.CurrentLocation, "Incorrect number of arguments (too many) for " + ExternalTypeName + "." + name + " (need " + need + ", got " + got + ")");

			// Figure out what arguments we should be passing
			ArrayList args = new ArrayList();
			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) + ")");
			}

//.........这里部分代码省略.........
开发者ID:nuxleus,项目名称:flexwiki,代码行数:101,代码来源:ReflectedValueSource.cs

示例15: Label

		public static LabelPresentation Label(ExecutionContext ctx, string forId, string text, [ExposedParameter(true)] string attributes)
		{
			return new LabelPresentation(forId, text, attributes);
		}
开发者ID:nuxleus,项目名称:flexwiki,代码行数:4,代码来源:Presentations.cs


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