internal bool Equals(string other) { string otherName; bool isAbbreviation = true; if (string.IsNullOrWhiteSpace(other)) { return(false); } // If other starts with a switch indicator, we want to enforce the correct indicator (e.g. "-directory" and "--d" will return false, but "--directory" and "directory" will return true). bool enforceSwitchType = other.StartsWith(FullSwitchIndicator) || other.StartsWith(AbbreviationSwitchIndicator); // Take off the switch indicators and figure out if this is an abbreviation or not. // also convert to lower-case if (other.StartsWith(FullSwitchIndicator)) { isAbbreviation = false; otherName = other.Substring(FullSwitchIndicator.Length).ToLowerInvariant(); } else if (other.StartsWith(AbbreviationSwitchIndicator)) { isAbbreviation = true; otherName = other.Substring(AbbreviationSwitchIndicator.Length).ToLowerInvariant(); } else { otherName = other.ToLowerInvariant(); } var thisAbbr = Abbreviation.ToLowerInvariant(); var thisName = Name.ToLowerInvariant(); if (enforceSwitchType) { return(isAbbreviation ? thisAbbr == otherName : thisName == otherName); } else { return(thisAbbr == otherName || thisName == otherName); } }