//------------------------------------------------------------------------- // Returns the common value's value if the value is for a common value, // otherwise just returns the given value. // // simpleCompare == true : just compares entire strings // simpleCompare == false : checks within strings to find common value keys public string GetCommonValue(string value, bool simpleCompare) { // Check local settings first. IEnumerable <KeyValuePair <string, string> > results = CommonValues.Where( x => x.Key.ToUpper() == value.ToUpper()); if (results.Count() > 0) { return(results.First().Value); } // Check the globals. results = Program.g_projectManager.CommonValues.Where( x => x.Key.ToUpper() == value.ToUpper()); if (results.Count() > 0) { return(results.First().Value); } // The following is legacy, but is probably partially used when // 'simple compares' aren't desired. // try this project foreach (string commonKey in CommonValues.Keys) { if (simpleCompare) { if (commonKey.ToUpper() == value.ToUpper()) { CommonValues.TryGetValue(commonKey, out value); return(value); } } else { string valueUpper = value.ToUpper(); if (valueUpper.Contains(commonKey.ToUpper())) { string commonKeyValue; CommonValues.TryGetValue(commonKey, out commonKeyValue); int index = valueUpper.IndexOf(commonKey.ToUpper()); value = value.Remove(index, commonKey.Length); value = value.Insert(index, commonKeyValue); return(value); } } } // try the global store foreach (string commonKey in Program.g_projectManager.CommonValues.Keys) { if (simpleCompare) { if (commonKey.ToUpper() == value.ToUpper()) { Program.g_projectManager.CommonValues.TryGetValue(commonKey, out value); return(value); } } else { string valueUpper = value.ToUpper(); if (valueUpper.Contains(commonKey.ToUpper())) { string commonKeyValue; Program.g_projectManager.CommonValues.TryGetValue(commonKey, out commonKeyValue); int index = valueUpper.IndexOf(commonKey.ToUpper()); value = value.Remove(index, commonKey.Length); value = value.Insert(index, commonKeyValue); return(value); } } } return(value); }