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


C# IMedia.ToXml方法代码示例

本文整理汇总了C#中IMedia.ToXml方法的典型用法代码示例。如果您正苦于以下问题:C# IMedia.ToXml方法的具体用法?C# IMedia.ToXml怎么用?C# IMedia.ToXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMedia的用法示例。


在下文中一共展示了IMedia.ToXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IndexMedia

 private static void IndexMedia(IMedia sender)
 {
     ExamineManager.Instance.ReIndexNode(
         sender.ToXml(), "media",
         ExamineManager.Instance.IndexProviderCollection.OfType<BaseUmbracoIndexer>().Where(x => x.EnableDefaultEventHandler));
 }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:6,代码来源:ExamineEvents.cs

示例2: Save

	    /// <summary>
	    /// Saves a single <see cref="IMedia"/> object
	    /// </summary>
	    /// <param name="media">The <see cref="IMedia"/> to save</param>
	    /// <param name="userId">Id of the User saving the Content</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Save(IMedia media, int userId = 0, bool raiseEvents = true)
	    {
            if(raiseEvents)
			{
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IMedia>(media), this))
				return;
            }

	        using (new WriteLock(Locker))
	        {
	            var uow = _uowProvider.GetUnitOfWork();
	            using (var repository = _repositoryFactory.CreateMediaRepository(uow))
	            {
	                media.CreatorId = userId;
	                repository.AddOrUpdate(media);
	                uow.Commit();

	                var xml = media.ToXml();
	                CreateAndSaveMediaXml(xml, media.Id, uow.Database);
	            }
	        }

            if (raiseEvents)
                Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false), this);

            Audit.Add(AuditTypes.Save, "Save Media performed by user", userId, media.Id);
	    }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:33,代码来源:MediaService.cs

示例3: Save

	    /// <summary>
	    /// Saves a single <see cref="IMedia"/> object
	    /// </summary>
	    /// <param name="media">The <see cref="IMedia"/> to save</param>
	    /// <param name="userId">Id of the User saving the Content</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Save(IMedia media, int userId = 0, bool raiseEvents = true)
	    {
            if(raiseEvents)
			{
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs<IMedia>(media), this))
				return;
            }

	        using (new WriteLock(Locker))
	        {
	            var uow = _uowProvider.GetUnitOfWork();
	            using (var repository = _repositoryFactory.CreateMediaRepository(uow))
	            {
	                media.CreatorId = userId;
	                repository.AddOrUpdate(media);
	                uow.Commit();

	                var xml = media.ToXml();
	                var poco = new ContentXmlDto {NodeId = media.Id, Xml = xml.ToString(SaveOptions.None)};
	                var exists = uow.Database.FirstOrDefault<ContentXmlDto>("WHERE nodeId = @Id", new {Id = media.Id}) != null;
	                int result = exists
	                                 ? uow.Database.Update(poco)
	                                 : Convert.ToInt32(uow.Database.Insert(poco));
	            }

	            if (raiseEvents)
	                Saved.RaiseEvent(new SaveEventArgs<IMedia>(media, false), this);

	            Audit.Add(AuditTypes.Save, "Save Media performed by user", media.CreatorId, media.Id);
	        }
	    }
开发者ID:kjetilb,项目名称:Umbraco-CMS,代码行数:37,代码来源:MediaService.cs


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