Exemplo n.º 1
0
        public bool Validate(GrepRequest request, List <string> messages)
        {
            if (request.FilterString == null)
            {
                messages.Add("'for' string parameter is not specified " +
                             "but required to filter the posted string against string.");

                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public string Perform(GrepRequest request)
        {
            var lines = request.InputString.Split(Environment.NewLine.ToCharArray());

            var sb = new StringBuilder();

            foreach (var line in lines)
            {
                if (line.Contains(line) == false)
                {
                    continue;
                }
                sb.Append(line);
            }

            return(sb.ToString());
        }
Exemplo n.º 3
0
        public bool TryToUnbind(HttpRequest httpRequest, List <string> messages, out GrepRequest request)
        {
            string s;

            if (_inputStreamStringReader.ReadStringFromInputStream(httpRequest.InputStream, messages, out s) == false)
            {
                request = null;
                return(false);
            }

            request = new GrepRequest
            {
                InputString  = s,
                FilterString = httpRequest.RoutesValues != null
                    ? httpRequest.RoutesValues["for"]
                    : null
            };

            return(true);
        }
Exemplo n.º 4
0
        public string HandleRequestFailure(
            HttpContext httpContext, RequestFailedAt requestFailedAt, List <string> messages, GrepRequest request)
        {
            var sb = new StringBuilder();

            switch (requestFailedAt)
            {
            case RequestFailedAt.PreAction:
                sb.AppendLine("Preparing for request handling.");
                break;

            case RequestFailedAt.Unbinding:
                sb.AppendLine("Unable to read request.");
                break;

            case RequestFailedAt.Validation:
                sb.AppendLine("Unable to validate request.");
                break;
            }
            messages.ForEach(x => sb.AppendLine(x));
            return(sb.ToString());
        }