BExIS.IO.Transform.Output.AsciiWriter.SortVariablesOnDatastructure C# (CSharp) Метод

SortVariablesOnDatastructure() приватный Метод

private SortVariablesOnDatastructure ( List variables, DataStructure datastructure ) : List
variables List
datastructure DataStructure
Результат List
        private List<Variable> SortVariablesOnDatastructure(List<Variable> variables, DataStructure datastructure)
        {
            List<Variable> sortedVariables = new List<Variable>();

            XmlDocument extra = new XmlDocument();
            extra.LoadXml(datastructure.Extra.OuterXml);
            IEnumerable<XElement> elements = XmlUtility.GetXElementByNodeName("variable", XmlUtility.ToXDocument(extra));

            foreach (XElement element in elements)
            {
                long id = Convert.ToInt64(element.Value);
                Variable var =variables.Where(v => v.Id.Equals(id)).FirstOrDefault();
                if(var !=null)
                    sortedVariables.Add(var);
            }

            return sortedVariables;
        }