private void SetList(List <DTObject> items) { Items = DTOPool.CreateObjectList(this, this.IsPinned); if (items.Count == 0) { this.ItemTemplate = this.IsPinned ? DTObject.Create() : DTObject.CreateReusable(); } else { if (items.Count == 1) { DTObject item = items[0]; if (item.ContainsData()) { Items.Add(item); } this.ItemTemplate = item.Clone(); } else { foreach (var item in items) { Items.Add(item); } this.ItemTemplate = Items[0].Clone(); } this.ItemTemplate.ForceClearData(); } }
public override void Reset() { Items.Clear(); this.Items = null; this.ItemTemplate = null; _objects = null; base.Reset(); }
public static DTEList CreateDTEList(string name, DTObject template, DTObjectList items, bool isPinned) { var dte = isPinned ? new DTEList() : Symbiosis.TryMark(_dteListPool, () => { return(new DTEList()); }); dte.InitByClone(name, template, items, isPinned); return(dte); }
/// <summary> /// 该构造函数仅供克隆时使用 /// </summary> /// <param name="template"></param> /// <param name="items"></param> internal void InitByClone(string name, DTObject template, DTObjectList items, bool isPinned) { this.IsPinned = isPinned; this.Name = name; this.ItemTemplate = template; this.Items = DTOPool.CreateObjectList(this, this.IsPinned); if (items.Count > 0) { foreach (var item in items) { this.Items.Add(item.Clone()); } } }