-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to .NET8 only to draw benefits of newer version C# language. Signed-off-by: Jiri Slachta <[email protected]>
- Loading branch information
Showing
9 changed files
with
454 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
using LocaleNames.Enumerations; | ||
using System; | ||
|
||
namespace LocaleNames.Extensions | ||
namespace LocaleNames.Extensions; | ||
|
||
/// <summary> | ||
/// Extension methods for the enum <see cref="AltVariant"/>. | ||
/// </summary> | ||
internal static class AltVariantExtensions | ||
{ | ||
/// <summary> | ||
/// Extension methods for the enum <see cref="AltVariant"/>. | ||
/// Gets the locale postfix. | ||
/// </summary> | ||
internal static class AltVariantExtensions | ||
/// <param name="variant">The variant.</param> | ||
/// <returns></returns> | ||
public static string GetLocalePostfix(this AltVariant variant) | ||
{ | ||
/// <summary> | ||
/// Gets the locale postfix. | ||
/// </summary> | ||
/// <param name="variant">The variant.</param> | ||
/// <returns></returns> | ||
public static string GetLocalePostfix(this AltVariant variant) | ||
switch (variant) | ||
{ | ||
switch (variant) | ||
{ | ||
case AltVariant.Alternative: | ||
return "-alt-variant"; | ||
case AltVariant.Short: | ||
return "-alt-short"; | ||
case AltVariant.Long: | ||
return "-alt-long"; | ||
case AltVariant.Menu: | ||
return "-alt-menu"; | ||
default: | ||
case AltVariant.Common: | ||
return string.Empty; | ||
} | ||
case AltVariant.Alternative: | ||
return "-alt-variant"; | ||
case AltVariant.Short: | ||
return "-alt-short"; | ||
case AltVariant.Long: | ||
return "-alt-long"; | ||
case AltVariant.Menu: | ||
return "-alt-menu"; | ||
default: | ||
case AltVariant.Common: | ||
return string.Empty; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,42 @@ | ||
using System; | ||
using LocaleNames.Enumerations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using LocaleNames.Enumerations; | ||
|
||
namespace LocaleNames.Extensions | ||
namespace LocaleNames.Extensions; | ||
|
||
/// <summary> | ||
/// The string extensions. | ||
/// </summary> | ||
public static class StringExtensions | ||
{ | ||
/// <summary> | ||
/// The string extensions. | ||
/// Determines whether the provided country code is continent. | ||
/// </summary> | ||
public static class StringExtensions | ||
/// <param name="countryCode">The country code</param> | ||
/// <returns>Returns true if countryCode is continent, otherwise false.</returns> | ||
public static bool IsCountryCodeContinent(this string countryCode) | ||
{ | ||
/// <summary> | ||
/// Determines whether the provided country code is continent. | ||
/// </summary> | ||
/// <param name="countryCode">The country code</param> | ||
/// <returns>Returns true if countryCode is continent, otherwise false.</returns> | ||
public static bool IsCountryCodeContinent(this string countryCode) | ||
{ | ||
if (string.IsNullOrWhiteSpace(countryCode)) return false; | ||
if (string.IsNullOrWhiteSpace(countryCode)) return false; | ||
|
||
return int.TryParse(countryCode, out _); | ||
} | ||
return int.TryParse(countryCode, out _); | ||
} | ||
|
||
/// <summary> | ||
/// Strips the locale variants from the given string. | ||
/// </summary> | ||
/// <param name="inputText">The text.</param> | ||
/// <returns>The stripped locale variant</returns> | ||
public static string StripLocaleVariants(this string inputText) | ||
/// <summary> | ||
/// Strips the locale variants from the given string. | ||
/// </summary> | ||
/// <param name="inputText">The text.</param> | ||
/// <returns>The stripped locale variant</returns> | ||
public static string StripLocaleVariants(this string inputText) | ||
{ | ||
foreach (AltVariant suit in (AltVariant[])Enum.GetValues(typeof(AltVariant))) | ||
{ | ||
foreach (AltVariant suit in (AltVariant[])Enum.GetValues(typeof(AltVariant))) | ||
if (!string.IsNullOrWhiteSpace(suit.GetLocalePostfix()) && inputText.Contains(suit.GetLocalePostfix())) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(suit.GetLocalePostfix()) && inputText.Contains(suit.GetLocalePostfix())) | ||
{ | ||
inputText = inputText.Replace(suit.GetLocalePostfix(), ""); | ||
} | ||
inputText = inputText.Replace(suit.GetLocalePostfix(), string.Empty); | ||
} | ||
|
||
return inputText; | ||
} | ||
|
||
return inputText; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.