public static void AddControls(this XElement element, AddInList list, XNamespace ns) { var items = list?.ToXml(ns).ToArray(); if (items != null && items.Any()) { foreach (var item in items) { element.Add(item); } } }
public static void AddControls <T>(this XElement element, AddInList <T> items, XNamespace ns) where T : AddInElement { if (items == null) { return; } foreach (var item in items) { element.Add(item.ToXml(ns)); } }