public string GetCommonPrefix() { if (EnumConstants.Count < 2) { return(""); } string prefix = ""; int i = 0; while (true) { char c = EnumConstants[0].Constant[i]; if (EnumConstants.Any(e => e.Constant[i] != c)) { break; } if (EnumConstants.Any(e => e.Constant.Length == i)) { // Prefix is already one of the enumerators, // can't use this prefix return(""); } i++; prefix += c; } return(prefix); }
public string GetCommonSuffix() { if (EnumConstants.Count < 2) { return(""); } string suffix = ""; int i = 1; while (true) { string enumConstant = EnumConstants[0].Constant; char c = enumConstant[enumConstant.Length - i]; if (EnumConstants.Any(e => e.Constant[e.Constant.Length - i] != c)) { break; } i++; suffix = c + suffix; } return(suffix); }