public static string WrapString(this string s, TextEnclosures wrapper, NullValueOptions nullOptions)
        {
            if (s == null)
            {
                switch (nullOptions)
                {
                case NullValueOptions.None:
                    return(null);

                case NullValueOptions.UseEmptyString:
                    return(string.Empty.WrapString(wrapper));

                case NullValueOptions.UsePlaceholderValue:
                    return(NullPlaceholder);

                default:
                    throw new InvalidEnumArgumentException(nameof(nullOptions), (int)nullOptions, typeof(NullValueOptions));
                }
            }
            switch (wrapper)
            {
            case TextEnclosures.None:
                return(s);

            case TextEnclosures.CurlyBrackets:
                return("{" + s + "}");

            case TextEnclosures.SquareBrackets:
                return("[" + s + "]");

            case TextEnclosures.AngleBrackets:
                return("<" + s + ">");

            case TextEnclosures.Parentheses:
                return("(" + s + ")");

            case TextEnclosures.DoubleQuotes:
                return("\"" + s + "\"");

            case TextEnclosures.SingleQuotes:
                return("'" + s + "'");

            default:
                throw new NotImplementedException($"No wrapping has been defined for {wrapper} yet.");
            }
        }
        public static string WrapString(this string s, TextEnclosures wrapper, string nullStringValue, bool overrideNullStringWrapperType = true)
        {
            if (nullStringValue == null)
            {
                throw new ArgumentNullException(nameof(nullStringValue));
            }

            if (s == null)
            {
                if (overrideNullStringWrapperType)
                {
                    return(nullStringValue.WrapString(wrapper));
                }
                return(nullStringValue.WrapString(NullableTypeWrapper));
            }
            return(s.WrapString(wrapper));
        }
 public static string WrapString(this string s, TextEnclosures wrapper)
 {
     return(s.WrapString(wrapper, NullValueOptions.UsePlaceholderValue));
 }
 private static Func <object, string> GenerateToStringFunction(this MethodInfo info, TextEnclosures wrapper = TextEnclosures.None)
 {
     return(((Expression <Func <object, string> >)(o => o == null ? NullPlaceholder : (info.Invoke(o, null) as string).WrapString(wrapper))).Compile());
 }