Skip to content

Commit

Permalink
Add implementation for LanguageCode class
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyaulee committed Jun 12, 2021
1 parent b66c14b commit 81e85da
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/WebExtensions.Net/Extensions/I18n/LanguageCode.cs
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);
}
}

0 comments on commit 81e85da

Please sign in to comment.