コード例 #1
0
        private void Add(ContentRoute route)
        {
            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            route.Path = route.Path.ToLower();
            if (!route.Path.StartsWith("/"))
            {
                route.Path = "/" + route.Path;
            }
            if (route.IsDirectory && !route.Path.EndsWith("/"))
            {
                route.Path = route.Path + "/";
            }

            if (Exists(route.Path))
            {
                return;
            }

            lock (_Lock)
            {
                _Routes.Add(route);
            }
        }
コード例 #2
0
        private void Remove(ContentRoute route)
        {
            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            lock (_Lock)
            {
                _Routes.Remove(route);
            }

            return;
        }
コード例 #3
0
        /// <summary>
        /// Remove a route.
        /// </summary>
        /// <param name="path">URL path.</param>
        public void Remove(string path)
        {
            if (String.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            ContentRoute r = Get(path);

            if (r == null)
            {
                return;
            }

            lock (_Lock)
            {
                _Routes.Remove(r);
            }

            return;
        }