本文整理匯總了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();
}