This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
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.
Merge pull request #30 from BlossomiShymae/issue-26-extension-methods
Add extension methods for type enums
- Loading branch information
Showing
20 changed files
with
532 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace BlossomiShymae.RiotBlossom.Converter | ||
{ | ||
internal interface IConverter<T, U> | ||
{ | ||
T Convert(U value); | ||
U Convert(T value); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
BlossomiShymae.RiotBlossom/Converter/PlatformAbbreviationConverter.cs
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Converter | ||
{ | ||
internal class PlatformAbbreviationConverter : IConverter<Platform, string> | ||
{ | ||
public Platform Convert(string value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string Convert(Platform value) | ||
{ | ||
return value switch | ||
{ | ||
Platform.Brazil => "BR", | ||
Platform.EuropeNordicEast => "EUNE", | ||
Platform.EuropeWest => "EUW", | ||
Platform.LatinAmericaNorth => "LAN", | ||
Platform.LatinAmericaSouth => "LAS", | ||
Platform.NorthAmerica => "NA", | ||
Platform.Oceania => "OCE", | ||
Platform.Russia => "RU", | ||
Platform.Turkey => "TR", | ||
Platform.Japan => "JP", | ||
Platform.Korea => "KR", | ||
Platform.Philippines => "PH", | ||
Platform.Singapore => "SG", | ||
Platform.Taiwan => "TW", | ||
Platform.Thailand => "TH", | ||
Platform.Vietnam => "VN", | ||
_ => throw new NotImplementedException("Abbreviation is not yet added for this platform!") | ||
}; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
BlossomiShymae.RiotBlossom/Converter/PlatformDefaultLocaleConverter.cs
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Converter | ||
{ | ||
internal class PlatformDefaultLocaleConverter : IConverter<Platform, string> | ||
{ | ||
public Platform Convert(string value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string Convert(Platform value) | ||
{ | ||
return value switch | ||
{ | ||
Platform.Brazil => "pt_BR", | ||
Platform.EuropeNordicEast => "en_GB", | ||
Platform.EuropeWest => "en_GB", | ||
Platform.Japan => "ja_JP", | ||
Platform.Korea => "ko_KR", | ||
Platform.LatinAmericaNorth => "es_MX", | ||
Platform.LatinAmericaSouth => "es_AR", | ||
Platform.NorthAmerica => "en_US", | ||
Platform.Oceania => "en_AU", | ||
Platform.Russia => "ru_RU", | ||
Platform.Turkey => "tr_TR", | ||
Platform.Philippines => "en_PH", | ||
Platform.Singapore => "en_SG", | ||
Platform.Thailand => "th_TH", | ||
Platform.Taiwan => "zn_TW", | ||
Platform.Vietnam => "vn_VN", | ||
_ => throw new NotImplementedException("Default locale is not yet added for this platform!") | ||
}; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
BlossomiShymae.RiotBlossom/Converter/PlatformPrettyNameConverter.cs
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Converter | ||
{ | ||
internal class PlatformPrettyNameConverter : IConverter<Platform, string> | ||
{ | ||
public Platform Convert(string value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string Convert(Platform value) | ||
{ | ||
return value switch | ||
{ | ||
Platform.Brazil => "Brazil", | ||
Platform.EuropeNordicEast => "Europe Nordic and East", | ||
Platform.EuropeWest => "Europe West", | ||
Platform.LatinAmericaNorth => "Latin America North", | ||
Platform.LatinAmericaSouth => "Latin America South", | ||
Platform.NorthAmerica => "North America", | ||
Platform.Oceania => "Oceania", | ||
Platform.Russia => "Russia", | ||
Platform.Turkey => "Turkey", | ||
Platform.Korea => "Republic of Korea", | ||
Platform.Philippines => "The Philippines", | ||
Platform.Singapore => "Singapore, Malaysia, and Indonesia", | ||
Platform.Taiwan => "Taiwan, Hong Kong, and Macao", | ||
Platform.Thailand => "Thailand", | ||
Platform.Vietnam => "Vietnam", | ||
_ => throw new NotImplementedException("Pretty name is not yet added for this platform!") | ||
}; | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
BlossomiShymae.RiotBlossom/Converter/RegionPrettyNameConverter.cs
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Converter | ||
{ | ||
internal class RegionPrettyNameConverter : IConverter<Region, string> | ||
{ | ||
public Region Convert(string value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string Convert(Region value) | ||
{ | ||
return value switch | ||
{ | ||
Region.Americas => "Americas", | ||
Region.Asia => "Asia", | ||
Region.SouthEastAsia => "Southeast Asia", | ||
Region.Europe => "Europe", | ||
_ => throw new NotImplementedException("Pretty name is not implemented for region!") | ||
}; | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
BlossomiShymae.RiotBlossom/Converter/ValRegionAbbreviationConverter.cs
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Converter | ||
{ | ||
internal class ValRegionAbbreviationConverter : IConverter<ValRegion, string> | ||
{ | ||
public ValRegion Convert(string value) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string Convert(ValRegion value) | ||
{ | ||
return value switch | ||
{ | ||
ValRegion.NorthAmerica => "NA", | ||
ValRegion.Brazil => "BR", | ||
ValRegion.Korea => "KR", | ||
ValRegion.AsiaPacific => "AP", | ||
ValRegion.LatinAmerica => "LATAM", | ||
ValRegion.Europe => "EU", | ||
_ => throw new NotImplementedException("Abbreviation is not yet added for VALORANT region!") | ||
}; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
BlossomiShymae.RiotBlossom/Extensions/LeagueDivisionExtensions.cs
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class LeagueDivisionExtensions | ||
{ | ||
/// <summary> | ||
/// Get the associated raw value e.g. "I", "II", "III", "IV". | ||
/// </summary> | ||
/// <param name="leagueDivision"></param> | ||
/// <returns></returns> | ||
public static string GetValue(this LeagueDivision leagueDivision) | ||
{ | ||
return LeagueDivisionMapper.GetValue(leagueDivision); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
BlossomiShymae.RiotBlossom/Extensions/LeagueQueueExtensions.cs
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class LeagueQueueExtensions | ||
{ | ||
/// <summary> | ||
/// Get the associated raw value e.g. "RANKED_SOLO_5x5". | ||
/// </summary> | ||
/// <param name="leagueQueue"></param> | ||
/// <returns></returns> | ||
public static string GetValue(this LeagueQueue leagueQueue) | ||
{ | ||
return LeagueQueueMapper.GetValue(leagueQueue); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
BlossomiShymae.RiotBlossom/Extensions/LeagueTierExtensions.cs
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class LeagueTierExtensions | ||
{ | ||
/// <summary> | ||
/// Get the associated raw value e.g. "IRON", "BRONZE". | ||
/// </summary> | ||
/// <param name="leagueTier"></param> | ||
/// <returns></returns> | ||
public static string GetValue(this LeagueTier leagueTier) | ||
{ | ||
return LeagueTierMapper.GetValue(leagueTier); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
BlossomiShymae.RiotBlossom/Extensions/LorRegionExtensions.cs
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class LorRegionExtensions | ||
{ | ||
/// <summary> | ||
/// Get the raw routing value e.g. "americas", "sea". | ||
/// </summary> | ||
/// <param name="lorRegion"></param> | ||
/// <returns></returns> | ||
public static string GetId(this LorRegion lorRegion) | ||
{ | ||
return LorRegionMapper.GetId(lorRegion); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
BlossomiShymae.RiotBlossom/Extensions/PlatformExtensions.cs
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using BlossomiShymae.RiotBlossom.Converter; | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class PlatformExtensions | ||
{ | ||
private static readonly PlatformAbbreviationConverter s_abbreviationConverter = new(); | ||
private static readonly PlatformPrettyNameConverter s_prettyNameConverter = new(); | ||
private static readonly PlatformDefaultLocaleConverter s_defaultLocaleConverter = new(); | ||
|
||
/// <summary> | ||
/// Get an abbreviation of platform e.g. "NA", "LAS", "EUNE", "JP". | ||
/// </summary> | ||
/// <param name="platform"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public static string GetAbbreviation(this Platform platform) | ||
=> s_abbreviationConverter.Convert(platform); | ||
|
||
/// <summary> | ||
/// Get the pretty name of platform e.g. "Europe Nordic and East". | ||
/// </summary> | ||
/// <param name="platform"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public static string GetPrettyName(this Platform platform) | ||
=> s_prettyNameConverter.Convert(platform); | ||
|
||
/// <summary> | ||
/// Get the associated <see cref="Region"/>. | ||
/// </summary> | ||
/// <param name="platform"></param> | ||
/// <returns></returns> | ||
public static Region GetRegion(this Platform platform) | ||
{ | ||
return PlatformToRegionConverter.ToRegion(platform); | ||
} | ||
|
||
/// <summary> | ||
/// Get the raw identifier value e.g. "na1", "euw1". | ||
/// </summary> | ||
/// <param name="platform"></param> | ||
/// <returns></returns> | ||
public static string GetId(this Platform platform) | ||
{ | ||
return PlatformMapper.GetId(platform); | ||
} | ||
|
||
/// <summary> | ||
/// Get the associated <see cref="Region"/> identifier value e.g. "americas", "europe". | ||
/// </summary> | ||
/// <param name="platform"></param> | ||
/// <returns></returns> | ||
public static string GetRegionId(this Platform platform) | ||
{ | ||
return platform.GetRegion().GetId(); | ||
} | ||
|
||
/// <summary> | ||
/// Get the default locale e.g. "ja_JP", "en_GB", "ko_KR". | ||
/// </summary> | ||
/// <param name="platform"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public static string GetDefaultLocale(this Platform platform) | ||
=> s_defaultLocaleConverter.Convert(platform); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using BlossomiShymae.RiotBlossom.Converter; | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class RegionExtensions | ||
{ | ||
private static readonly RegionPrettyNameConverter s_prettyNameConverter = new(); | ||
|
||
/// <summary> | ||
/// Get the raw identifier value e.g. "americas", "europe". | ||
/// </summary> | ||
/// <param name="region"></param> | ||
/// <returns></returns> | ||
public static string GetId(this Region region) | ||
{ | ||
return RegionMapper.GetId(region); | ||
} | ||
|
||
/// <summary> | ||
/// Get the pretty name of region e.g. "Americas", "Asia". | ||
/// </summary> | ||
/// <param name="region"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public static string GetPrettyName(this Region region) | ||
=> s_prettyNameConverter.Convert(region); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
BlossomiShymae.RiotBlossom/Extensions/TftLeagueQueueExtensions.cs
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class TftLeagueQueueExtensions | ||
{ | ||
/// <summary> | ||
/// Get the associated raw value e.g. "RANKED_TFT_TURBO". | ||
/// </summary> | ||
/// <param name="tftLeagueQueue"></param> | ||
/// <returns></returns> | ||
public static string GetValue(this TftLeagueQueue tftLeagueQueue) | ||
{ | ||
return TftLeagueQueueMapper.GetValue(tftLeagueQueue); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
BlossomiShymae.RiotBlossom/Extensions/ValRegionExtensions.cs
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using BlossomiShymae.RiotBlossom.Converter; | ||
using BlossomiShymae.RiotBlossom.Core; | ||
using BlossomiShymae.RiotBlossom.Type; | ||
|
||
namespace BlossomiShymae.RiotBlossom.Extensions | ||
{ | ||
public static class ValRegionExtensions | ||
{ | ||
private static readonly ValRegionAbbreviationConverter s_abbreviationConverter = new(); | ||
|
||
/// <summary> | ||
/// Get an abbreviation of a VALORANT region e.g. "NA", "AP", "LATAM". | ||
/// </summary> | ||
/// <param name="valRegion"></param> | ||
/// <returns></returns> | ||
/// <exception cref="NotImplementedException"></exception> | ||
public static string GetAbbreviation(this ValRegion valRegion) | ||
=> s_abbreviationConverter.Convert(valRegion); | ||
|
||
/// <summary> | ||
/// Get the raw routing value e.g. "na", "ap", "latam". | ||
/// </summary> | ||
/// <param name="valRegion"></param> | ||
/// <returns></returns> | ||
public static string GetId(this ValRegion valRegion) | ||
{ | ||
return ValRegionMapper.GetId(valRegion); | ||
} | ||
} | ||
} |
Oops, something went wrong.