本文整理汇总了C#中VirtoCommerce.Platform.Core.ExportImport.PlatformExportManifest.SerializeXML方法的典型用法代码示例。如果您正苦于以下问题:C# PlatformExportManifest.SerializeXML方法的具体用法?C# PlatformExportManifest.SerializeXML怎么用?C# PlatformExportManifest.SerializeXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtoCommerce.Platform.Core.ExportImport.PlatformExportManifest
的用法示例。
在下文中一共展示了PlatformExportManifest.SerializeXML方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
public void Export(Stream outStream, PlatformExportImportOptions exportOptions, Action<ExportImportProgressInfo> progressCallback)
{
if (exportOptions == null)
{
throw new ArgumentNullException("exportOptions");
}
var progressInfo = new ExportImportProgressInfo
{
Description = "Start platform export...",
TotalCount = exportOptions.Modules.Count(),
ProcessedCount = 0
};
progressCallback(progressInfo);
using (var package = ZipPackage.Open(outStream, FileMode.Create))
{
var exportModulesInfo = new List<ExportModuleInfo>();
foreach (var module in exportOptions.Modules)
{
//Create part for module
var modulePartUri = PackUriHelper.CreatePartUri(new Uri(module.Id, UriKind.Relative));
var modulePart = package.CreatePart(modulePartUri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Normal);
progressInfo.Description = String.Format("{0}: export started.", module.Id);
progressCallback(progressInfo);
Action<ExportImportProgressInfo> modulePorgressCallback = (x) =>
{
progressInfo.Description = String.Format("{0}: {1}", module.Id, x.Description);
progressCallback(progressInfo);
};
((ISupportExportModule)module.ModuleInfo.ModuleInstance).DoExport(modulePart.GetStream(), modulePorgressCallback);
//Register in manifest
var moduleManifestPart = new ExportModuleInfo
{
ModuleId = module.Id,
ModuleVersion = module.Version,
PartUri = modulePartUri.ToString()
};
exportModulesInfo.Add(moduleManifestPart);
progressInfo.Description = String.Format("{0}: export finished.", module.Id);
progressInfo.ProcessedCount++;
progressCallback(progressInfo);
}
//Write system information about exported modules
var manifestPart = package.CreatePart(_manifestPartUri, System.Net.Mime.MediaTypeNames.Text.Xml);
var manifest = new PlatformExportManifest
{
Author = exportOptions.Author,
Created = DateTime.UtcNow,
PlatformVersion = exportOptions.PlatformVersion.ToString(),
Modules = exportModulesInfo.ToArray(),
};
//After all modules exported need write export manifest part
using (var streamWriter = new StreamWriter(manifestPart.GetStream()))
{
streamWriter.Write(manifest.SerializeXML());
}
}
}