private void DetectAirlineFromCycleCodes() { if (!_IsAirlineDetected && _AreCycleCodesDetected) { foreach (string cycleCode in _CycleCodes) { if (CycleValidator.ValidateAirlineCodeCycle(cycleCode)) { //Airline detected _AirlineCode = cycleCode.Substring(0, 2); //Must be a valid airline code (CycleValidator checks this) for (int i = 0; i < Globals.AirlineClients.GetLength(0); i++) { if (_AirlineCode == Globals.AirlineClients[i][0]) { _Airline = Globals.AirlineClients[i][1]; } } _IsAirlineDetected = true; return; } } } }
private void SetCycle() { _Cycle = ""; if (_AreCycleCodesDetected) { foreach (string cycleCode in _CycleCodes) { if (CycleValidator.Validate4DigitCycle(cycleCode)) { _Cycle = cycleCode; return; } else if (CycleValidator.ValidateAirlineCodeCycle(cycleCode)) { _Cycle = cycleCode.Substring(2, 4); return; } } } }
private void DetectCycleTokens() { _AreCycleCodesDetected = false; List <string> filePathTokens = new Tokens(_NoDiacriticsSubDirectoriesFilePath, TokenType.FilePath).GetTokens; foreach (string filePathtoken in filePathTokens) { bool isValidCycleToken = false; if (CycleValidator.Validate4DigitCycle(filePathtoken)) { isValidCycleToken = true; } else if (CycleValidator.ValidateYear(filePathtoken)) { string yearSearchText = @"\" + filePathtoken + @"\"; //Trying to get the year directory specifically, thus the backslashes. Not a year that is part of the Album/Track text for example. if (FindToken(yearSearchText, _NormalizedSubDirectoriesPath, false)) { isValidCycleToken = true; } } else if (CycleValidator.ValidateAirlineCodeCycle(filePathtoken)) { isValidCycleToken = true; } if (isValidCycleToken) { if (!_CycleCodes.Any(code => code == filePathtoken)) { _CycleCodes.Add(filePathtoken); } } } if (!_IsAirlineDetected || _CycleCodes.Any(code => code.Length == 6)) { if (_CycleCodes.Count > 0) { _CycleCodes = _CycleCodes.OrderByDescending(code => code.Length).ThenBy(code => code).ToList(); _AreCycleCodesDetected = true; } return; } foreach (string cycleCode in _CycleCodes) { if (CycleValidator.Validate4DigitCycle(cycleCode)) { string airlineCycle = _AirlineCode + cycleCode; if (FindToken(airlineCycle, _NormalizedSubDirectoriesFilePath, false)) { if (!_CycleCodes.Any(code => code == airlineCycle)) { _CycleCodes.Add(airlineCycle); } if (_CycleCodes.Count > 0) { _CycleCodes = _CycleCodes.OrderByDescending(code => code.Length).ThenBy(code => code).ToList(); _AreCycleCodesDetected = true; } return; } } } if (_CycleCodes.Count > 0) { _CycleCodes = _CycleCodes.OrderByDescending(code => code.Length).ThenBy(code => code).ToList(); _AreCycleCodesDetected = true; } return; }