internal ObjectBase(Unknown other, ObjectFactoryDelegate factory) { other._Properties.CopyTo(this._Properties); foreach (var kvp in other._Attributes) { this._Attributes[kvp.Key] = kvp.Value; } foreach (var child in other._LogicalChildren) { if (factory != null && child is Unknown unkChild) { _LogicalChildren.Add(factory(unkChild)); } else { _LogicalChildren.Add(child); } } }
public static ObjectBase ParseXml(XElement root, ObjectFactoryDelegate factory) { var target = new Unknown(root.Name.LocalName); foreach (var xattr in root.Attributes()) { target.Attributes[xattr.Name.LocalName] = xattr.Value; } var props = root.Element(_Constants.Namespace.GetName("Properties")); if (props != null) { target.Properties._ParseXml(props); } foreach (var childxml in root.Elements().Where(item => item.Name.LocalName != "Properties")) { var child = ParseXml(childxml, factory); target.AddLogicalChild(child); } return(factory(target)); }