本文整理汇总了C#中IContentDefinitionManager.DeleteTypeDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# IContentDefinitionManager.DeleteTypeDefinition方法的具体用法?C# IContentDefinitionManager.DeleteTypeDefinition怎么用?C# IContentDefinitionManager.DeleteTypeDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContentDefinitionManager
的用法示例。
在下文中一共展示了IContentDefinitionManager.DeleteTypeDefinition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TaxonomyPartHandler
public TaxonomyPartHandler(
IRepository<TaxonomyPartRecord> repository,
ITaxonomyService taxonomyService,
IContentDefinitionManager contentDefinitionManager) {
string previousName = null;
Filters.Add(StorageFilter.For(repository));
OnPublished<TaxonomyPart>((context, part) => {
var previousTermTypeName = part.TermTypeName;
taxonomyService.CreateTermContentType(part);
if (previousName != null && part.Name != previousName) {
// remove previous term type
contentDefinitionManager.DeleteTypeDefinition(previousTermTypeName);
// update existing fields
foreach (var partDefinition in contentDefinitionManager.ListPartDefinitions()) {
foreach (var field in partDefinition.Fields) {
if (field.FieldDefinition.Name == typeof (TaxonomyField).Name) {
if (field.Settings.GetModel<TaxonomyFieldSettings>().Taxonomy == previousName) {
contentDefinitionManager.AlterPartDefinition(partDefinition.Name,
cfg => cfg.WithField(field.Name,
builder => builder.WithSetting("TaxonomyFieldSettings.Taxonomy", part.Name)));
}
}
}
}
}
});
OnLoading<TaxonomyPart>( (context, part) => part.TermsField.Loader(x => taxonomyService.GetTerms(part.Id)));
OnUpdating<TitlePart>((context, part) => {
// if altering the title of a taxonomy, save the name
if (part.As<TaxonomyPart>() != null) {
previousName = part.Title;
}
});
}
示例2: OptionSetPartHandler
public OptionSetPartHandler(
IRepository<OptionSetPartRecord> repository,
IOptionSetService optionSetService,
IContentDefinitionManager contentDefinitionManager) {
int? previousId = null;
Filters.Add(StorageFilter.For(repository));
OnPublished<OptionSetPart>((context, part) => {
var previousTermTypeName = part.TermTypeName;
if (previousId != null && part.Id != previousId) {
// remove previous term type
contentDefinitionManager.DeleteTypeDefinition(previousTermTypeName);
// update existing fields
foreach (var partDefinition in contentDefinitionManager.ListPartDefinitions()) {
foreach (var field in partDefinition.Fields) {
if (field.FieldDefinition.Name == typeof (OptionSetField).Name) {
if (field.Settings.GetModel<OptionSetFieldSettings>().OptionSetId == previousId) {
contentDefinitionManager.AlterPartDefinition(partDefinition.Name,
cfg => cfg.WithField(field.Name,
builder => builder.WithSetting("TaxonomyFieldSettings.TaxonomyId", part.Id.ToString())));
}
}
}
}
}
});
OnLoading<OptionSetPart>((context, part) => part.OptionItemsField.Loader(x => optionSetService.GetOptionItems(part.Id)));
OnUpdating<TitlePart>((context, part) => {
// if altering the title of a taxonomy, save the name
if (part.As<OptionSetPart>() != null) {
previousId = part.Id;
}
});
}