本文整理汇总了C#中TermPart类的典型用法代码示例。如果您正苦于以下问题:C# TermPart类的具体用法?C# TermPart怎么用?C# TermPart使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TermPart类属于命名空间,在下文中一共展示了TermPart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDirectContentItems
public IEnumerable<IContent> GetDirectContentItems(TermPart term, int skip = 0, int count = 0, string fieldName = null)
{
return GetDirectContentItemsQuery(term, fieldName)
.Join<CommonPartRecord>()
.OrderByDescending(x => x.CreatedUtc)
.Slice(skip, count);
}
示例2: BuildTag
private static Tag BuildTag(TermPart term, bool leavesOnly, IEnumerable<TermPart> terms) {
return new Tag {
Value = term.Id,
Label = term.Name,
Disabled = !term.Selectable || (leavesOnly && terms.Any(t => t.Path.Contains(term.Path + term.Id))),
Levels = term.GetLevels()
};
}
示例3: CreateTerm
public void CreateTerm(TermPart termPart)
{
if (GetTermByName(termPart.TaxonomyId, termPart.Name) == null) {
_authorizationService.CheckAccess(Permissions.CreateTerm, _services.WorkContext.CurrentUser, null);
termPart.As<ICommonPart>().Container = GetTaxonomy(termPart.TaxonomyId).ContentItem;
_contentManager.Create(termPart);
}
else {
_notifier.Warning(T("The term {0} already exists in this taxonomy", termPart.Name));
}
}
示例4: ProcessTerm
private void ProcessTerm(TermPart termPart, ICollection<int> processedTermPartRecordIds)
{
termPart.Count = (int)_taxonomyService.GetContentItemsCount(termPart);
processedTermPartRecordIds.Add(termPart.Id);
// Look for a parent term that has not yet been processed
if (termPart.Container != null) {
var parentTerm = termPart.Container.As<TermPart>();
if (parentTerm != null && !processedTermPartRecordIds.Contains(parentTerm.Id)) {
ProcessTerm(parentTerm, processedTermPartRecordIds);
}
}
}
示例5: GetCategoriesWithAssociatedContentItems
public List<string> GetCategoriesWithAssociatedContentItems(TermPart packageTypeTerm) {
var categoriesList = new List<string>();
//TODO:Check
var categories = _taxonomyService.GetChildren(packageTypeTerm)
.Where(ct => _taxonomyService.GetContentItems(ct).Any())
.Select(c => c.Name).OrderBy(c => c);
if (categories.Count() > 0)
{
categoriesList.Add("All Categories");
categoriesList.AddRange(categories);
}
return categoriesList;
}
示例6: CreateChildTermFor
public TermPart CreateChildTermFor(TaxonomyPart taxonomy, TermPart parent, string termName, string termSlug)
{
var existingTerm = _taxonomyService.GetTermByName(taxonomy.Id, termName);
if (existingTerm != null)
return existingTerm;
var term = _taxonomyService.NewTerm(taxonomy, parent);
_contentManager.Create(term, VersionOptions.Draft);
term.Weight = 0;
term.Name = termName.Trim();
if (!string.IsNullOrEmpty(termSlug) || !string.IsNullOrWhiteSpace(termSlug))
term.Slug = termSlug.Trim();
_contentManager.Publish(term.ContentItem);
return term;
}
示例7: GetDirectContentItemsQuery
public IContentQuery<TermsPart, TermsPartRecord> GetDirectContentItemsQuery(TermPart term, string fieldName = null)
{
var query = _contentManager
.Query<TermsPart, TermsPartRecord>();
if (String.IsNullOrWhiteSpace(fieldName))
{
query = query.Where(
tpr => tpr.Terms.Any(tr =>
tr.TermRecord.Id == term.Id));
}
else
{
query = query.Where(
tpr => tpr.Terms.Any(tr =>
tr.Field == fieldName
&& (tr.TermRecord.Id == term.Id)));
}
return query;
}
示例8: GetContentItemsQuery
public IContentQuery<TermsPart, TermsPartRecord> GetContentItemsQuery(TermPart term, string fieldName = null) {
var rootPath = term.FullPath + "/";
var query = _contentManager
.Query<TermsPart, TermsPartRecord>()
.WithQueryHints(new QueryHints().ExpandRecords<AutoroutePartRecord, TitlePartRecord, CommonPartRecord>());
if (String.IsNullOrWhiteSpace(fieldName)) {
query = query.Where(
tpr => tpr.Terms.Any(tr =>
tr.TermRecord.Id == term.Id
|| tr.TermRecord.Path.StartsWith(rootPath)));
} else {
query = query.Where(
tpr => tpr.Terms.Any(tr =>
tr.Field == fieldName
&& (tr.TermRecord.Id == term.Id || tr.TermRecord.Path.StartsWith(rootPath))));
}
return query;
}
示例9: DeleteTerm
public void DeleteTerm(TermPart termPart) {
_contentManager.Remove(termPart.ContentItem);
foreach(var childTerm in GetChildren(termPart)) {
_contentManager.Remove(childTerm.ContentItem);
}
// delete termContentItems
var termContentItems = _termContentItemRepository
.Fetch(t => t.TermRecord == termPart.Record)
.ToList();
foreach (var termContentItem in termContentItems) {
_termContentItemRepository.Delete(termContentItem);
}
}
示例10: GetChildren
public IEnumerable<TermPart> GetChildren(TermPart term, bool includeParent) {
var rootPath = term.FullPath + "/";
var result = _contentManager.Query<TermPart, TermPartRecord>()
.Where(x => x.Path.StartsWith(rootPath))
.List();
if (includeParent) {
result = result.Concat(new[] { term });
}
return TermPart.Sort(result);
}
示例11: GetTermNode
private TreeNode GetTermNode(TermPart term) {
return new TreeNode {
Title = term.Name,
Type = "taxonomy-term",
Id = term.Id.ToString(CultureInfo.InvariantCulture),
Url = _url.ItemEditUrl(term)
};
}
示例12: GetDirectChildren
public IEnumerable<TermPart> GetDirectChildren(TermPart term) {
var directChildren = GetContainables(term.Record.ContentItemRecord);
return directChildren.List();
}
示例13: GetParents
public IEnumerable<TermPart> GetParents(TermPart term) {
return term.Path.Split(new [] {'/'}, StringSplitOptions.RemoveEmptyEntries).Select(id => GetTerm(int.Parse(id)));
}
示例14: ProcessPath
public void ProcessPath(TermPart term) {
var parentTerm = term.Container.As<TermPart>();
term.Path = parentTerm != null ? parentTerm.FullPath + "/": "/";
}
示例15: GetHierarchyAlternates
public IEnumerable<string> GetHierarchyAlternates(TermPart part)
{
TermPart parent = part;
do {
yield return parent.Slug;
} while (null != (parent = parent.Container.As<TermPart>()));
}