public static void Replace(this XElement x, XBase xn) { var name = xn.XName; var elements = x.Elements(name); foreach (var element in elements) { element.Remove(); } x.Add(xn); }
public static void StickyCopyXml <T>(this XBase from, T to) where T : class { var stickies = GetStickyProperties(to); foreach (var info in stickies) { // 1) XML get var name = info.Name; var prop = from.GetProperty(info.PropertyType, name); // 2) Reflection set if (null != prop) { info.SetValue(to, prop, new object[0]); } } }
public static void StickyCopyXml <T>(this T from, XBase to) where T : class { var stickies = GetStickyProperties(from); foreach (var info in stickies) { // 1) Reflection get var name = info.Name; var prop = info.GetValue(from, new object[0]); if (null != prop) { // 2) XML set to.SetProperty(name, prop.ToString()); } } }