AcManager.Pages.Dialogs.UpgradeIconEditor.TryToGuessLabel C# (CSharp) Метод

TryToGuessLabel() приватный Метод

private TryToGuessLabel ( string carName ) : string
carName string
Результат string
        public static string TryToGuessLabel(string carName) {
            if (carName == null) return null;
            if (Regex.IsMatch(carName, @"\b(?:drift|d(?:\s*|-)spec)\b", RegexOptions.IgnoreCase)) return "D";
            if (Regex.IsMatch(carName, @"\b(?:s|step|stage)\s*3\b", RegexOptions.IgnoreCase)) return "S3";
            if (Regex.IsMatch(carName, @"\b(?:s|step|stage)\s*2\b", RegexOptions.IgnoreCase)) return "S2";
            if (Regex.IsMatch(carName, @"\b(?:s|step|stage)\s*1\b", RegexOptions.IgnoreCase)) return "S1";
            if (Regex.IsMatch(carName, @"\b(?:race|hotlap)\b", RegexOptions.IgnoreCase)) return "Race";
            if (Regex.IsMatch(carName, @"\b(?:turbo)\b", RegexOptions.IgnoreCase)) return "Turbo";
            return null;
        }

Usage Example

        public UpgradeIconEditor_Editor()
        {
            var mainDialog = UpgradeIconEditor.Instance;

            if (mainDialog != null)
            {
                Car  = mainDialog.Car;
                _key = @"__upgradeiconeditor_" + Car.Id;
            }

            DataContext = this;
            InitializeComponent();

            NewIconLabel.Text = _key != null?ValuesStorage.Get(_key, UpgradeIconEditor.TryToGuessLabel(Car?.DisplayName)) ?? "S1" : @"?";

            NewIconLabel_UpdateFontSize();

            FocusLabel();
        }