public void ReadXml(XmlReader reader) { if (Rules != null) { throw new InvalidOperationException(); } var xElement = (XElement)XNode.ReadFrom(reader); Name = xElement.Attribute(ATTR.name)?.Value; RowSource = xElement.Attribute(ATTR.rowsource)?.Value; var rules = new List <MetadataRule>(); foreach (var child in xElement.Elements(EL.rule)) { var rule = new MetadataRule(); var attrSource = child.Attribute(ATTR.source); if (attrSource != null) { rule = rule.ChangeSource(PropertyPath.Parse(attrSource.Value)); } rule = rule.ChangePattern(child.Attribute(ATTR.pattern)?.Value); rule = rule.ChangeReplacement(child.Attribute(ATTR.replacement)?.Value); var attrTarget = child.Attribute(ATTR.target); if (attrTarget != null) { rule = rule.ChangeTarget(PropertyPath.Parse(attrTarget.Value)); } rules.Add(rule); } Rules = ImmutableList.ValueOf(rules); }