ReadIncludes() public method

public ReadIncludes ( System.Xml.Linq.XElement root ) : void
root System.Xml.Linq.XElement
return void
コード例 #1
0
        public static XmlCoalesceAsset Load(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            var sourcePath = Path.GetFullPath(path);

            if (!File.Exists(sourcePath))
            {
                Console.WriteLine(@"Warning: {0} not found!", path);
                return(null);
            }

            var doc = XDocument.Load(path);

            var root = doc.Root;

            if (root == null)
            {
                return(null);
            }

            var id     = (string)root.Attribute("id");
            var name   = (string)root.Attribute("name");
            var source = (string)root.Attribute("source");

            var result = new XmlCoalesceAsset(name)
            {
                BaseUri         = (doc.BaseUri != "") ? doc.BaseUri : new Uri(sourcePath).AbsoluteUri,
                Id              = id,
                Source          = source,
                SourcePath      = sourcePath,
                SourceDirectory = Path.GetDirectoryName(sourcePath)
            };

            // Read includes before the sections
            result.ReadIncludes(root);
            result.ReadSections(root);

            return(result);
        }
コード例 #2
0
		public static XmlCoalesceAsset Load(string path)
		{
			if (path.IsNullOrEmpty())
			{
				throw new ArgumentNullException(nameof(path));
			}

			var sourcePath = Path.GetFullPath(path);

			if (!File.Exists(sourcePath))
			{
				Console.WriteLine(@"Warning: {0} not found!", path);
				return null;
			}

			var doc = XDocument.Load(path);

			var root = doc.Root;

			if (root == null)
			{
				return null;
			}

			var id = (string) root.Attribute("id");
			var name = (string) root.Attribute("name");
			var source = (string) root.Attribute("source");

			var result = new XmlCoalesceAsset(name)
			{
				BaseUri = (doc.BaseUri != "") ? doc.BaseUri : new Uri(sourcePath).AbsoluteUri,
				Id = id,
				Source = source,
				SourcePath = sourcePath,
				SourceDirectory = Path.GetDirectoryName(sourcePath)
			};

			// Read includes before the sections
			result.ReadIncludes(root);
			result.ReadSections(root);

			return result;
		}