public FileGroupXml(XElement xElement, string basePath) { var name = xElement.Attribute("Name"); if (name == null && xElement.Attribute("Path") == null) { throw new Exception("Name or path attribute required on FileGroup element"); } if (name != null) { this.Name = name.Value; } if (xElement.Attribute("Path") != null) { this.Path = System.IO.Path.Combine(basePath, xElement.Attribute("Path").Value); } else { this.Path = System.IO.Path.Combine(basePath, this.Name); } this.Minify = ((string)xElement.Attribute("Minify")).ToEnum(MinifyActions.True); this.MinifyWith = ((string)xElement.Attribute("MinifyWith")).ToEnum(MinifyType.Unspecified); this.Debug = ((string)xElement.Attribute("Debug")).ToBool(false); var files = new List<FileXml>(); foreach (var fileDescriptor in xElement.Elements()) { if (fileDescriptor.Name.LocalName == "File" || fileDescriptor.Name.LocalName == "Raw") { var file = new FileXml(fileDescriptor, basePath); if (file.MinifyWith == MinifyType.Unspecified) { file.MinifyWith = this.MinifyWith; } files.Add(file); } if (fileDescriptor.Name.LocalName == "Folder") { var folder = new FolderXml(fileDescriptor, basePath); if (folder.Minify != null) { foreach (var f in folder.FileXmlList) { f.Minify = folder.Minify; } } if (folder.MinifyWith == MinifyType.Unspecified) { folder.MinifyWith = this.MinifyWith; foreach (var f in folder.FileXmlList) { f.MinifyWith = this.MinifyWith; } } files.AddRange(folder.FileXmlList); } } this.Files = files; }
public FileGroupXml(XElement xElement, string basePath) { var name = xElement.Attribute("Name"); if (name == null && xElement.Attribute("Path") == null) { throw new Exception("Name or path attribute required on FileGroup element"); } if (name != null) { this.Name = name.Value; } if (xElement.Attribute("Path") != null) { this.Path = System.IO.Path.Combine(basePath, xElement.Attribute("Path").Value); } else { this.Path = System.IO.Path.Combine(basePath, this.Name); } this.Minify = ((string)xElement.Attribute("Minify")).ToEnum(MinifyActions.True); this.MinifyWith = ((string)xElement.Attribute("MinifyWith")).ToEnum(MinifyType.Unspecified); this.Debug = ((string)xElement.Attribute("Debug")).ToBool(false); var files = new List <FileXml>(); foreach (var fileDescriptor in xElement.Elements()) { if (fileDescriptor.Name.LocalName == "File" || fileDescriptor.Name.LocalName == "Raw") { var file = new FileXml(fileDescriptor, basePath); if (file.MinifyWith == MinifyType.Unspecified) { file.MinifyWith = this.MinifyWith; } files.Add(file); } if (fileDescriptor.Name.LocalName == "Folder") { var folder = new FolderXml(fileDescriptor, basePath); if (folder.Minify != null) { foreach (var f in folder.FileXmlList) { f.Minify = folder.Minify; } } if (folder.MinifyWith == MinifyType.Unspecified) { folder.MinifyWith = this.MinifyWith; foreach (var f in folder.FileXmlList) { f.MinifyWith = this.MinifyWith; } } files.AddRange(folder.FileXmlList); } } this.Files = files; }