Ejemplo n.º 1
0
    public static string Format(DyObject obj, ExecutionContext ctx, bool notype = false, int maxLen = 0)
    {
        string fmt;

        try
        {
            fmt = obj.ToLiteral(ctx).ToString();
        }
        catch (Exception ex)
        {
            return($"Formatting failed:\n{(ex is DyCodeException c ? c.ToString() : ex.Message)}");
        }

        if (maxLen > 0 && fmt.Length > maxLen)
        {
            fmt = fmt[..maxLen] + "...";