internal static LogMappings Load(XmlReader reader) { LogMappings result = new LogMappings(); while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "Type": result.Type = reader.Value; break; case "Id": result.SerializedId = reader.Value; break; default: if (result.Conditions == null) { result.Conditions = new Dictionary <string, string>(); } result.Conditions.Add(reader.Name, reader.Value); break; } } if (!reader.IsEmptyElement) { reader.ReadStartElement(); result.Values = LoadValues(reader).ToList(); reader.ReadEndElement(); } else { result.Values = Enumerable.Empty <KeyValuePairMapping>().ToList(); reader.Skip(); // no children exist, just move on } return(result); }
/// <summary> /// Helper method to deserialize mapping rules form xml /// </summary> internal static MappingRules Load(XmlReader reader) { MappingRules result = new MappingRules(); reader.ReadStartElement(); while (reader.GoToSibling()) { switch (reader.LocalName) { case "Log": var mapping = LogMappings.Load(reader); result.LogMappingsRules.Add(mapping); break; default: reader.Skip(); break; } } reader.ReadEndElement(); return(result); }
internal static LogMappings Load(XmlReader reader) { LogMappings result = new LogMappings(); while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "Type": result.Type = reader.Value; break; case "Id": result.SerializedId = reader.Value; break; default: if (result.Conditions == null) result.Conditions = new Dictionary<string, string>(); result.Conditions.Add(reader.Name, reader.Value); break; } } if (!reader.IsEmptyElement) { reader.ReadStartElement(); result.Values = LoadValues(reader).ToList(); reader.ReadEndElement(); } else { result.Values = Enumerable.Empty<KeyValuePairMapping>().ToList(); reader.Skip(); // no children exist, just move on } return result; }