using ResourceString.Net.Logic.DomainObjects.Resx; using System.Linq; using System.Xml; namespace ResourceString.Net.Logic.Parsers.Resx; internal static class Parser { public static Option TryParse(string xmlString) { var doc = new XmlDocument(); try { doc.LoadXml(xmlString); } catch { return Option.None; } var resources = doc.SelectNodes("descendant::data").OfType().Select((i, _) => { var name = i.GetAttribute("name"); var type = i.GetAttribute("type"); var value = i.SelectSingleNode("descendant::value")?.InnerXml; return new Resource(name, value ?? string.Empty) { Type = type }; }).ToArray(); return resources.Any() ? Option.Some(new File(resources)) : Option.None; } }