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


C# IContentDefinitionManager.DeleteTypeDefinition方法代码示例

本文整理汇总了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;
                }
            });
        }
开发者ID:wezmag,项目名称:Coevery,代码行数:42,代码来源:TaxonomyPartHandler.cs

示例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;
                }
            });
        }
开发者ID:wezmag,项目名称:Coevery,代码行数:41,代码来源:OptionSetPartHandler.cs


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