コード例 #1
0
 public void Add(string uriPrefix)
 {
     this._listener.CheckDisposed();
     HttpListenerPrefix.CheckPrefix(uriPrefix);
     if (!this._prefixes.Contains(uriPrefix))
     {
         this._prefixes.Add(uriPrefix);
         if (this._listener.IsListening)
         {
             EndPointManager.AddPrefix(uriPrefix, this._listener);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Adds the specified <paramref name="uriPrefix"/> to the collection.
        /// </summary>
        /// <param name="uriPrefix">
        /// A <see cref="string"/> that represents the URI prefix to add. The prefix must be
        /// a well-formed URI prefix with http or https scheme, and must end with a <c>'/'</c>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="uriPrefix"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="uriPrefix"/> is invalid.
        /// </exception>
        /// <exception cref="ObjectDisposedException">
        /// The <see cref="HttpListener"/> associated with this collection is closed.
        /// </exception>
        public void Add(string uriPrefix)
        {
            _listener.CheckDisposed();
            HttpListenerPrefix.CheckPrefix(uriPrefix);
            if (_prefixes.Contains(uriPrefix))
            {
                return;
            }

            _prefixes.Add(uriPrefix);
            if (_listener.IsListening)
            {
                EndPointManager.AddPrefix(uriPrefix, _listener);
            }
        }
コード例 #3
0
        public void Add(string uriPrefix)
        {
            listener.CheckDisposed();
            ListenerPrefix.CheckUri(uriPrefix);
            if (prefixes.Contains(uriPrefix))
            {
                return;
            }

            prefixes.Add(uriPrefix);
            if (listener.IsListening)
            {
                EndPointManager.AddPrefix(uriPrefix, listener);
            }
        }
コード例 #4
0
        /// <summary>
        /// Adds the specified URI prefix to the collection.
        /// </summary>
        /// <param name="uriPrefix">
        ///   <para>
        ///   A <see cref="string"/> that specifies the URI prefix to add.
        ///   </para>
        ///   <para>
        ///   It must be a well-formed URI prefix with http or https scheme,
        ///   and must end with a '/'.
        ///   </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="uriPrefix"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="uriPrefix"/> is invalid.
        /// </exception>
        /// <exception cref="ObjectDisposedException">
        /// The <see cref="HttpListener"/> instance associated with this
        /// collection is closed.
        /// </exception>
        public void Add(string uriPrefix)
        {
            if (_listener.IsDisposed)
            {
                throw new ObjectDisposedException(_listener.GetType().ToString());
            }

            HttpListenerPrefix.CheckPrefix(uriPrefix);

            if (_prefixes.Contains(uriPrefix))
            {
                return;
            }

            if (_listener.IsListening)
            {
                EndPointManager.AddPrefix(uriPrefix, _listener);
            }

            _prefixes.Add(uriPrefix);
        }