public void GetObjectData(SerializationInfo info, StreamingContext context) { UrlCollection urls = this.GetMergedList(); info.AddValue("policy", this.policy, typeof(UrlManagePolicy)); info.AddValue("urls", urls, typeof(UrlCollection)); }
/// <summary> /// 将分组IList的增量部分合并到一个IList中 /// </summary> /// <returns>IList</returns> private UrlCollection GetMergedList() { UrlCollection urls = new UrlCollection(); for (int i = 0; i < this.lists.Length; i++) { for (int n = this.listInitItems[i]; n < this.lists[i].Count; n++) { urls.Add(this.lists[i][n].Value); } } return(urls); }
/// <summary> /// 反序列化 /// </summary> /// <param name="info">SerializationInfo</param> /// <param name="context">StreamingContext</param> protected UrlManager(SerializationInfo info, StreamingContext context) { this.policy = info.GetValue("policy", typeof(UrlManagePolicy)) as UrlManagePolicy; UrlCollection urls = info.GetValue("urls", typeof(UrlCollection)) as UrlCollection; if (null != urls) { foreach (Url url in urls) { this.AddOrRemoveItem(url, false); } urls.Clear(); this.InitItemsCount(); } }