Пример #1
0
 public ContentVersionRepository(IRepository<ContentVersion> repository, Exporter exporter, Importer importer, IUrlParser parser, IProxyFactory proxyFactory)
 {
     this.Repository = repository;
     this.exporter = exporter;
     this.importer = importer;
     this.parser = parser;
     this.proxyFactory = proxyFactory;
 }
Пример #2
0
 internal static string Serialize(Exporter exporter, ContentItem item)
 {
     using (var sw = new StringWriter())
     {
         exporter.Export(item, ExportOptions.ExcludePages | ExportOptions.ExcludeAttachments, sw);
         return sw.ToString();
     }
 }
        public void ExportItem(ContentItem item)
        {
            // no UrlParser and FS -> cannot export Attachments
            var itemXmlWriter = new ItemXmlWriter(_definitions, null, null);
            var exporter = new Exporter(itemXmlWriter);
            var path = _path + '/' + GetContentItemFilenameUnique(item.ID);

            using (var ms = new MemoryStream())
            {
                using (var tw = new StreamWriter(ms))
                {
                    lock (_syncLock)
                    {
                        // Nhibernate doesn't like parallel ?
                        exporter.Export(item, ExportOptions.ExcludeAttachments | ExportOptions.ExcludePages, tw);
                    }
                    // Save to FS
                    ms.Position = 0;
                    _fs.WriteFile(path, ms, item.Published);
                }
            }
        }
Пример #4
0
		public ContentVersion(Importer importer, Exporter exporter, IUrlParser parser)
		{
			Deserializer = (xml) => Deserialize(importer, parser, xml);
			Serializer = (item) => Serialize(exporter, item);
		}
        public ActionResult Item(int id)
        {
            var item = _repository.Get(id);
            if (item != null)
                try
                {
                    var itemXmlWriter = new ItemXmlWriter(Context.Current.Definitions, null, null);
                    var exporter = new Exporter(itemXmlWriter);
                    var ms = new MemoryStream();
                    var tw = new StreamWriter(ms);
                    {
                        exporter.Export(item, ExportOptions.ExcludeAttachments | ExportOptions.ExcludePages, tw);
                    }
                    ms.Position = 0;
                    return new FileStreamResult(ms, "application/xml");
                }
                catch (Exception ex)
                {
                    return Content(ex.Message, "text/plain");
                }

            return new EmptyResult();
        }