示例#1
0
        private WorkflowHttpResponse RespondToDelete(WorkflowHttpRequest request)
        {
            string actualPath;
            string workItemId;

            if (IsWorkItem(request.RawUrl, out actualPath, out workItemId))
            {
                return(DeleteWorkItem(actualPath, workItemId));
            }

            return(DeleteWorkStep(request.RawUrl));
        }
        public static WorkflowHttpRequest Create(HttpListenerRequest listenerRequest)
        {
            var request =
                new WorkflowHttpRequest
            {
                InputStream = listenerRequest.InputStream,
                RawUrl      = listenerRequest.RawUrl,
                HttpMethod  = listenerRequest.HttpMethod,
                ContentType = listenerRequest.ContentType,
                Accept      = listenerRequest.AcceptTypes != null?listenerRequest.AcceptTypes.FirstOrDefault() : null
            };

            return(request);
        }
        public static WorkflowHttpRequest Create(HttpListenerRequest listenerRequest)
        {
            var request =
                new WorkflowHttpRequest
                    {
                        InputStream = listenerRequest.InputStream,
                        RawUrl = listenerRequest.RawUrl,
                        HttpMethod = listenerRequest.HttpMethod,
                        ContentType = listenerRequest.ContentType,
                        Accept = listenerRequest.AcceptTypes != null ? listenerRequest.AcceptTypes.FirstOrDefault() : null
                    };

            return request;
        }
        public WorkflowHttpResponse HandleRequest(WorkflowHttpRequest request)
        {
            switch (request.HttpMethod.ToLowerInvariant())
            {

                case "post":
                    return RespondToPost(request);
                case "get":
                    return RespondToGet(request);
                case "delete":
                    return RespondToDelete(request);
            }

            return WorkflowHttpResponse.MethodNotAllowed;
        }
示例#5
0
        public WorkflowHttpResponse HandleRequest(WorkflowHttpRequest request)
        {
            switch (request.HttpMethod.ToLowerInvariant())
            {
            case "post":
                return(RespondToPost(request));

            case "get":
                return(RespondToGet(request));

            case "delete":
                return(RespondToDelete(request));
            }

            return(WorkflowHttpResponse.MethodNotAllowed);
        }
示例#6
0
        private WorkflowHttpResponse RespondToPost(WorkflowHttpRequest request)
        {
            IRequestMessageParser parser;

            if (!RequestMessageParserFactory.TryCreateParser(request.ContentType, out parser))
            {
                return(WorkflowHttpResponse.UnsupportedMediaType);
            }

            var visitor = new HttpPostWorkflowNodeVisitor(_workflow, request.RawUrl);

            try
            {
                parser.Parse(request.InputStream).AcceptVisitor(visitor);
            }
            catch (ArgumentException e)
            {
                return(WorkflowHttpResponse.BadRequest(e));
            }

            return(visitor.Response);
        }
        private WorkflowHttpResponse RespondToPost(WorkflowHttpRequest request)
        {
            IRequestMessageParser parser;
            if (!RequestMessageParserFactory.TryCreateParser(request.ContentType, out parser))
            {
                return WorkflowHttpResponse.UnsupportedMediaType;
            }

            var visitor = new HttpPostWorkflowNodeVisitor(_workflow, request.RawUrl);
            try
            {
                parser.Parse(request.InputStream).AcceptVisitor(visitor);
            }
            catch(ArgumentException e)
            {
                return WorkflowHttpResponse.BadRequest(e);
            }

            return visitor.Response;
        }
 private WorkflowHttpResponse RespondToGet(WorkflowHttpRequest request)
 {
     var renderer = _rendererFactory.CreateRenderer(request.Accept);
     return Render(renderer, request.RawUrl);
 }
        private WorkflowHttpResponse RespondToDelete(WorkflowHttpRequest request)
        {
            string actualPath;
            string workItemId;
            if (IsWorkItem(request.RawUrl, out actualPath, out workItemId))
            {
                return DeleteWorkItem(actualPath, workItemId);
            }

            return DeleteWorkStep(request.RawUrl);
        }
示例#10
0
        private WorkflowHttpResponse RespondToGet(WorkflowHttpRequest request)
        {
            var renderer = _rendererFactory.CreateRenderer(request.Accept);

            return(Render(renderer, request.RawUrl));
        }