public override IEnumerable <TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
        {
            if (_typeHasProfilePart)
            {
                var settings = new ProfileFrontEndSettings();
                if (updateModel.TryUpdateModel(settings, "ProfileFrontEndSettings", null, null))
                {
                    ProfileFrontEndSettings.SetValues(builder, settings.AllowFrontEndDisplay, settings.AllowFrontEndEdit);

                    // Update the type settings
                    var partDefinition = _contentDefinitionManager.GetPartDefinition(builder.PartName);
                    var typeDefinition = _typeBuilder.Current;

                    // At this stage, the settings in the FieldDefinition are not updated, so the IFrontEndProfileService
                    // has no way of knowing whether the value of settings.AllowFrontEndEdit has changed. We need to pass
                    // it along to be used.
                    var fieldPlacements = GetEditorPlacement(typeDefinition, partDefinition, builder.Current, settings.AllowFrontEndEdit);
                    if (fieldPlacements.Any())
                    {
                        UpdateFrontEndPlacements(typeDefinition, fieldPlacements);
                        //// schedules a re-evaluation of the shell
                        //_settingsManagerEventHandlers.Value.Invoke(x => x.Saved(_shellSettings), Logger);
                    }
                }
                yield return(DefinitionTemplate(settings));
            }
        }
        public override IEnumerable <TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
        {
            var typeDefinition = _contentDefinitionManager.GetTypeDefinition(builder.TypeName);

            if (_typeHasProfilePart ||
                typeDefinition.Parts.Any(ctpd => ctpd.PartDefinition.Name == "ProfilePart"))
            {
                _typeHasProfilePart = true;
                var settings = new ProfileFrontEndSettings();
                if (updateModel.TryUpdateModel(settings, "ProfileFrontEndSettings", null, null))
                {
                    ProfileFrontEndSettings.SetValues(builder, settings.AllowFrontEndDisplay, settings.AllowFrontEndEdit);

                    // Update the type settings
                    var partDefinition = typeDefinition.Parts
                                         .FirstOrDefault(ctpd => ctpd.PartDefinition.Name == builder.Name)?.PartDefinition;
                    if (partDefinition != null)   // sanity check
                    // At this stage, the settings in the PartDefinition are not updated, so the IFrontEndProfileService
                    // has no way of knowing whether the value of settings.AllowFrontEndEdit has changed. We need to
                    // pass it along to be used.
                    {
                        var partPlacements = GetEditorPlacement(typeDefinition, partDefinition, settings.AllowFrontEndEdit);
                        if (partPlacements.Any())
                        {
                            UpdateFrontEndPlacements(typeDefinition, partPlacements);
                            //// schedules a re-evaluation of the shell
                            //_settingsManagerEventHandlers.Value.Invoke(x => x.Saved(_shellSettings), Logger);
                        }
                    }
                }

                yield return(DefinitionTemplate(settings));
            }
        }