/// <inheritdoc/> public override void HandleCommandLocalizedString(StringFormatter formatter, StringBuilder output, StringSegment command, StringFormatterCommandArguments arguments, LocalizedString value) { var targetArgumentArg = arguments.GetArgument(0); var targetArgumentIndex = targetArgumentArg.GetValueAsInt32(); var targetMatchRuleArg = arguments.GetNextArgument(ref targetArgumentArg); var targetMatchRule = targetMatchRuleArg.Text; // Make sure our target is a localized string variant. var target = formatter.GetArgument(targetArgumentIndex); if (target.Reference == null || !(target.Reference is LocalizedStringVariant)) { throw new FormatException(CoreStrings.FmtCmdInvalidForArgument.Format("match", target.Reference?.GetType())); } // Run the specified match evaluator. var match = Localization.MatchVariant(value, (LocalizedStringVariant)target.Reference, targetMatchRule); output.Append(match ?? "???"); }
/// <summary> /// Handles a command which has an associated formatter argument value of <see cref="Int32"/> type. /// </summary> /// <param name="formatter">The formatter which is parsing the command.</param> /// <param name="output">The output buffer.</param> /// <param name="command">The name of the command being handled.</param> /// <param name="arguments">The arguments for the command being handled.</param> /// <param name="value">The command's associated value.</param> public virtual void HandleCommandInt32(StringFormatter formatter, StringBuilder output, StringSegment command, StringFormatterCommandArguments arguments, Int32 value) { throw new NotSupportedException(CoreStrings.FmtCmdInvalidForArgument.Format(command, typeof(Int32))); }
/// <summary> /// Handles a command which does not have an associated formatter argument value (that is, a command /// in the format of {foo} rather than {0:foo}). /// </summary> /// <param name="formatter">The formatter which is parsing the command.</param> /// <param name="output">The output buffer.</param> /// <param name="command">The name of the command being handled.</param> /// <param name="arguments">The arguments for the command being handled.</param> public virtual void HandleCommand(StringFormatter formatter, StringBuilder output, StringSegment command, StringFormatterCommandArguments arguments) { throw new NotSupportedException(CoreStrings.FmtCmdInvalidWithoutArgument.Format(command)); }