public static XmlCoalesceAsset LoadFromMemory(string text) { var sourcePath = "virtualized"; var doc = XDocument.Parse(text); var root = doc.Root; 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); }
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); }
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; }