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(); } }
/// <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()); } } }