Beispiel #1
0
        /// <summary>
        /// Opens a new document loaded from the provided address asynchronously
        /// in the given context.
        /// </summary>
        /// <param name="context">The browsing context to use.</param>
        /// <param name="address">The address to load.</param>
        /// <returns>The task that creates the document.</returns>
        public static Task <IDocument> OpenAsync(this IBrowsingContext context, String address)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }

            return(context.OpenAsync(Url.Create(address), CancellationToken.None));
        }
Beispiel #2
0
 /// <summary>
 /// Creates a new virtual response.
 /// </summary>
 public VirtualResponse()
 {
     address = Url.Create("http://localhost/");
     status  = HttpStatusCode.OK;
     headers = new Dictionary <String, String>();
     content = MemoryStream.Null;
     source  = null;
     dispose = false;
 }
        /// <summary>
        /// Opens a new document loaded from the provided address asynchronously
        /// in the given context.
        /// </summary>
        /// <param name="context">The browsing context to use.</param>
        /// <param name="address">The address to load.</param>
        /// <param name="cancellation">The cancellation token (optional)</param>
        /// <returns>The task that creates the document.</returns>
        public static Task <IDocument> OpenAsync(this IBrowsingContext context, String address, CancellationToken cancellation = default(CancellationToken))
        {
            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            return(context.OpenAsync(Url.Create(address), cancellation));
        }
Beispiel #4
0
 /// <summary>
 /// Sets the location of the response to the provided address.
 /// </summary>
 /// <param name="address">The string to use as an url.</param>
 /// <returns>The current instance.</returns>
 public VirtualResponse Address(String address)
 {
     return(Address(Url.Create(address ?? String.Empty)));
 }