Beispiel #1
0
 /// <summary>
 /// Check wheter the Plate is following the Brazillian new MercoSul pattern
 /// </summary>
 /// <returns>True if it is following the Brazilling new MercoSul pattern</returns>
 public bool IsBrazilMercoSul()
 {
     return(Plate.IsBrazilMercoSul(this.value));
 }
Beispiel #2
0
        /// <summary>
        /// Convert and old pattern plate to the Brazillian MercoSul pattern
        /// </summary>
        /// <param name="value">The Plate's value following the old ABC-1234 pattern</param>
        /// <returns>The Plate's value following the new ABC1D23 pattern</returns>
        public static string ConvertToBrazilMercoSul(string value)
        {
            if (!Plate.IsValid(value))
            {
                throw new System.ArgumentException(Resources.GetString("plate", "ImplicitStringOperator"));
            }

            if (Plate.IsBrazilMercoSul(value))
            {
                return(value.Trim().ToUpper());
            }

            var           match = Regex.Match(value, Plate.regexUnformattedOldPlate);
            StringBuilder str   = new StringBuilder(match.Value.Substring(0, 4));

            switch (match.Value.Substring(4, 1))
            {
            case "0":
                str.Append("A");
                break;

            case "1":
                str.Append("B");
                break;

            case "2":
                str.Append("C");
                break;

            case "3":
                str.Append("D");
                break;

            case "4":
                str.Append("E");
                break;

            case "5":
                str.Append("F");
                break;

            case "6":
                str.Append("G");
                break;

            case "7":
                str.Append("H");
                break;

            case "8":
                str.Append("I");
                break;

            case "9":
                str.Append("J");
                break;

            default:
                throw new System.ArgumentException(Resources.GetString("plate", "ImplicitStringOperator"));
            }

            str.Append(match.Value.Substring(5, 2));

            return(str.ToString());
        }