本文整理汇总了C#中TemplateItem类的典型用法代码示例。如果您正苦于以下问题:C# TemplateItem类的具体用法?C# TemplateItem怎么用?C# TemplateItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemplateItem类属于命名空间,在下文中一共展示了TemplateItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ChangedTemplate
public virtual void ChangedTemplate(Item targetItem, TemplateItem oldTemplate)
{
if(oldTemplate != null)
_logger.Debug($"* [T] from {oldTemplate.Name} to {targetItem.TemplateName}");
else
_logger.Debug($"* [T] to {targetItem.TemplateName}");
}
开发者ID:Eldblom,项目名称:Unicorn,代码行数:7,代码来源:DefaultDeserializerLogger.cs
示例2: InheritsFromTemplate
private bool InheritsFromTemplate(TemplateItem templateItem, Sitecore.Data.ID templateId)
{
return templateItem.ID == templateId
|| (templateItem.BaseTemplates != null
&& templateItem.BaseTemplates
.Where(baseTempl => InheritsFromTemplate(baseTempl, templateId)).Count() > 0);
}
开发者ID:johnpen,项目名称:SharedSource.Projects,代码行数:7,代码来源:CheckProjectItems.cs
示例3: FindItemsByTemplateOrDerivedTemplate
/// <summary>
/// Find items below another based on the specified template or a derived template
/// </summary>
/// <param name="rootItem">The item the item must be below</param>
/// <param name="template">The template to find item based on, or based on derivaties of the template</param>
/// <returns>All items which match</returns>
public static Item[] FindItemsByTemplateOrDerivedTemplate(this Item rootItem, TemplateItem template)
{
if (rootItem == null || template == null)
return new Item[0];
var database = rootItem.Database;
var foundItems = new List<Item>();
var derivedTemplates = new List<TemplateItem>();
var references = Sitecore.Globals.LinkDatabase.GetReferrers(template);
foreach (var reference in references)
{
var source = reference.GetSourceItem();
if (source.Template.Key == "template")
derivedTemplates.Add((TemplateItem)source);
else
{
if(source.Axes.IsDescendantOf(rootItem))
foundItems.Add(source);
}
}
foreach(var derivedTemplate in derivedTemplates)
{
foundItems.AddRange(FindItemsByTemplateOrDerivedTemplate(rootItem, derivedTemplate));
}
return foundItems.ToArray();
}
开发者ID:kaytee821,项目名称:WeBlog,代码行数:35,代码来源:ItemExtensions.cs
示例4: TemplateIsOrBasedOn
/// <summary>
/// Determine if an item is based on a given template or if the item's template is based on the given template
/// </summary>
/// <param name="item">The item to test the template of</param>
/// <param name="template">The template which the item's template should be or inherit from</param>
/// <returns>True if the item's template is based on the given template, otherwsie false</returns>
public static bool TemplateIsOrBasedOn(this Item item, TemplateItem template)
{
if (template != null)
return TemplateIsOrBasedOn(item, template.ID);
else
return false;
}
开发者ID:KerwinMa,项目名称:WeBlog,代码行数:13,代码来源:ItemExtensions.cs
示例5: Check
/// <summary>Checks the specified output.</summary>
/// <param name="output">The output.</param>
/// <param name="item">The item.</param>
public override void Check(ValidationAnalyzer output, Item item)
{
Assert.ArgumentNotNull(output, "output");
Assert.ArgumentNotNull(item, "item");
var parametersTemplateId = item[ParametersTemplateFieldId];
if (string.IsNullOrEmpty(parametersTemplateId))
{
return;
}
var parameterTemplateItem = item.Database.GetItem(parametersTemplateId);
if (parameterTemplateItem == null)
{
return;
}
var template = new TemplateItem(parameterTemplateItem);
foreach (var templateFieldItem in template.Fields)
{
var templateItem = new TemplateItem(templateFieldItem.InnerItem.Parent.Parent);
if (!templateItem.BaseTemplates.Any())
{
continue;
}
output.MaxMessages++;
if (string.IsNullOrEmpty(templateFieldItem.ToolTip))
{
output.Write(SeverityLevel.Suggestion, "Parameter must have help text", string.Format("The parameter '{0}' in the '{1}' control does not have a short help text. The short help text is part of documentation and is displayed in the Documentation web site", templateFieldItem.Name, item.Name), "Write a help text.", templateFieldItem.InnerItem);
}
}
}
开发者ID:JakobChristensen,项目名称:Sitecore.Speak.Reference,代码行数:38,代码来源:MissingParameterHelp.cs
示例6: CustomItemInformation
public CustomItemInformation(TemplateItem template, string baseNamespace, string baseFileRoot)
{
CustomItemSettings settings = new CustomItemSettings(HttpContext.Current);
ICustomItemNamespaceProvider namespaceProvider = AssemblyUtil.GetNamespaceProvider(settings.NamespaceProvider);
ICustomItemFolderPathProvider filePathProvider = AssemblyUtil.GetFilePathProvider(settings.FilepathProvider);
GetItemInformation(template, baseNamespace, baseFileRoot, filePathProvider, namespaceProvider);
}
开发者ID:kmazzoni,项目名称:Custom-Item-Generator,代码行数:7,代码来源:CustomItemInformation.cs
示例7: RecursiveCheckBaseTemplatesIfStructuredTree
/// <summary>
/// Cheks if selected templates has "StructuredData StructuredTreeArchive" as one of its base tamplates
/// </summary>
/// <param name="templateItem">The template item. </param>
/// <returns>if selected templates has "StructuredData StructuredTreeArchive".</returns>
private static bool RecursiveCheckBaseTemplatesIfStructuredTree(TemplateItem templateItem)
{
if (templateItem != null
&& !templateItem.Name.Equals("Standard template"))
{
if (templateItem.Name.Equals("StructuredData StructuredTreeArchive"))
{
return true;
}
TemplateItem[] baseTemplates = templateItem.BaseTemplates;
if (baseTemplates != null)
{
foreach (TemplateItem baseTemplateItem in baseTemplates)
{
bool success = RecursiveCheckBaseTemplatesIfStructuredTree(baseTemplateItem);
if (success)
{
return true;
}
}
}
}
return false;
}
开发者ID:HydAu,项目名称:sitecore8ecommerce,代码行数:31,代码来源:EnableStructuredDataModule.cs
示例8: 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
示例9: Execute
public override void Execute(CommandContext context)
{
var selectedItem = context.Items.FirstOrDefault();
if (selectedItem == null)
return;
string templateId = "{CC80011D-8EAE-4BFC-84F1-67ECD0223E9E}";
TemplateItem newTemplate = new TemplateItem(Sitecore.Context.Database.GetItem(templateId));
if (newTemplate != null)
{
try
{
using (new Sitecore.SecurityModel.SecurityDisabler())
{
selectedItem.Editing.BeginEdit();
selectedItem.ChangeTemplate(newTemplate);
}
}
catch (Exception ex)
{
Log.Error(ex.Message, ex, this);
throw;
}
finally
{
selectedItem.Editing.EndEdit();
}
}
}
开发者ID:islaytitans,项目名称:AssignTemplates,代码行数:31,代码来源:AssignTemplates.cs
示例10: AddTemplate
protected void AddTemplate(ITemplate template) {
if (template != null) {
TemplateItem i = new TemplateItem();
template.InstantiateIn(i);
Controls.Add(i);
}
}
开发者ID:cmarfia,项目名称:KalikoCMS.Core,代码行数:7,代码来源:BaseList.cs
示例11: Folder
/// <summary>
/// Initializes a new instance of the <see cref="Folder"/> class.
/// </summary>
/// <param name="templateItem">The template item.</param>
/// <param name="format">The format.</param>
public Folder(TemplateItem templateItem, string format)
{
Sitecore.Diagnostics.Assert.IsNotNull(templateItem, "templateItem");
Sitecore.Diagnostics.Assert.IsNotNullOrEmpty(format, "format");
Template = templateItem;
FormatString = format;
}
开发者ID:JimmieOverby,项目名称:NewsMover,代码行数:13,代码来源:Folder.cs
示例12: Render
public override string Render(TemplateItem item)
{
return Template.Resolve().Render(new TemplateItem {
Parent = item,
Data = new ExpressionEvaluator(item).Evaluate(Data).Value,
Options = new ExpressionEvaluator(item).Evaluate(Options).Value,
});
}
开发者ID:hikirsch,项目名称:jquery-tmpl.net,代码行数:8,代码来源:NestedTemplate.cs
示例13: RecurseTemplates
private static void RecurseTemplates(ICollection<string> list, TemplateItem template)
{
foreach (var baseTemplateItem in template.BaseTemplates)
{
list.Add(IdHelper.NormalizeGuid(baseTemplateItem.ID));
if (baseTemplateItem.ID != TemplateIDs.StandardTemplate)
RecurseTemplates(list, baseTemplateItem);
}
}
开发者ID:simonproctor,项目名称:Synthesis,代码行数:9,代码来源:InheritedTemplates.cs
示例14: GetAllTemplates
public void GetAllTemplates(TemplateItem baseTemplate, List<string> list)
{
var str = IdHelper.NormalizeGuid(baseTemplate.ID);
list.Add(str);
if (baseTemplate.ID == TemplateIDs.StandardTemplate)
return;
foreach (var item in baseTemplate.BaseTemplates)
GetAllTemplates(item, list);
}
开发者ID:BIGANDYT,项目名称:Habitat,代码行数:9,代码来源:AllTemplatesComputedField.cs
示例15: TemplateAndBaseCheck
protected virtual bool TemplateAndBaseCheck(TemplateItem template, ID templateId)
{
if (template.ID == templateId)
{
return true;
}
return template.BaseTemplates.Any(baseTemplate => TemplateAndBaseCheck(baseTemplate, templateId));
}
开发者ID:neilduncan,项目名称:Glass.Mapper,代码行数:9,代码来源:EnforcedTemplateCheck.cs
示例16: GetItemsByTemplate
public static IEnumerable<Item> GetItemsByTemplate(TemplateItem template, Item root)
{
var usages = template.GetUsageIDs();
foreach (var usage in usages)
{
var item = template.Database.GetItem(usage);
if (item != null && (root == null || root.Axes.IsAncestorOf(item)))
yield return item;
}
}
开发者ID:simonproctor,项目名称:Testing-Framework,代码行数:10,代码来源:ItemReferences.cs
示例17: GetNamespace
public string GetNamespace(TemplateItem template, string baseNamespace)
{
string relativePath = TemplateUtil.GetRelativeTemplatePath(template);
if(string.IsNullOrEmpty(relativePath)) return baseNamespace;
relativePath = relativePath.Replace("/", ".");
relativePath = CodeUtil.CleanStringOfIllegalCharacters(relativePath);
return baseNamespace + "." + relativePath;
}
开发者ID:kmazzoni,项目名称:Custom-Item-Generator,代码行数:11,代码来源:TemplatePathNameSpaceProvider.cs
示例18: GetBaseTemplates
private static void GetBaseTemplates(TemplateItem template, IDictionary<string, TemplateItem> templates)
{
if (template != null && !templates.ContainsKey(template.FullName))
{
templates.Add(template.FullName, template);
foreach (var baseTemplate in template.BaseTemplates)
{
GetBaseTemplates(baseTemplate, templates);
}
}
}
开发者ID:GuitarRich,项目名称:Console,代码行数:11,代码来源:GetItemTemplateCommand.cs
示例19: TemplateInSetBase
public TemplateInSetBase(Item item, string[] databases, string setNamespace)
{
TemplateItem = new TemplateItem(item);
TemplateId = item.ID.ToString();
TemplateName = item.Name;
ClassName = DomUtil.ConvertCaseString(item.Name);
FullClassName = string.Format("{0}.{1}", setNamespace, ClassName);
Databases = databases;
TemplateSectionItem[] sectionItems = TemplateItem.GetSections();
Sections = sectionItems != null ? sectionItems.Select(sectionItem => new TemplateSection(sectionItem, false)) : null;
}
开发者ID:hermanussen,项目名称:CompiledDomainModel,代码行数:11,代码来源:TemplateInSetBase.cs
示例20: ShouldMigrate
protected virtual bool ShouldMigrate(TemplateItem template)
{
foreach (TemplateItem baseTemplate in template.BaseTemplates)
{
if (string.Equals(baseTemplate.ID.ToString(), sharedBaseTemplateID) || ShouldMigrate(baseTemplate))
{
return true;
}
}
return false;
}
开发者ID:ivansharamok,项目名称:VersionableMedia,代码行数:11,代码来源:UnversionedToVersioned.cs
注:本文中的TemplateItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论