示例#1
0
        public static SkinMetadata MetadataFromXmlFile(string skinXmlPath)
        {
            SkinMetadata metadata = null;

            try
            {
                var document = new XmlDocument();
                document.LoadXml(File.ReadAllText(skinXmlPath));
                bool legacy = true;                                       // TODO: make conditional
                var  root   = document.SelectSingleNode("/SapphireSkin"); //TODO: Load Quartz
                if (root == null)
                {
                    throw new ParseException("Skin missing root SapphireSkin node at " + skinXmlPath, null);
                }

                var name   = XmlUtil.GetStringAttribute(root, "name");
                var author = XmlUtil.GetStringAttribute(root, "author");
                metadata = new SkinMetadata {
                    Name = name, Author = author, Path = Path.GetDirectoryName(skinXmlPath), Legacy = legacy
                };
            }
            catch (XmlNodeException ex)
            {
                Debug.LogErrorFormat("{0} while parsing xml \"{1}\" at node \"{2}\": {3}",
                                     ex.GetType(), skinXmlPath, ex.Node == null ? "null" : ex.Node.Name, ex.ToString());
            }
            catch (XmlException ex)
            {
                Debug.LogErrorFormat("XmlException while parsing xml \"{0}\" at line {1}, col {2}: {3}",
                                     skinXmlPath, ex.LineNumber, ex.LinePosition, ex.Message);
            }
            catch (Exception ex)
            {
                Debug.LogErrorFormat("{0} while parsing xml \"{1}\": {2}", ex.GetType(),
                                     skinXmlPath, ex.ToString());
            }

            return(metadata);
        }
示例#2
0
        public static SkinMetadata MetadataFromXmlFile(string skinXmlPath)
        {
            SkinMetadata metadata = null;

            try
            {
                var document = new XmlDocument();
                document.LoadXml(File.ReadAllText(skinXmlPath));
				bool legacy = true; // TODO: make conditional
                var root = document.SelectSingleNode("/SapphireSkin"); //TODO: Load Quartz
                if (root == null)
                {
                    throw new ParseException("Skin missing root SapphireSkin node at " + skinXmlPath, null);
                }

                var name = XmlUtil.GetStringAttribute(root, "name");
                var author = XmlUtil.GetStringAttribute(root, "author");
                metadata = new SkinMetadata {Name = name, Author = author, Path = Path.GetDirectoryName(skinXmlPath), Legacy = legacy};
            }
            catch (XmlNodeException ex)
            {
                Debug.LogErrorFormat("{0} while parsing xml \"{1}\" at node \"{2}\": {3}",
                    ex.GetType(), skinXmlPath, ex.Node == null ? "null" : ex.Node.Name, ex.ToString());
            }
            catch (XmlException ex)
            {
                Debug.LogErrorFormat("XmlException while parsing xml \"{0}\" at line {1}, col {2}: {3}",
                    skinXmlPath, ex.LineNumber, ex.LinePosition, ex.Message);
            }
            catch (Exception ex)
            {
                Debug.LogErrorFormat("{0} while parsing xml \"{1}\": {2}", ex.GetType(),
                    skinXmlPath, ex.ToString());
            }

            return metadata;
        }