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


C# ContentItem.Clone方法代码示例

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


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

示例1: GetTemplate

		public TemplateDefinition GetTemplate(ContentItem item)
		{
			var template = CreateTemplate(map.GetOrCreateDefinition(item));
			template.OriginalFactory = () => item;
			template.TemplateFactory = () => item.Clone(false);
			return template;
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:7,代码来源:TemplateProvider.cs

示例2: SaveVersion

		/// <summary>Creates a version of the item. This must be called before the item item is modified to save a version before modifications.</summary>
		/// <param name="item">The item to create a old version of.</param>
		/// <returns>The old version.</returns>
		public virtual ContentItem SaveVersion(ContentItem item)
		{
			if (item == null) 
				throw new ArgumentNullException("item");

			CancellableItemEventArgs args = new CancellableItemEventArgs(item);
			if (ItemSavingVersion != null)
				ItemSavingVersion.Invoke(this, args);

			if (args.Cancel)
				return null;

			item = args.AffectedItem;
                
			ContentItem oldVersion = item.Clone(false);
			if(item.State == ContentState.Published)
				stateChanger.ChangeTo(oldVersion, ContentState.Unpublished);
			else
				stateChanger.ChangeTo(oldVersion, ContentState.Draft);
			oldVersion.Expires = Utility.CurrentTime().AddSeconds(-1);
			oldVersion.Updated = Utility.CurrentTime().AddSeconds(-1);
			oldVersion.Parent = null;
			oldVersion.VersionOf = item;
			if (item.Parent != null)
				oldVersion["ParentID"] = item.Parent.ID;
			itemRepository.SaveOrUpdate(oldVersion);

			if (ItemSavedVersion != null)
				ItemSavedVersion.Invoke(this, new ItemEventArgs(oldVersion));

			TrimVersionCountTo(item, maximumVersionsPerItem);

			return oldVersion;
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:37,代码来源:VersionManager.cs

示例3: GetTemplate

        public TemplateDefinition GetTemplate(ContentItem item)
        {
            if (item["TemplatName"] != null)
                return null;

            var template = CreateTemplate(map.GetOrCreateDefinition(item));
            template.Original = () => item;
            template.Template = () => item.Clone(false);
            return template;
        }
开发者ID:AnonymousRetard,项目名称:n2cms,代码行数:10,代码来源:TemplateProvider.cs

示例4: CommandContext

		public CommandContext(ItemDefinition definition, ContentItem content, string userInterface, IPrincipal user, IContentForm<CommandContext> binder, IValidator<CommandContext> validator)
        {
			Definition = definition;
            Content = content;
			Original = content.VersionOf.Value ?? content.Clone(false);
            Interface = userInterface;
            User = user;
            Binder = binder;
            Validator = validator;
            ValidationErrors = new List<ValidationError>();
            Errors = new List<Exception>();
			Parameters = new Dictionary<string, object>();
        }
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:13,代码来源:CommandContext.cs

示例5: UpdateItem

        protected override bool UpdateItem(NameValueCollection request, ContentItem item)
	    {
            item = item.Clone(true);
            item.Name = null;
            item.ZoneName = request["zone"];
            foreach (var child in Find.EnumerateChildren(item, true, false))
                child.SetVersionKey(Guid.NewGuid().ToString());

            int newIndex;
            var parent = GetParentAndIndex(request, Page, out newIndex);
            if (parent == null)
                throw new Exception("could not locate target of action");

            InsertItem(parent, item, newIndex);

            return true;
	    }
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:17,代码来源:ItemCopyer.cs

示例6: CreateTemplateInfo

		private TemplateDefinition CreateTemplateInfo(ContentItem template)
		{
			var info = new TemplateDefinition
			{
				Name = template.Name,
				Title = template.Title,
				Description = template.GetDetail(TemplateDescription, ""),
				TemplateUrl = template.Url,
				Definition = map.GetOrCreateDefinition(template.GetContentType(), template.Name),
				TemplateFactory = () =>
				{
					var clone = template.Clone(true);
					clone.SetDetail(TemplateDescription, null, typeof(string));
					clone.Title = "";
					clone.Name = null;
					clone.TemplateKey = template.Name;
					return clone;
				},
				OriginalFactory = () => template
			};
			return info;
		}
开发者ID:rohancragg,项目名称:n2cms,代码行数:22,代码来源:ContentTemplateRepository.cs

示例7: Copy

		public override ContentItem Copy(ContentItem source, ContentItem destination)
		{
			Trace.TraceInformation("ContentPersister.Copy " + source + " to " + destination);
			ContentItem cloned = source.Clone(includeChildren:true);
			if (cloned.Name == source.ID.ToString())
				cloned.Name = null;
			cloned.Parent = destination;

            Save(cloned);
            foreach (var descendant in Find.EnumerateChildren(cloned).ToArray())
                Save(descendant);

			return cloned;
		}
开发者ID:davethieben,项目名称:n2cms,代码行数:14,代码来源:DatabaseSource.cs

示例8: Copy

		public override ContentItem Copy(ContentItem source, ContentItem destination)
		{
			Trace.TraceInformation("ContentPersister.Copy " + source + " to " + destination);
			ContentItem cloned = source.Clone(includeChildren:true);
			if (cloned.Name == source.ID.ToString())
				cloned.Name = null;
			cloned.Parent = destination;

			Save(cloned);

			return cloned;
		}
开发者ID:jupeterson,项目名称:n2cms,代码行数:12,代码来源:DatabaseSource.cs

示例9: CreateTemplateInfo

 private TemplateDefinition CreateTemplateInfo(ContentItem template)
 {
     var clone = template.Clone(true);
     clone.SetDetail(TemplateDescription, null, typeof(string));
     clone.Title = "";
     clone.Name = null;
     clone["TemplateName"] = template.Name;
     var info = new TemplateDefinition
     {
         Name = template.Name,
         Title = template.Title,
         Description = template.GetDetail(TemplateDescription, ""),
         TemplateUrl = template.Url,
         Definition = definitions.GetDefinition(template.GetContentType()).Clone(),
         Template = clone,
         Original = template
     };
     info.Definition.Template = template.Name;
     return info;
 }
开发者ID:ztaff,项目名称:n2cms,代码行数:20,代码来源:ContentTemplateRepository.cs

示例10: SaveVersion

        /// <summary>Creates an old version of an item. This must be called before the item item is modified.</summary>
        /// <param name="item">The item to create a old version of.</param>
        /// <returns>The old version.</returns>
        public virtual ContentItem SaveVersion(ContentItem item)
        {
            CancelItemEventArgs args = new CancelItemEventArgs(item);
            if (ItemSavingVersion != null)
                ItemSavingVersion.Invoke(this, args);
            if (!args.Cancel)
            {
                item = args.AffectedItem;

                ContentItem oldVersion = item.Clone(false);
                oldVersion.Expires = Utility.CurrentTime().AddSeconds(-1);
                oldVersion.Updated = Utility.CurrentTime().AddSeconds(-1);
                oldVersion.Parent = null;
                oldVersion.TranslationOf = null;
                oldVersion.VersionOf = item;
                if (item.Parent != null)
                    oldVersion["ParentID"] = item.Parent.ID;
                if (item.TranslationOf != null)
                    oldVersion["TranslationOfID"] = item.TranslationOf.ID;
                _itemRepository.SaveOrUpdate(oldVersion);

                if (ItemSavedVersion != null)
                    ItemSavedVersion.Invoke(this, new ItemEventArgs(oldVersion));

                return oldVersion;
            }
            return null;
        }
开发者ID:dpawatts,项目名称:zeus,代码行数:31,代码来源:VersionManager.cs

示例11: CreateTemplateInfo

 private ContentTemplate CreateTemplateInfo(ContentItem template)
 {
     var clone = template.Clone(true);
     var info = new ContentTemplate
     {
         Name = template.Name,
         Title = template.Title,
         Description = template.GetDetail(TemplateDescription, ""),
         TemplateUrl = template.Url,
         Definition = definitions.GetDefinition(template.GetContentType()),
         Template = clone,
         Original = template
         //HiddenEditors = (template.GetDetailCollection("HiddenEditors", false) ?? new DetailCollection()).ToList<string>(),
     };
     clone.SetDetail(TemplateDescription, null, typeof(string));
     clone.Title = "";
     clone.Name = null;
     return info;
 }
开发者ID:cherylhanlon,项目名称:Tigers,代码行数:19,代码来源:ContentTemplateRepository.cs


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