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


C# Item.Add方法代码示例

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


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

示例1: SetUp

 public void SetUp()
 {
   _item1 = _testRoot.Add("item1", _template);
   _item2 = _testRoot.Add("item2", _template);
   _subItem1 = _item1.Add("subitem1", _template);
   _subItem2 = _item1.Add("subitem2", _template);
 }
开发者ID:KerwinMa,项目名称:revolver,代码行数:7,代码来源:MoveItem.cs

示例2: CreateAlphabetFolderStructure

        /// <summary>
        /// Creates an alphabet folder structure under the passed in parent.  This will also inlcude 123 as a folder
        /// for handling items that start with numbers.
        /// </summary>
        /// <param name="parentItem">The parent item.</param>
        /// <param name="folderTemplate">The folder template.</param>
        /// <param name="upperCase">if set to <c>true</c> make the letter folder name upper case.</param>
        public static void CreateAlphabetFolderStructure(Item parentItem, TemplateItem folderTemplate, bool upperCase)
        {
            if (parentItem == null || folderTemplate == null) return;

            Database masterDb = Factory.GetDatabase("master");
            using (new SecurityDisabler())
            {
                foreach (string letter in alphabetFolderNames)
                {
                    //If we are supposed to make the folder name upper case, do so
                    string folderName = letter;
                    if (upperCase)
                    {
                        folderName = folderName.ToUpper();
                    }

                    //Only add the folder if it does not already exist, this way this method can be used to fill
                    // in missing folders in an already existing partial alpha folder structure.
                    string letterFolderPath = string.Format("{0}/{1}", parentItem.Paths.Path, folderName);
                    Item alphaFolder = SitecoreItemFinder.GetItem(masterDb, letterFolderPath);
                    if (alphaFolder == null)
                    {
                        parentItem.Add(letter.ToUpper(), folderTemplate);
                    }
                }
            }
        }
开发者ID:Velir,项目名称:Sitecore-Commons,代码行数:34,代码来源:CreateItemUtil.cs

示例3: TestFixtureSetUp

        public void TestFixtureSetUp()
        {
            var db = Sitecore.Configuration.Factory.GetDatabase("web");
            var folder = db.GetTemplate("Common/Folder");
            var page = db.GetTemplate("dc2011/page");
            var home = db.GetItem("/sitecore/content/dc2011");

            using (new SecurityDisabler())
            {
                m_testRoot = home.Add("test", folder);

                m_pageWithTitle = m_testRoot.Add("withtitle", page);
                m_pageWithTitle.Editing.BeginEdit();
                m_pageWithTitle["title"] = "Different Title";
                m_pageWithTitle.Editing.EndEdit();

                m_pageNoTitle = m_testRoot.Add("notitle", page);

                m_testRoot.Paste(File.ReadAllText(@"test data\Category Items.xml"), true, PasteMode.Overwrite);
                m_categoryItems = m_testRoot.Axes.GetChild("Project List");
            }
        }
开发者ID:simonproctor,项目名称:Testing-Framework,代码行数:22,代码来源:ItemExtensionsTests.cs

示例4: CreateTestContentItem

        private Item CreateTestContentItem(Item item, TemplateItem template, string name, string content)
        {
            var child = item.Add(name, template);
            child.Editing.BeginEdit();
            child["content"] = content;
            child.Editing.EndEdit();

            return child;
        }
开发者ID:shamrox,项目名称:WeBlog,代码行数:9,代码来源:FirstContentBlockTest.cs

示例5: CreateTestContentItem

        private Item CreateTestContentItem(Item item, string name, string content)
        {
          var template = item.Database.Templates["sample/sample item"];

            var child = item.Add(name, template);
            child.Editing.BeginEdit();
            child["text"] = content;
            child.Editing.EndEdit();

            return child;
        }
开发者ID:KerwinMa,项目名称:WeBlog,代码行数:11,代码来源:AutoGenerateTest.cs


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