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


C# Sandbox.Print方法代码示例

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


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

示例1: Run

		public override IEnumerator<RantAction> Run(Sandbox sb)
		{
			foreach (RichActionBase action in Group.Actions)
				yield return action;
            if (sb.ScriptObjectStack.Any())
            {
                var obj = sb.ScriptObjectStack.Pop();
                if (obj is RichList)
                {
                    var list = (obj as RichList);
                    // don't make a block from a list with zero items
                    if (list.Items.Count == 0)
                        yield break;
                    List<RantAction> actions = new List<RantAction>();
                    foreach (RichActionBase action in list.Items)
                    {
                        yield return action;
                        var item = sb.ScriptObjectStack.Pop();
                        if (item is RichPatternString)
                            actions.Add((item as RichPatternString).Pattern.Action);
                        else
                            actions.Add(new RAText(action.Range, item.ToString()));
                    }
                    yield return new RABlock(list.Range, actions.ToArray());
                }
                else if (obj is RichPatternString)
                    yield return (obj as RichPatternString).Pattern.Action;
                else if (obj is bool)
                    sb.Print((bool)obj ? "true" : "false");
                else if(!(obj is RantObject && (obj as RantObject).Type == RantObjectType.Undefined))
                    sb.Print(obj);
            }
			yield break;
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:34,代码来源:RAExpression.cs

示例2: Run

		public override IEnumerator<RantAction> Run(Sandbox sb)
		{
			sb.AddOutputWriter();
			yield return _sourceAction;
			var input = sb.Return().Main;
			var matches = _regex.Matches(input);
			int start = 0;
			foreach (Match match in matches)
			{
				sb.RegexMatches.Push(match);
				sb.AddOutputWriter();
				yield return _matchEvalAction;
				var result = sb.Return().Main;
                sb.Print(input.Substring(start, match.Index - start));
				sb.Print(result);
                sb.RegexMatches.Pop();
				start = match.Index + match.Length;
			}
			sb.Print(input.Substring(start, input.Length - start));
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:20,代码来源:RAReplacer.cs

示例3: Run

        public override IEnumerator<RantAction> Run(Sandbox sb)
		{
			var attribs = sb.NextAttribs(this);

			// Skip if chance doesn't fall within range
			if (attribs.Chance < 100 && sb.RNG.NextDouble(0, 100) > attribs.Chance)
			{
				yield break;
			}

			int next = -1;
			int reps = attribs.RepEach ? _items.Count : attribs.Repetitions;
			var block = new BlockState(attribs.Repetitions);
			double weightSum = _constantWeightSum;

			if (attribs.Start != null) yield return attribs.Start;

			if (_weighted && attribs.Sync == null)
			{
				foreach (var dw in _dynamicWeights)
				{
					sb.AddOutputWriter();
					yield return dw.Item2;
					var strWeight = sb.Return().Main;
					if (!Double.TryParse(strWeight, out _weights[dw.Item1]))
						throw new RantRuntimeException(sb.Pattern, dw.Item2.Range,
							$"Dynamic weight returned invalid weight value: '{strWeight}'");
					weightSum += _weights[dw.Item1];
				}
			}
	        
			sb.Blocks.Push(block);
			for (int i = 0; i < reps; i++)
			{
				if (_weighted)
				{
					double choice = sb.RNG.NextDouble(weightSum);
					for (int j = 0; j < _count; j++)
					{
						if (choice < _weights[j])
						{
							next = j;
							break;
						}
						choice -= _weights[j];
					}
				}
				else
				{
					next = attribs.NextIndex(_count, sb.RNG);
				}

				if (next == -1) break;
				block.Next(next);

				sb.Blocks.Pop(); // Don't allow separator to access block state
				// Separator
				if (i > 0 && attribs.Separator != null)
				{
					if (attribs.IsSeries)
					{
						// Check if we're on the last separator in a series
						if (i == reps - 1)
						{
							// Add the oxford comma if specified
							if (attribs.EndSeparator != null)
							{
								// If there are more than two items, print it!
								if (reps > 2) yield return attribs.EndSeparator;
							}

							sb.Print(sb.Format.StandardSpace);

							// Add conjunction if specified (it normally should be, if it's a series)
							if (attribs.EndConjunction != null)
							{
								yield return attribs.EndConjunction;
								sb.Print(sb.Format.StandardSpace);
							}
						}
						else if (reps > 2)
						{
							yield return attribs.Separator;
							sb.Print(sb.Format.StandardSpace);
						}
					}
					else
					{
						yield return attribs.Separator;
					}
				}
				sb.Blocks.Push(block); // Now put it back

				// Prefix
				if (attribs.Before != null) yield return attribs.Before;

				// Content
				sb.Objects.EnterScope();
				yield return _items[next];
				sb.Objects.ExitScope();
//.........这里部分代码省略.........
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:101,代码来源:RABlock.cs

示例4: Run

		public override IEnumerator<RantAction> Run(Sandbox sb)
		{
			sb.Print(_text);
			yield break;
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:5,代码来源:RAText.cs

示例5: Run

		public override IEnumerator<RantAction> Run(Sandbox sb)
		{
			if (_unicode)
			{
				sb.Print(new string(_code, _times));
			}
			else
			{
				Action<Sandbox, int> func;
				if (!EscapeTable.TryGetValue(_code, out func))
				{
					sb.Print(new string(_code, _times));
				}
				else
				{
					func(sb, _times);
				}
			}
			yield break;
		}
开发者ID:W-h-a-t-s,项目名称:Rant,代码行数:20,代码来源:RAEscape.cs


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