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


C# Database.GetTemplate方法代码示例

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


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

示例1: GetFieldsOfASublayoutItem

        public static List<Item> GetFieldsOfASublayoutItem(Item item, Database database)
        {
            List<Item> sourceField = new List<Item>();
            if (!string.IsNullOrEmpty(item["Datasource Template"]))
            {
                var firstTemplateID = database.GetItem(item["Datasource Template"]).ID;
                if (!firstTemplateID.IsNull)
                {
                    List<TemplateItem> templateItems = new List<TemplateItem>();
                    var firstTemplate = database.GetTemplate(firstTemplateID);
                    if (firstTemplate != null)
                    {
                        templateItems.Add(firstTemplate);
                        templateItems.AddRange(firstTemplate.BaseTemplates);

                        foreach (Item template in templateItems)
                        {
                            var sections =
                                template.Children.Where(
                                    o => o.TemplateID.Equals(new ID("{E269FBB5-3750-427A-9149-7AA950B49301}")));

                            foreach (var section in sections.Distinct(new ItemEqualityComparer()))
                            {
                                foreach (Item fieldItem in section.Children.Where(o => !o.Name.StartsWith("__")))
                                {
                                    sourceField.Add(fieldItem);
                                }
                            }
                        }
                    }
                }

            }
            return sourceField;
        }
开发者ID:JobiJoba,项目名称:PageAnalyze,代码行数:35,代码来源:DatasourceIndexerHelper.cs

示例2: RetrieveFieldItem

        private static List<Item> RetrieveFieldItem(Database database, ID templateId)
        {
            List<Item> sourceField = new List<Item>();
            List<TemplateItem> templateItems = new List<TemplateItem>();
            // We retrieve him as a TemplateItem
            var firstTemplate = database.GetTemplate(templateId);
            if (firstTemplate != null)
            {
                // We add to the list the firstTemplate and his BaseTemplate to retrieve all the field.
                templateItems.Add(firstTemplate);
                templateItems.AddRange(firstTemplate.BaseTemplates);

                foreach (Item template in templateItems)
                {
                    //We retrieve each section
                    var sections =
                        template.Children.Where(
                            o => o.TemplateID.Equals(Constants.TemplateSectionsID));
                    // Foreach sections, we will take the field except the standard field ("__")
                    foreach (var section in sections.Distinct(new ItemEqualityComparer()))
                    {
                        foreach (Item fieldItem in section.Children.Where(o => !o.Name.StartsWith("__") && TextFieldTypes.Contains(o[Constants.TypeFieldID])))
                        {
                            sourceField.Add(fieldItem);
                        }
                    }
                }
            }
            return sourceField;
        }
开发者ID:paramount-jay,项目名称:DatasourceIndexer,代码行数:30,代码来源:DatasourceIndexHelper.cs

示例3: GetAllBlogs

        /// <summary>
        /// Gets all the blogs.
        /// </summary>
        /// <param name="database">The database to get the blogs from. If null, use the context database</param>
        /// <returns>The list of all blogs</returns>
        public Items.WeBlog.BlogHomeItem[] GetAllBlogs(Database database)
        {
            if (database == null)
                database = Context.Database;

            // TODO: Store the result of this call in cache and clear it from cache on publish
            var blogTemplate = database.GetTemplate(Settings.BlogTemplateIDString);
            var contentRoot = database.GetItem(Settings.ContentRootPath);
            var blogItems = contentRoot.FindItemsByTemplateOrDerivedTemplate(blogTemplate);
            return (from item in blogItems select new BlogHomeItem(item)).ToArray();
        }
开发者ID:KerwinMa,项目名称:WeBlog,代码行数:16,代码来源:BlogManager.cs

示例4: GetAllBlogs

        /// <summary>
        /// Gets all the blogs.
        /// </summary>
        /// <param name="database">The database to get the blogs from. If null, use the context database</param>
        /// <returns>The list of all blogs</returns>
        public BlogHomeItem[] GetAllBlogs(Database database = null)
        {
            if (database == null)
                database = Context.Database;

            var contentRoot = database.GetItem(Settings.ContentRootPath);

            return (from templateId in Settings.BlogTemplateIds
                   let template = database.GetTemplate(templateId)
                   let blogItems = contentRoot.FindItemsByTemplateOrDerivedTemplate(template)
                   from item in blogItems
                   where item != null
                   select new BlogHomeItem(item)).ToArray();
        }
开发者ID:WeTeam,项目名称:WeBlog,代码行数:19,代码来源:BlogManager.cs

示例5: IsTemplateBucketable

        /// <summary>
        /// Based off a Template ID, when an Item is Created, Will it be bucketed.
        /// </summary>
        /// <returns>If true then it is going to be bucketed</returns>
        /// <param name="templateId">Template Id</param>
        /// <param name="database">Context Database</param>
        public static bool IsTemplateBucketable(ID templateId, Database database)
        {
            #if NET40
            Contract.Requires(templateId.IsNotNull());
            Contract.Requires(database.IsNotNull());
            #else
            Assert.ArgumentNotNull(templateId, "templateId");
            Assert.ArgumentNotNull(database, "database");
            #endif

            var template = database.GetTemplate(templateId);
            if (template == null)
            {
                var item = database.GetItem(templateId);
                if (item != null)
                    template = item.Template;
            }
            return template == null ? false : template.IsBucketTemplateCheck();
        }
开发者ID:csteeg,项目名称:Sitecore-Item-Buckets,代码行数:25,代码来源:BucketManager.cs

示例6: IsTemplateBucketable

        /// <summary>
        /// Based off a Template ID, when an Item is Created, Will it be bucketed.
        /// </summary>
        /// <returns>If true then it is going to be bucketed</returns>
        /// <param name="templateId">Template Id</param>
        /// <param name="database">Context Database</param>
        public static bool IsTemplateBucketable(ID templateId, Database database)
        {
            Contract.Requires(templateId.IsNotNull());
            Contract.Requires(database.IsNotNull());

            var template = database.GetTemplate(templateId).IsNull() ? database.GetItem(templateId).Template : database.GetTemplate(templateId);
            return template.IsBucketTemplateCheck();
        }
开发者ID:seankearney,项目名称:Sitecore-Item-Buckets,代码行数:14,代码来源:BucketManager.cs

示例7: IsTemplateBucketable

 /// <summary>
 /// Based off a Template ID, when an Item is Created, Will it be bucketed.
 /// </summary>
 /// <returns>If true then it is going to be bucketed</returns>
 /// <param name="templateId">Template Id</param>
 /// <param name="database">Context Database</param>
 public static bool IsTemplateBucketable(ID templateId, Database database)
 {
     var template = database.GetTemplate(templateId).IsNull() ? database.GetItem(templateId).Template : database.GetTemplate(templateId);
     return template.IsBucketTemplateCheck();
 }
开发者ID:katebutenko,项目名称:Sitecore-Item-Buckets-NET-2-0,代码行数:11,代码来源:BucketManager.cs


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