Code Review 2
This commit is contained in:
1 parent
9158a69b62
commit
368280fcb5
8 files changed
+54
-45
No files matched your search
@@ -6,8 +6,7 @@ public static class EscapeUtils {
|
||||
/// <summary>
|
||||
/// WPF XML 转义。
|
||||
/// </summary>
|
||||
public static string? XmlEscape(string? str) {
|
||||
if (str is null) return null;
|
||||
public static string XmlEscape(string str) {
|
||||
if (str.StartsWithF("{")) str = "{}" + str; // #4187
|
||||
return str
|
||||
.Replace("&", "&").Replace("<", "<").Replace(">", ">").Replace("'", "'")
|
||||
@@ -34,7 +33,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="Regex.Escape"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? RegexEscape(string value)
|
||||
public static string RegexEscape(string value)
|
||||
=> Regex.Escape(value);
|
||||
|
||||
/// <summary>
|
||||
@@ -42,7 +41,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="Regex.Unescape"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? RegexUnescape(string value)
|
||||
public static string RegexUnescape(string value)
|
||||
=> Regex.Unescape(value);
|
||||
|
||||
/// <summary>
|
||||
@@ -50,7 +49,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="Uri.EscapeDataString"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? UrlEscape(string value)
|
||||
public static string UrlEscape(string value)
|
||||
=> Uri.EscapeDataString(value);
|
||||
|
||||
/// <summary>
|
||||
@@ -58,7 +57,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="Uri.UnescapeDataString"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? UrlUnescape(string value)
|
||||
public static string UrlUnescape(string value)
|
||||
=> Uri.UnescapeDataString(value);
|
||||
|
||||
/// <summary>
|
||||
@@ -66,7 +65,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="WebUtility.UrlEncode"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? FormUrlEscape(string value)
|
||||
public static string FormUrlEscape(string value)
|
||||
=> WebUtility.UrlEncode(value);
|
||||
|
||||
/// <summary>
|
||||
@@ -74,7 +73,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="WebUtility.UrlDecode"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? FormUrlUnescape(string value)
|
||||
public static string FormUrlUnescape(string value)
|
||||
=> WebUtility.UrlDecode(value);
|
||||
|
||||
/// <summary>
|
||||
@@ -82,7 +81,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="WebUtility.HtmlEncode"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? HtmlEscape(string value)
|
||||
public static string HtmlEscape(string value)
|
||||
=> WebUtility.HtmlEncode(value);
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +89,7 @@ public static class EscapeUtils {
|
||||
/// 等同于 <see cref="WebUtility.HtmlDecode"/>。
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static string? HtmlUnescape(string value)
|
||||
public static string HtmlUnescape(string value)
|
||||
=> WebUtility.HtmlDecode(value);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user