Пример #1
0
        public static bool Register(string uri, Action <WebAPIContext> handler)
        {
            if (uri == null)
            {
                return(false);
            }

            uri = uri.TrimEnd('/');

            if (!uri.StartsWith("/"))
            {
                uri = "/" + uri;
            }

            var h = Handlers.GetValue(uri);

            if (h == null)
            {
                Handlers[uri] = h = new WebAPIHandler(uri, handler);
            }
            else
            {
                h.Handler = handler;
            }

            return(h.Handler == handler);
        }
Пример #2
0
        public static bool Register(string uri, Action <WebAPIContext> handler)
        {
            if (uri == null)
            {
                return(false);
            }

            uri = uri.TrimEnd('/');

            if (!uri.StartsWith("/"))
            {
                uri = "/" + uri;
            }

            if (!Handlers.ContainsKey(uri) || Handlers[uri] == null)
            {
                Handlers[uri] = new WebAPIHandler(uri, handler);
            }
            else
            {
                Handlers[uri].Handler = handler;
            }

            return(true);
        }