public IEnumerable<int> FindIndex(string stringToSearchIn, enIndexFinderOccurrence occurrence, string charsToSearchFor, enIndexFinderDirection direction, bool matchCase, int startIndex)
{
IEnumerable<int> result = new[] { -1 };
if(!string.IsNullOrEmpty(stringToSearchIn) && !string.IsNullOrEmpty(charsToSearchFor))
{
#region Calculate the index according to what the user enterd
var comparisonType = matchCase ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase;
int firstIndex = stringToSearchIn.IndexOf(charsToSearchFor, startIndex, comparisonType);
int lastIndex = stringToSearchIn.LastIndexOf(charsToSearchFor, stringToSearchIn.Length - 1, comparisonType);
if(direction == enIndexFinderDirection.RightToLeft)
{
result = RightToLeftIndexSearch(occurrence, firstIndex, lastIndex, stringToSearchIn, charsToSearchFor,
comparisonType);
}
else
{
result = LeftToRightIndexSearch(occurrence, firstIndex, lastIndex, stringToSearchIn, charsToSearchFor,
comparisonType);
}
#endregion
}
return result;
}