Ejemplo n.º 1
0
        public T Parse(string searchExpression)
        {
            string parsedValue;

            if (searchExpression.Replace("*", string.Empty).Equals(string.Empty))
            {
                return(_searchProvider.CreateNullSearch());
            }
            if (searchExpression.StartsWith(_specialCharacter) && searchExpression.EndsWith(_specialCharacter))
            {
                parsedValue = searchExpression.Substring(1, searchExpression.Length - 2);
                return(_searchProvider.CreateContainsSearch(parsedValue));
            }
            if (searchExpression.EndsWith(_specialCharacter))
            {
                parsedValue = searchExpression.Substring(0, searchExpression.Length - 1);
                return(_searchProvider.CreateStartsWithSearch(parsedValue));
            }
            if (searchExpression.StartsWith(_specialCharacter))
            {
                parsedValue = searchExpression.Substring(1, searchExpression.Length - 1);
                return(_searchProvider.CreateEndsWithSearch(parsedValue));
            }

            return(_searchProvider.CreateEqualsSearch(searchExpression));
        }
 public IAsynchronousSearch CreateEndsWithSearch(string searchString)
 {
     return(CreateSearch(() => _searchProvider.CreateEndsWithSearch(searchString)));
 }