-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implementation for LanguageCode class
- Loading branch information
1 parent
b66c14b
commit 81e85da
Showing
1 changed file
with
25 additions
and
0 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,25 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace WebExtensions.Net.I18n | ||
{ | ||
[JsonConverter(typeof(MultiTypeJsonConverter<LanguageCode>))] | ||
public partial class LanguageCode : BaseMultiTypeObject | ||
{ | ||
private readonly string valueString; | ||
|
||
/// <summary>Creates a new instance of <see cref="LanguageCode" />.</summary> | ||
/// <param name="value">The value.</param> | ||
public LanguageCode(string value) : base(value, typeof(string)) | ||
{ | ||
valueString = value; | ||
} | ||
|
||
/// <summary>Converts from <see cref="LanguageCode" /> to <see cref="string" />.</summary> | ||
/// <param name="value">The value to convert from.</param> | ||
public static implicit operator string(LanguageCode value) => value.valueString; | ||
|
||
/// <summary>Converts from <see cref="string" /> to <see cref="LanguageCode" />.</summary> | ||
/// <param name="value">The value to convert from.</param> | ||
public static implicit operator LanguageCode(string value) => new(value); | ||
} | ||
} |