Пример #1
0
        public RouteHandler(IMatchOperation [] ops, HttpMethod [] methods, IManosTarget target)
        {
            Target = target;

            match_ops    = ops;
            this.methods = new List <HttpMethod> (methods);

            SetupChildrenCollection();
        }
Пример #2
0
        public RouteHandler(string [] patterns, HttpMethod [] methods, IManosTarget target)
        {
            Target = target;

            Patterns     = new List <string> (patterns);
            this.methods = new List <HttpMethod> (methods);

            SetupChildrenCollection();
        }
Пример #3
0
        private RouteHandler AddImplicitRouteHandlerForTarget(IManosTarget target, IMatchOperation [] ops, HttpMethod [] methods)
        {
            RouteHandler res = new RouteHandler(ops, methods, target)
            {
                IsImplicit = true,
            };

            Routes.Children.Add(res);
            return(res);
        }
Пример #4
0
        private RouteHandler AddImplicitRouteHandler(IManosTarget target, string [] patterns, HttpMethod [] methods)
        {
            RouteHandler res = new RouteHandler(patterns, methods, target)
            {
                IsImplicit = true,
            };

            Routes.Children.Add(res);
            return(res);
        }
Пример #5
0
        private IManosTarget Find(IHttpRequest request, int uri_start)
        {
            if (!IsMethodMatch(request))
            {
                return(null);
            }

            DataDictionary uri_data = null;

            if (HasPatterns)
            {
                int end;

                if (!FindPatternMatch(request.Path, uri_start, out uri_data, out end))
                {
                    return(null);
                }

                if (Target != null)
                {
                    if (uri_data != null)
                    {
                        request.UriData.Children.Add(uri_data);
                    }
                    return(Target);
                }

                uri_start = end;
            }

            foreach (RouteHandler handler in Children)
            {
                IManosTarget res = handler.Find(request, uri_start);
                if (res != null)
                {
                    if (uri_data != null)
                    {
                        request.UriData.Children.Add(uri_data);
                    }
                    return(res);
                }
            }

            return(null);
        }
Пример #6
0
        private void PipePostProcessTarget(IManosTarget handler)
        {
            if (null != AppHost.Pipes)
            {
                // reset pending pipes
                pending = AppHost.Pipes == null ? 1 : AppHost.Pipes.Count;

                for (int i = AppHost.Pipes.Count - 1; i >= 0; --i)
                {
                    IManosPipe pipe = AppHost.Pipes[i];
                    try {
                        pipe.OnPostProcessTarget(ctx, handler, StepCompleted);
                    } catch (Exception e) {
                        Console.Error.WriteLine("Exception in {0}::OnPostProcessTarget.", pipe);
                        Console.Error.WriteLine(e);
                    }
                }
            }
        }
Пример #7
0
        public void OnPostProcessTarget(IManosContext ctx, IManosTarget target)
        {
            if (AppHost.Pipes == null)
            {
                return;
            }

            foreach (IManosPipe pipe in AppHost.Pipes)
            {
                try {
                    pipe.OnPostProcessTarget(ctx, target);

                    if (ctx.Transaction.Aborted)
                    {
                        return;
                    }
                } catch (Exception e) {
                    Console.Error.WriteLine("Exception in {0}::OnPostProcessTarget.", pipe);
                    Console.Error.WriteLine(e);
                }
            }
        }
Пример #8
0
        private RouteHandler AddRouteHandler(IManosTarget target, string [] patterns, HttpMethod [] methods)
        {
            // TODO: Need to decide if this is a good or bad idea
            // RemoveImplicitHandlers (action);

            if (target == null)
            {
                throw new ArgumentNullException("action");
            }
            if (patterns == null)
            {
                throw new ArgumentNullException("patterns");
            }
            if (methods == null)
            {
                throw new ArgumentNullException("methods");
            }

            RouteHandler res = new RouteHandler(patterns, methods, target);

            Routes.Children.Add(res);
            return(res);
        }
Пример #9
0
        private RouteHandler AddRouteHandler(IManosTarget target, IMatchOperation[] matchOperations, HttpMethod [] methods)
        {
            // TODO: Need to decide if this is a good or bad idea
            // RemoveImplicitHandlers (action);

            if (target == null)
                throw new ArgumentNullException ("action");
            if (matchOperations == null)
                throw new ArgumentNullException ("matchOperations");
            if (methods == null)
                throw new ArgumentNullException ("methods");

            RouteHandler res = new RouteHandler (matchOperations, methods, target);
            Routes.Children.Add (res);
            return res;
        }
Пример #10
0
 private RouteHandler AddImplicitRouteHandlerForTarget(IManosTarget target, string[] patterns, HttpMethod[] methods, MatchType matchType)
 {
     return AddImplicitRouteHandlerForTarget (target, OpsForPatterns (patterns, matchType), methods);
     //return AddImplicitRouteHandlerForTarget (target, StringOpsForPatterns (patterns), methods);
 }
Пример #11
0
        private RouteHandler AddImplicitRouteHandlerForTarget(IManosTarget target, IMatchOperation [] ops, HttpMethod [] methods)
        {
            RouteHandler res = new RouteHandler (ops, methods, target) {
                IsImplicit = true,
            };

            Routes.Children.Add (res);
            return res;
        }
Пример #12
0
        private void PipePostProcessTarget(IManosTarget handler)
        {
            if (null != AppHost.Pipes) {
                // reset pending pipes
                pending = AppHost.Pipes == null ? 1 : AppHost.Pipes.Count;

                for (int i = AppHost.Pipes.Count - 1; i >= 0 ; --i)	{
                    IManosPipe pipe = AppHost.Pipes[i];
                    try {
                        pipe.OnPostProcessTarget (ctx, handler, StepCompleted);
                    } catch (Exception e) {
                        Console.Error.WriteLine ("Exception in {0}::OnPostProcessTarget.", pipe);
                        Console.Error.WriteLine (e);
                    }
                }
            }
        }
Пример #13
0
 public virtual void OnPostProcessTarget(IManosContext ctx, IManosTarget target, Action complete)
 {
     complete();
 }
Пример #14
0
 public RouteHandler(string pattern, HttpMethod [] methods, IManosTarget target) : this(new string [] { pattern }, methods, target)
 {
 }
Пример #15
0
 public virtual void OnPostProcessTarget(IManosContext ctx, IManosTarget target)
 {
 }
Пример #16
0
 public RouteHandler(IMatchOperation op, HttpMethod [] methods, IManosTarget target) : this(new IMatchOperation [] { op }, methods, target)
 {
 }
Пример #17
0
 public RouteHandler(IMatchOperation op, HttpMethod method, IManosTarget target) : this(new IMatchOperation [] { op }, new HttpMethod [] { method }, target)
 {
 }
Пример #18
0
 public RouteHandler(string pattern, HttpMethod method, IManosTarget target) : this(new string [] { pattern }, new HttpMethod [] { method }, target)
 {
 }
Пример #19
0
        private RouteHandler AddRouteHandler(IManosTarget target, string [] patterns, HttpMethod [] methods)
        {
            // TODO: Need to decide if this is a good or bad idea
            // RemoveImplicitHandlers (action);

            if (target == null)
                throw new ArgumentNullException ("action");
            if (patterns == null)
                throw new ArgumentNullException ("patterns");
            if (methods == null)
                throw new ArgumentNullException ("methods");

            RouteHandler res = new RouteHandler (SimpleOpsForPatterns (patterns), methods, target);
            Routes.Children.Add (res);
            return res;
        }
Пример #20
0
 public virtual void OnPostProcessTarget(IManosContext ctx, IManosTarget target, Action complete)
 {
     complete ();
 }
Пример #21
0
        private RouteHandler AddImplicitRouteHandler(IManosTarget target, string [] patterns, string [] methods)
        {
            RouteHandler res = new RouteHandler (patterns, methods, target) {
                IsImplicit = true,
            };

            Routes.Children.Add (res);
            return res;
        }
Пример #22
0
 public virtual void OnPostProcessTarget(IManosContext ctx, IManosTarget target)
 {
 }
Пример #23
0
        public void OnPostProcessTarget(IManosContext ctx, IManosTarget target)
        {
            if (AppHost.Pipes == null)
                return;

            foreach (IManosPipe pipe in AppHost.Pipes) {
                try {
                    pipe.OnPostProcessTarget (ctx, target);

                    if (ctx.Transaction.Aborted)
                        return;
                } catch (Exception e) {
                    Console.Error.WriteLine ("Exception in {0}::OnPostProcessTarget.", pipe);
                    Console.Error.WriteLine (e);
                }
            }
        }
Пример #24
0
 private RouteHandler AddImplicitRouteHandlerForTarget(IManosTarget target, string[] patterns, HttpMethod[] methods, MatchType matchType)
 {
     return(AddImplicitRouteHandlerForTarget(target, OpsForPatterns(patterns, matchType), methods));
     //return AddImplicitRouteHandlerForTarget (target, StringOpsForPatterns (patterns), methods);
 }