static string DetermineType(KVLib.KeyValue k) { //If they key contains 'Is', 'Can', 'Has', then it's probably a bool if (k.Key.IndexOf("Is", StringComparison.OrdinalIgnoreCase) != -1 || k.Key.IndexOf("Can", StringComparison.OrdinalIgnoreCase) != -1 || k.Key.IndexOf("Has", StringComparison.OrdinalIgnoreCase) != -1) { return("bool"); } //Attributes are always ints if (k.Key.IndexOf("Attribute", StringComparison.OrdinalIgnoreCase) != -1) { return("int"); } //Determine the type of the KV List <string> PossibleTypes = new List <string>() { "float", "string", "bool", "int", }; float f; if (!k.TryGet(out f)) //Not a float { PossibleTypes.Remove("float"); } int i; if (!k.TryGet(out i)) { PossibleTypes.Remove("int"); } bool b; if (!k.TryGet(out b)) { PossibleTypes.Remove("bool"); } if (PossibleTypes.Count > 1) //If we have more than one type, it's probably not a string { PossibleTypes.Remove("string"); } if (PossibleTypes.Count == 1) { //Got it, return that one return(PossibleTypes.First()); } //If the possible types are float or int, default to int if (PossibleTypes.Contains("int") && PossibleTypes.Contains("float") && !PossibleTypes.Contains("bool")) { return("int"); } if (k.GetInt() < 0 || k.GetInt() > 1) //If the number is less than 0 or greater than 1, assume int { return("int"); } //If the value is '0' or '1', it could be float int or bool. If the name didn't have 'is', lets default to //lets default to int return("CANTDETERMINE"); }