BlogEngine.Core.Providers.XmlBlogProvider.SavePackageFiles C# (CSharp) Method

SavePackageFiles() public method

Log of all files for installed package
public SavePackageFiles ( List packageFiles ) : void
packageFiles List List of intalled package files
return void
        public override void SavePackageFiles(List<PackageFile> packageFiles)
        {
            if(packageFiles == null || packageFiles.Count == 0)
                return;

            var fileName = dataFolder + Constants.InstalledPackageFilesXml;
            var pkgId = packageFiles.First().PackageId;

            var installedFiles = AllInstalledFiles(pkgId);

            using (var writer = new XmlTextWriter(fileName, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.Indentation = 4;
                writer.WriteStartDocument(true);
                writer.WriteStartElement("InstalledPackageFiles");

                // write to file old package files
                foreach (var f in installedFiles)
                {
                    writer.WriteStartElement("item");
                    writer.WriteAttributeString("id", f.PackageId);
                    writer.WriteAttributeString("fileorder", f.FileOrder.ToString());
                    writer.WriteAttributeString("filepath", f.FilePath);
                    writer.WriteAttributeString("isdirectory", f.IsDirectory.ToString());
                    writer.WriteEndElement();
                }

                // add new package files
                foreach (var pf in packageFiles)
                {
                    writer.WriteStartElement("item");
                    writer.WriteAttributeString("id", pf.PackageId);
                    writer.WriteAttributeString("fileorder", pf.FileOrder.ToString());
                    writer.WriteAttributeString("filepath", pf.FilePath);
                    writer.WriteAttributeString("isdirectory", pf.IsDirectory.ToString());
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }
        }