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


C# ContentItem.AddTo方法代码示例

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


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

示例1: MoveTo

		public void MoveTo(ContentItem item, ContentItem parent)
		{
			if (item.Parent == parent)
			{
				// move it last
				item.AddTo(null);
				item.AddTo(parent);
			}
			else if (item.Parent == null || !parent.Children.Contains(item))
				item.AddTo(parent);

		    UpdateSortOrderAndSave(parent);
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:13,代码来源:TreeSorter.cs

示例2: MoveTo

		public void MoveTo(ContentItem item, NodePosition position, ContentItem relativeTo)
		{
            if (relativeTo == null) throw new ArgumentNullException("item");
            if (relativeTo == null) throw new ArgumentNullException("relativeTo");
            if (relativeTo.Parent == null) throw new ArgumentException("The supplied item '" + relativeTo + "' has no parent to add to.", "relativeTo");
            
			if (item.Parent == null 
				|| item.Parent != relativeTo.Parent
				|| !item.Parent.Children.Contains(item))
				item.AddTo(relativeTo.Parent);

			IList<ContentItem> siblings = item.Parent.Children;
			
			int itemIndex = siblings.IndexOf(item);
			int relativeToIndex = siblings.IndexOf(relativeTo);
			
            if(itemIndex < 0)
            {
                if(position == NodePosition.Before)
                    siblings.Insert(relativeToIndex, item);
                else
                    siblings.Insert(relativeToIndex + 1, item);
            }
		    else if(itemIndex < relativeToIndex && position == NodePosition.Before)
				MoveTo(item, relativeToIndex - 1);
			else if (itemIndex > relativeToIndex && position == NodePosition.After)
				MoveTo(item, relativeToIndex + 1);
			else
				MoveTo(item, relativeToIndex);
		}
开发者ID:navneetccna,项目名称:n2cms,代码行数:30,代码来源:TreeSorter.cs

示例3: MoveTo

		public void MoveTo(ContentItem item, ContentItem parent)
		{
			if (item.Parent == parent)
			{
				// move it last
				item.AddTo(null);
				item.AddTo(parent);
			}
			else if (item.Parent == null || !parent.Children.Contains(item))
				item.AddTo(parent);

			using (var tx = persister.Repository.BeginTransaction())
			{
				foreach (ContentItem updatedItem in Utility.UpdateSortOrder(parent.Children))
				{
					persister.Repository.SaveOrUpdate(updatedItem);
				}
				tx.Commit();
			}
		}
开发者ID:nagarjunachallapalli,项目名称:n2cms,代码行数:20,代码来源:TreeSorter.cs

示例4: AddTemplate

        public void AddTemplate(ContentItem templateItem)
        {
            TemplateContainer templates = container.GetOrCreateBelowRoot((c) =>
                {
                    c.Title = "Templates";
                    c.Name = "Templates";
                    c.Visible = false;
                    c.SortOrder = int.MaxValue - 1001000;
                });

            templateItem.Name = null;
            templateItem.AddTo(templates);
            persister.Save(templateItem);
        }
开发者ID:ztaff,项目名称:n2cms,代码行数:14,代码来源:ContentTemplateRepository.cs

示例5: InsertChildBefore

		public static void InsertChildBefore(this ContentItem parent, ContentItem child, int beforeSortOrder)
		{
			bool wasAdded = false;
			for (int i = 0; i < parent.Children.Count; i++)
			{
				var sibling = parent.Children[i];
				if (sibling.SortOrder >= beforeSortOrder)
				{
					parent.Children.Insert(i, child);
					Utility.UpdateSortOrder(parent.Children);
					wasAdded = true;
					break;
				}
			}
			if (!wasAdded)
			{
				child.AddTo(parent);
				Utility.UpdateSortOrder(parent.Children);
			}
		}
开发者ID:rajeshpillai,项目名称:n2cms,代码行数:20,代码来源:EditExtensions.cs

示例6: Save

		public override void Save(ContentItem item)
		{
			using (var tx = repository.BeginTransaction())
			{
				// update updated date unless it's a version being saved
				if (!item.VersionOf.HasValue)
					item.Updated = Utility.CurrentTime();
				// empty string names not allowed, null is replaced with item id
				if (string.IsNullOrEmpty(item.Name))
					item.Name = null;

				item.AddTo(item.Parent);
				
				// make sure the ordering is the same next time these siblings are loaded
				var unsavedItems = item.Parent.EnsureChildrenSortOrder();
				foreach (var itemToSave in unsavedItems.Union(new [] { item }))
				{
					repository.SaveOrUpdate(itemToSave);
				}

				// ensure a name, fallback to id
				if (string.IsNullOrEmpty(item.Name))
				{
					item.Name = item.ID.ToString();
					repository.SaveOrUpdate(item);
				}

				tx.Commit();
			}
		}
开发者ID:davethieben,项目名称:n2cms,代码行数:30,代码来源:DatabaseSource.cs

示例7: Move

		public override ContentItem Move(ContentItem source, ContentItem destination)
		{
			using (var tx = repository.BeginTransaction())
			{
				Trace.TraceInformation("ContentPersister.MoveAction " + source + " to " + destination);
				source.AddTo(destination);
				foreach (var descendant in UpdateAncestralTrailRecursive(source, destination))
				{
					repository.SaveOrUpdate(descendant);
				}
				Save(source);
				tx.Commit();
			}
			return source;
		}
开发者ID:davethieben,项目名称:n2cms,代码行数:15,代码来源:DatabaseSource.cs

示例8: DeleteRecursive

		private void DeleteRecursive(ContentItem itemToDelete)
		{
			DeletePreviousVersions(itemToDelete);

			try
			{
				Trace.Indent();
				foreach (ContentItem child in itemToDelete.Children.ToList())
					DeleteRecursive(child);
			}
			finally
			{
				Trace.Unindent();
			}

			itemToDelete.AddTo(null);

			Trace.TraceInformation("DatabaseSource.DeleteRecursive " + itemToDelete);
			repository.Delete(itemToDelete);
		}
开发者ID:davethieben,项目名称:n2cms,代码行数:20,代码来源:DatabaseSource.cs

示例9: HandleParentRelation

 protected virtual void HandleParentRelation(ContentItem item, string parent, ReadingJournal journal)
 {
     if (!string.IsNullOrEmpty(parent))
     {
         int parentID = int.Parse(parent);
         ContentItem parentItem = journal.Find(parentID);
         item.AddTo(parentItem);
     }
 }
开发者ID:GrimaceOfDespair,项目名称:n2cms,代码行数:9,代码来源:ItemXmlReader.cs

示例10: HandleParentRelation

 protected virtual void HandleParentRelation(ContentItem item, string parent, string parentVersionKey, ReadingJournal journal)
 {
     int parentID = 0;
     if (int.TryParse(parent, out parentID) && parentID != 0)
     {
         ContentItem parentItem = journal.Find(parentID);
         if (parentItem != null)
             item.AddTo(parentItem);
         else
             journal.Register(parentID, (laterParent) => item.AddTo(laterParent), isChild: true);
     }
     if (!string.IsNullOrEmpty(parentVersionKey))
     {
         ContentItem parentItem = journal.Find(parentVersionKey);
         if (parentItem != null)
             item.AddTo(parentItem);
         else
             journal.Register(parentVersionKey, (laterParent) => item.AddTo(laterParent), isChild: true);
     }
 }
开发者ID:brianmatic,项目名称:n2cms,代码行数:20,代码来源:ItemXmlReader.cs

示例11: DeleteRecursive

		private void DeleteRecursive(ContentItem itemToDelete)
		{
			using (logger.Indent())
			{
				foreach (ContentItem child in itemToDelete.Children.ToList())
					DeleteRecursive(child);
			}

			itemToDelete.AddTo(null);

			logger.InfoFormat("Deleting {0}", itemToDelete);
			repository.Delete(itemToDelete);
		}
开发者ID:grbbod,项目名称:drconnect-jungo,代码行数:13,代码来源:DatabaseSource.cs

示例12: RegisterParentRelation

        public void RegisterParentRelation(int parentID, ContentItem item)
		{
			Register(parentID, (laterParent) => item.AddTo(laterParent), isChild: true, relationType: "parent", referencingItem: item);
		}
开发者ID:nicklv,项目名称:n2cms,代码行数:4,代码来源:ReadingJournal.cs

示例13: MoveTo

        public void MoveTo(ContentItem item, NodePosition position, ContentItem relativeTo)
        {
            if (relativeTo == null) throw new ArgumentNullException("item");
            if (relativeTo == null) throw new ArgumentNullException("relativeTo");
            if (relativeTo.Parent == null) throw new ArgumentException("The supplied item '" + relativeTo + "' has no parent to add to.", "relativeTo");

			using (var tx = persister.Repository.BeginTransaction())
			{
				if (item.Parent == null 
					|| item.Parent != relativeTo.Parent
					|| !item.Parent.Children.Contains(item))
				{
					item.AddTo(relativeTo.Parent);
					if (ItemMoved != null)
						ItemMoved.Invoke(this, new DestinationEventArgs(item, relativeTo.Parent));
					//foreach (ContentItem updatedItem in item.UpdateAncestralTrailRecursive(relativeTo.Parent))
					//{
					//	persister.Repository.SaveOrUpdate(updatedItem);
					//}
				}

				IList<ContentItem> siblings = item.Parent.Children;
            
				int itemIndex = siblings.IndexOf(item);
				int relativeToIndex = siblings.IndexOf(relativeTo);
            
				if(itemIndex < 0)
				{
					if(position == NodePosition.Before)
						siblings.Insert(relativeToIndex, item);
					else
						siblings.Insert(relativeToIndex + 1, item);
				}
				else if(itemIndex < relativeToIndex && position == NodePosition.Before)
					MoveTo(item, relativeToIndex - 1);
				else if (itemIndex > relativeToIndex && position == NodePosition.After)
					MoveTo(item, relativeToIndex + 1);
				else
					MoveTo(item, relativeToIndex);

				tx.Commit();
			}
        }
开发者ID:EzyWebwerkstaden,项目名称:n2cms,代码行数:43,代码来源:TreeSorter.cs

示例14: AddTemplate

        public void AddTemplate(ContentItem templateItem)
        {
            TemplateContainer templates = container.GetOrCreateBelowRoot((c) =>
                {
                    c.Title = "Templates";
                    c.Name = "Templates";
                    c.Visible = false;
                    c.SortOrder = int.MaxValue - 1001000;
                });

            templateItem.Name = null;
            templateItem.AddTo(templates);

			using (var tx = repository.BeginTransaction())
			{
				repository.SaveOrUpdate(templateItem);
				tx.Commit();
			}
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:19,代码来源:ContentTemplateRepository.cs


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