本文整理汇总了C#中Rant.Engine.Sandbox类的典型用法代码示例。如果您正苦于以下问题:C# Sandbox类的具体用法?C# Sandbox怎么用?C# Sandbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sandbox类属于Rant.Engine命名空间,在下文中一共展示了Sandbox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearTarget
private static void ClearTarget(Sandbox sb,
[RantDescription("The name of the target to be cleared.")]
string targetName)
{
sb.Output.Do(chain => chain.ClearTarget(targetName));
}
示例2: PrintEmoji
private static void PrintEmoji(Sandbox sb,
[RantDescription("The emoji shortcode to use, without colons.")]
string shortcode)
{
shortcode = shortcode.ToLower();
if(!Emoji.Shortcodes.ContainsKey(shortcode))
{
sb.Print("[missing emoji]");
return;
}
sb.Print(Char.ConvertFromUtf32(Emoji.Shortcodes[shortcode]));
}
示例3: Plural
private static void Plural(Sandbox sb, string word)
{
sb.Print(sb.Format.Pluralizer.Pluralize(word));
}
示例4: Emdash
private static void Emdash(Sandbox sb) => sb.Print("\x2014");
示例5: Bullet
private static void Bullet(Sandbox sb) => sb.Print("\x2022");
示例6: PatternArg
private static void PatternArg(Sandbox sb,
[RantDescription("The name of the argument to access.")]
string argName)
{
if (sb.PatternArgs == null) return;
sb.Output.Print(sb.PatternArgs[argName]);
}
示例7: RegisteredTrademark
private static void RegisteredTrademark(Sandbox sb) => sb.Print("\x00ae");
示例8: Import
private static IEnumerator<RantAction> Import(Sandbox sb,
[RantDescription("The name or path of the pattern to load.")]
string name)
{
RantAction action;
try
{
action = sb.Engine.GetPattern(name).Action;
}
catch (RantCompilerException e)
{
throw new RantRuntimeException(sb.Pattern, sb.CurrentAction.Range,
$"Failed to compile imported pattern '{name}':\n{e.Message}");
}
catch (Exception e)
{
throw new RantRuntimeException(sb.Pattern, sb.CurrentAction.Range,
$"Failed to import '{name}':\n{e.Message}");
}
yield return action;
}
示例9: Define
private static void Define(Sandbox sb,
[RantDescription("The list of flags to define.")]
params string[] flags)
{
foreach (var flag in flags.Where(f => !Util.IsNullOrWhiteSpace(f) && Util.ValidateName(f)))
{
sb.Engine.Flags.Add(flag);
}
}
示例10: End
private static void End(Sandbox sb,
[RantDescription("The pattern to run after the next block.")]
RantAction endPattern)
{
sb.CurrentBlockAttribs.End = endPattern;
}
示例11: Persist
private static void Persist(Sandbox sb, AttribPersistence persistence)
{
sb.CurrentBlockAttribs.Persistence = persistence;
}
示例12: Start
private static void Start(Sandbox sb,
[RantDescription("The pattern to run before the next block.")]
RantAction beforePattern)
{
sb.CurrentBlockAttribs.Start = beforePattern;
}
示例13: NotNthO
private static IEnumerator<RantAction> NotNthO(Sandbox sb,
[RantDescription("The interval at which the pattern should not be run.")]
int interval,
[RantDescription("The number of iterations to offset the interval by.")]
int offset,
[RantDescription("The pattern to run when the condition is satisfied.")]
RantAction pattern)
{
if (!sb.Blocks.Any()) yield break;
if (Util.Mod(sb.Blocks.Peek().Iteration - offset, interval) == 0) yield break;
yield return pattern;
}
示例14: NotNth
private static IEnumerator<RantAction> NotNth(Sandbox sb,
[RantDescription("The interval at which the pattern should not be run.")]
int interval,
[RantDescription("The pattern to run when the condition is satisfied.")]
RantAction pattern)
{
if (!sb.Blocks.Any()) yield break;
if (sb.Blocks.Peek().Iteration % interval == 0) yield break;
yield return pattern;
}
示例15: Branch
private static IEnumerator<RantAction> Branch(Sandbox sb, string id, RantAction branchAction)
{
sb.RNG.Branch(id.Hash());
yield return branchAction;
sb.RNG.Merge();
}