AutoCatAvalonia/AutoCatCore/Model/PlateNumber.cs

35 lines
840 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace AutoCatCore.Model;
public class PlateNumber
{
private readonly string _number;
private readonly string _numberEnglish;
private readonly Dictionary<char, char> _lettersMap = new()
{
{ 'А', 'A' }, { 'В', 'B' }, { 'Е', 'E' }, { 'К', 'K' },
{ 'М', 'M' }, { 'Н', 'H' }, { 'О', 'O' }, { 'Р', 'P' },
{ 'С', 'C' }, { 'Т', 'T' }, { 'У', 'Y' }, { 'Х', 'X' }
};
public PlateNumber(string number)
{
this._number = number;
this._numberEnglish = string.Concat(number.Select(c => _lettersMap.TryGetValue(c, out var eng) ? eng : c));
}
public string AsString()
{
return _number;
}
public string MainPart()
{
return _numberEnglish[..6];
}
public string Region()
{
return _numberEnglish[6..];
}
}