AutoCatUwp/AutoCat/Controls/PlateNumber.cs

47 lines
1.3 KiB
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.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation.Metadata;
namespace AutoCat.Controls
{
[CreateFromString(MethodName = "AutoCat.Controls.PlateNumber.ConvertFromString")]
public class PlateNumber
{
private string number;
private string numberEnglish;
public Dictionary<Char, Char> lettersMap = new Dictionary<Char, Char> { { 'А', '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 Char eng) ? eng : c));
}
public string AsString()
{
return number;
}
public string MainPart()
{
return numberEnglish.Substring(0, 6);
}
public string Region()
{
return numberEnglish.Substring(6);
}
public static PlateNumber ConvertFromString(string number)
{
return new PlateNumber(number);
}
}
}