/// <summary> /// Parses a LoggingConfig XML element /// </summary> /// <param name="element">The XML element</param> /// <returns>A populated LoggingConfigElement</returns> public static LoggingConfigElement Parse(XElement element) { if (element == null) { throw new FormatException($"'{TAG}' tag not found."); } XAttribute fileNameAttribute = element.Attribute(FILE_NAME_ATTRIBUTE); XAttribute windowsPathAttribute = element.Attribute(WINDOWS_PATH_ATTRIBUTE); XAttribute linuxPathAttribute = element.Attribute(LINUX_PATH_ATTIRBUTE); if (fileNameAttribute == null) { throw new FormatException($"'{FILE_NAME_ATTRIBUTE}' attribute of {TAG} element is missing."); } if (windowsPathAttribute == null) { throw new FormatException($"'{WINDOWS_PATH_ATTRIBUTE}' attribute of {TAG} element is missing."); } if (linuxPathAttribute == null) { throw new FormatException($"'{LINUX_PATH_ATTIRBUTE}' attribute of {TAG} element is missing."); } LoggingConfigElement configElement = new LoggingConfigElement( windowsPathAttribute.Value, linuxPathAttribute.Value, fileNameAttribute.Value ); foreach (XElement typeElement in element.Elements(LoggingTypeElement.TAG)) { configElement.AddLoggingType(LoggingTypeElement.Parse(typeElement)); } return(configElement); }
/// <summary> /// Adds a LoggingTypeElement to the list /// </summary> /// <param name="type">The LoggingTypeElement to add</param> private void AddLoggingType(LoggingTypeElement type) { _loggingTypes.Add(type); }