/// <summary> /// Verifies that properties and attributes have been used correctly, based on certain rules enforced to guarantee that unintended behavior & usage doesn't occur at scale. /// </summary> /// <param name="el"></param> public void ValidatePropertiesAndAttributes(GameElement el) { if (ElementPool.FindAll(x => !string.IsNullOrEmpty(el.Id) && x.GetComponent <GameElement>() && x.GetComponent <GameElement>().Id == el.Id).Count > 1) { logger.LogError($"Multiple elements have the same \"Id\" of \"{el.Id}\". The Id attribute must be unique."); } }
public static string GetStringFromCustomSettings(string key) { AQALogger logger = new AQALogger(); AutomationSet keyVal = settings.Configs.Find(x => x.Key == key); if (keyVal == default(AutomationSet) || string.IsNullOrEmpty(keyVal.Key)) { logger.LogError($"Key requested ({key}) which is not defined in the settings file or is invalid.{(hostPlatform == HostPlatform.Cloud ? " Make sure you are supplying the expected settings config file name to DeviceFarmConfig." : string.Empty)}"); } return(keyVal.Value); }
public static bool GetBooleanFromCustomSettings(string key) { AQALogger logger = new AQALogger(); AutomationSet keyVal = settings.Configs.Find(x => x.Key == key); bool returnVal = false; if (keyVal == default(AutomationSet) || !bool.TryParse(keyVal.Value, out returnVal)) { logger.LogError($"Key requested ({key}) which is not defined in the settings file or is invalid.{(hostPlatform == HostPlatform.Cloud ? " Make sure you are supplying the expected settings config file name to DeviceFarmConfig." : string.Empty)}"); } return(returnVal); }
/// <summary> /// Take multi-part query strings and break them into list of all individual pieces/filters. /// </summary> /// <param name="querySelector"></param> /// <returns></returns> private static List <string> BreakdownQuery(string querySelector) { AQALogger logger = new AQALogger(); List <string> returnValues = new List <string>(); char[] characters = querySelector.ToCharArray(); int startIndex = 0; for (int x = 0; x < characters.Length; x++) { bool isLastCharacter = x == characters.Length - 1; // Spaces, equal signs, and asterisks do not represent the end of a query string. Underscores are treated like a letter or space and ignored. if (isLastCharacter || (!char.IsLetterOrDigit(characters[x]) && characters[x] != ' ' && characters[x] != '=' && characters[x] != '*' && characters[x] != '_')) { bool isClosingStatement = characters[x] == ']'; bool isStartOfQuery = startIndex == x; if (x == 0 && isClosingStatement) { logger.LogError("Invalid Query String: \"]\" cannot be the first character in a query string."); } if (!isStartOfQuery && characters[startIndex] == '[' && !isClosingStatement) { logger.LogError("Invalid Query String: A starting bracket \"[\" was encountered, but a closing bracket \"]\" was not encountered before the expected end of the query."); } if (!isStartOfQuery) { returnValues.Add(querySelector.Substring(startIndex, (isLastCharacter || isClosingStatement ? x + 1 : x) - startIndex)); } startIndex = x; } if (isLastCharacter) { break; } } return(returnValues.FindAll(rv => !string.IsNullOrEmpty(rv) && rv != "]")); }