Ejemplo n.º 1
0
        private static string ReplaceSystem(IBag bag, string text, string token)
        {
            bag.Logger.StartSection("ReplaceSystem " + token);
            string systemtoken = GetSeparatedPart(token, "|", 2).ToLowerInvariant();
            string format      = GetSeparatedPart(token, "|", 3);

            bag.Logger.Log($"SystemToken: {systemtoken} Format: {format}");

            string value = "";

            switch (systemtoken.ToUpperInvariant())
            {
            case "NOW":
                value = SystemNow(format);
                break;

            case "TODAY":
                value = SystemToday(format);
                break;

            case "USER":
                value = bag.SystemUser(format);
                break;

            case "CHAR":
                value = SystemChars(format);
                break;

            default:
                throw new InvalidPluginExecutionException("Unknown system token: " + systemtoken);
            }

            bag.Logger.Log($"Replacing <{token}> with {value}");
            bag.Logger.EndSection();
            return(text.ReplaceFirstOnly("<" + token + ">", value));
        }