/// <summary> /// Initializes a new instance of the <see cref="SessionRequestList"/> class /// that contains elements copied from the specified collection and /// that has the same initial capacity as the number of elements copied. /// </summary> /// <param name="collection">The <see cref="SessionRequestList"/> /// whose elements are copied to the new collection.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="collection"/> is a null reference.</exception> /// <remarks>Please refer to <see cref="ArrayList(ICollection)"/> for details.</remarks> public SessionRequestList(SessionRequestList collection) { if (collection == null) throw new ArgumentNullException("collection"); this._array = new SessionRequest[collection.Count]; AddRange(collection); }
internal ReadOnlyList(SessionRequestList collection) : base(Tag.Default) { this._collection = collection; }
internal Enumerator(SessionRequestList collection) { this._collection = collection; this._version = collection._version; this._index = -1; }
/// <overloads> /// Adds a range of elements to the end of the <see cref="SessionRequestList"/>. /// </overloads> /// <summary> /// Adds the elements of another collection to the end of the <see cref="SessionRequestList"/>. /// </summary> /// <param name="collection">The <see cref="SessionRequestList"/> whose elements /// should be added to the end of the current collection.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="collection"/> is a null reference.</exception> /// <exception cref="NotSupportedException"> /// <para>The <see cref="SessionRequestList"/> is read-only.</para> /// <para>-or-</para> /// <para>The <b>SessionRequestList</b> has a fixed size.</para></exception> /// <remarks>Please refer to <see cref="ArrayList.AddRange"/> for details.</remarks> public virtual void AddRange(SessionRequestList collection) { if (collection == null) throw new ArgumentNullException("collection"); if (collection.Count == 0) return; if (this._count + collection.Count > this._array.Length) EnsureCapacity(this._count + collection.Count); ++this._version; Array.Copy(collection._array, 0, this._array, this._count, collection.Count); this._count += collection.Count; }
/// <summary> /// Creates a shallow copy of the <see cref="SessionRequestList"/>. /// </summary> /// <returns>A shallow copy of the <see cref="SessionRequestList"/>.</returns> /// <remarks>Please refer to <see cref="ArrayList.Clone"/> for details.</remarks> public virtual object Clone() { SessionRequestList collection = new SessionRequestList(this._count); Array.Copy(this._array, 0, collection._array, 0, this._count); collection._count = this._count; collection._version = this._version; return collection; }
/// <summary> /// Returns a read-only wrapper for the specified <see cref="SessionRequestList"/>. /// </summary> /// <param name="collection">The <see cref="SessionRequestList"/> to wrap.</param> /// <returns>A read-only wrapper around <paramref name="collection"/>.</returns> /// <exception cref="ArgumentNullException"> /// <paramref name="collection"/> is a null reference.</exception> /// <remarks>Please refer to <see cref="ArrayList.ReadOnly"/> for details.</remarks> public static SessionRequestList ReadOnly(SessionRequestList collection) { if (collection == null) throw new ArgumentNullException("collection"); return new ReadOnlyList(collection); }
/// <summary> /// Returns a synchronized (thread-safe) wrapper /// for the specified <see cref="SessionRequestList"/>. /// </summary> /// <param name="collection">The <see cref="SessionRequestList"/> to synchronize.</param> /// <returns> /// A synchronized (thread-safe) wrapper around <paramref name="collection"/>. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="collection"/> is a null reference.</exception> /// <remarks>Please refer to <see cref="ArrayList.Synchronized"/> for details.</remarks> public static SessionRequestList Synchronized(SessionRequestList collection) { if (collection == null) throw new ArgumentNullException("collection"); return new SyncList(collection); }
public override void AddRange(SessionRequestList collection) { lock (this._root) this._collection.AddRange(collection); }
internal SyncList(SessionRequestList collection) : base(Tag.Default) { this._root = collection.SyncRoot; this._collection = collection; }
public override void AddRange(SessionRequestList collection) { throw new NotSupportedException("Read-only collections cannot be modified."); }
/// <summary> /// Add url request to session request list. /// </summary> /// <param name="requests"> The SessionRequestList.</param> /// <param name="url"> The url.</param> private void AddUrlRequest(SessionRequestList requests, string url) { if ( url.StartsWith("http") ) { GetSessionRequest getSessionRequest = new GetSessionRequest(); getSessionRequest.QueryString = url; getSessionRequest.RequestCookies = getForm.CookieManager.GetCookies(new Uri(url)); getSessionRequest.Url = new Uri(url); getSessionRequest.RequestHttpSettings = this.ClientProperties.Clone(); requests.Add(getSessionRequest); } }
/// <summary> /// Loads the UrlSpider /// </summary> /// <param name="sender"> The sender object.</param> /// <param name="e"> The LoadLinksEventArgs.</param> private void LoadUrlSpider(object sender, LoadLinksEventArgs e) { int requestCount = e.Anchors.Count + e.Links.Count + CurrentResponseBuffer.Scripts.Count; // // enabled url spider commands // if ( requestCount == 0 ) // { // // disabled // this.btnOpenTemplate.Enabled = false; // this.btnRunUrlSpider.Enabled = false; // } // else // { // // enabled // this.btnOpenTemplate.Enabled = true; // //this.btnRunUrlSpider.Enabled = false; // } urlSpiderControl.SuspendLayout(); urlSpiderControl.Clear(); TreeNode frameParent = urlSpiderControl.AddRootNode("Frames"); TreeNode anchorParent = urlSpiderControl.AddRootNode("Anchor Elements"); TreeNode linkParent = urlSpiderControl.AddRootNode("Link Elements"); TreeNode scriptParent = urlSpiderControl.AddRootNode("External Scripts"); this.urlSpiderControl.ImageList = this.imgIcons; anchorParent.ImageIndex = 7; anchorParent.SelectedImageIndex = 7; linkParent.ImageIndex = 7; linkParent.SelectedImageIndex = 7; scriptParent.SelectedImageIndex = 7; scriptParent.ImageIndex = 7; frameParent.ImageIndex = 7; frameParent.SelectedImageIndex = 7; // new session request collection to add urls SessionRequestList urlRequests = new SessionRequestList(); string url = string.Empty; foreach ( HtmlAnchorTag tag in e.Anchors ) { if ( tag.HRef.StartsWith("http") ) { // add node urlSpiderControl.AddChildren(anchorParent.Index,tag.HRef,tag.HRef,1); // add url request AddUrlRequest(urlRequests,tag.HRef); } } foreach ( HtmlLinkTag tag in e.Links ) { // add node urlSpiderControl.AddChildren(linkParent.Index,tag.HRef + " (" + tag.MimeType + ")",tag.HRef,1); url = UriResolver.ResolveUrl((Uri)this.CurrentResponseBuffer.ResponseHeaderCollection["Response Uri"],tag.HRef); // add url request AddUrlRequest(urlRequests,url); } foreach ( HtmlScript tag in CurrentResponseBuffer.Scripts ) { if ( tag.Source != string.Empty ) { url = UriResolver.ResolveUrl((Uri)this.CurrentResponseBuffer.ResponseHeaderCollection["Response Uri"],tag.Source); // add node urlSpiderControl.AddChildren(scriptParent.Index,tag.Source,tag.Source,1); // add url request AddUrlRequest(urlRequests,url); } } foreach ( HtmlLinkTag frame in e.Frames ) { if ( frame.HRef != string.Empty ) { url = UriResolver.ResolveUrl((Uri)this.CurrentResponseBuffer.ResponseHeaderCollection["Response Uri"],frame.HRef); // add node urlSpiderControl.AddChildren(frameParent.Index,frame.HRef,frame.HRef,1); // add url request AddUrlRequest(urlRequests,url); } } urlSpiderControl.UrlRequests = urlRequests; urlSpiderControl.ResumeLayout(true); }