/// <summary> /// Loads XmlPseudoAttributes from the filesystem (if the parameter is null) and converts /// them into a list of PseudoAttributes. /// </summary> /// <param name="xmlPseudoAttributes">The XmlPseudoAttributes to convert if they shouldn't be loaded from the filesystem.</param> /// <returns>The converted PseudoAttributes (not null)</returns> /// <exception cref="PseudoAttributeDataInvalidException">If the xml files or given XmlPseudoAttributes are invalid.</exception> public List <PseudoAttribute> LoadPseudoAttributes(XmlPseudoAttributes xmlPseudoAttributes = null) { XmlPseudoAttribute[] xmlPseudos; if (xmlPseudoAttributes == null) { // Deserialize all files in DataPath that end with .xml // and select the XmlPseudoAttribute objects. xmlPseudos = (from file in Directory.GetFiles(DataPath) where file.EndsWith(".xml") from pseudo in DeserializeFile(file).PseudoAttributes select pseudo).ToArray(); } else { xmlPseudos = xmlPseudoAttributes.PseudoAttributes; } if (xmlPseudos.Length == 0) { throw new PseudoAttributeDataInvalidException(string.Format(L10n.Message("No Pseudo Attributes loaded. Make sure {0} is not empty."), DataPath)); } // Inductive converting. var pseudos = ConvertFromXml(xmlPseudos).ToList(); // Replace nested pseudo attributes by proper object. ResolveNesting(pseudos); // No longer needed. _pseudoNameDict.Clear(); _nestedPseudosDict.Clear(); return(pseudos); }
/// <summary> /// Loads XmlPseudoAttributes from the filesystem (if the parameter is null) and converts /// them into a list of PseudoAttributes. /// </summary> /// <param name="xmlPseudoAttributes">The XmlPseudoAttributes to convert if they shouldn't be loaded from the filesystem.</param> /// <returns>The converted PseudoAttributes (not null)</returns> /// <exception cref="PseudoAttributeDataInvalidException">If the xml files or given XmlPseudoAttributes are invalid.</exception> public List<PseudoAttribute> LoadPseudoAttributes(XmlPseudoAttributes xmlPseudoAttributes = null) { XmlPseudoAttribute[] xmlPseudos; if (xmlPseudoAttributes == null) { // Deserialize all files in DataPath that end with .xml // and select the XmlPseudoAttribute objects. xmlPseudos = (from file in Directory.GetFiles(DataPath) where file.EndsWith(".xml") from pseudo in DeserializeFile(file).PseudoAttributes select pseudo).ToArray(); } else { xmlPseudos = xmlPseudoAttributes.PseudoAttributes; } if (xmlPseudos.Length == 0) { throw new PseudoAttributeDataInvalidException(string.Format(L10n.Message("No Pseudo Attributes loaded. Make sure {0} is not empty."), DataPath)); } // Inductive converting. var pseudos = ConvertFromXml(xmlPseudos).ToList(); // Replace nested pseudo attributes by proper object. ResolveNesting(pseudos); // No longer needed. _pseudoNameDict.Clear(); _nestedPseudosDict.Clear(); return pseudos; }