当前位置: 首页>>代码示例>>C#>>正文


C# PlatformExportManifest.SerializeXML方法代码示例

本文整理汇总了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());
				}
			}
		}
开发者ID:rajendra1809,项目名称:VirtoCommerce,代码行数:64,代码来源:PlatformExportImportManager.cs


注:本文中的VirtoCommerce.Platform.Core.ExportImport.PlatformExportManifest.SerializeXML方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。