From f53607018c8cf5632d7f6bf15a357a1ab8bd4d2a Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 8 Nov 2018 15:50:12 -0500 Subject: [PATCH] refactor: Enumerate over XML attributes --- ICD.Common.Utils/Xml/XmlReaderExtensions.cs | 8 +------- ICD.Common.Utils/Xml/XmlUtils.cs | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ICD.Common.Utils/Xml/XmlReaderExtensions.cs b/ICD.Common.Utils/Xml/XmlReaderExtensions.cs index e974c79..fbddbbc 100644 --- a/ICD.Common.Utils/Xml/XmlReaderExtensions.cs +++ b/ICD.Common.Utils/Xml/XmlReaderExtensions.cs @@ -42,17 +42,11 @@ namespace ICD.Common.Utils.Xml if (extends == null) throw new ArgumentNullException("extends"); - if (!extends.HasAttributes) - return Enumerable.Empty(); - - List attributes = new List(); while (extends.MoveToNextAttribute()) - attributes.Add(new IcdXmlAttribute(extends.Name, extends.Value)); + yield return new IcdXmlAttribute(extends.Name, extends.Value); // Move back to element. extends.MoveToElement(); - - return attributes.ToArray(); } /// diff --git a/ICD.Common.Utils/Xml/XmlUtils.cs b/ICD.Common.Utils/Xml/XmlUtils.cs index 9becca2..d2413f8 100644 --- a/ICD.Common.Utils/Xml/XmlUtils.cs +++ b/ICD.Common.Utils/Xml/XmlUtils.cs @@ -60,7 +60,7 @@ namespace ICD.Common.Utils.Xml using (IcdXmlReader reader = new IcdXmlReader(xml)) { reader.ReadToNextElement(); - return reader.GetAttributes(); + return reader.GetAttributes().ToArray(); } }