Что-то подобное должно делать?
Ниже я добавляю свойство текстовой строки к типу носителя изображения по умолчанию.Я даже тестировал его только сейчас, и он работает: -)
Существует перегрузка для метода AddPropertyType, который позволяет вам добавлять свойство в данную группу вкладок / свойств при необходимости.
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var dataTypeService = ApplicationContext.Current.Services.DataTypeService;
var mediaType = contentTypeService.GetMediaType(1032);
if (mediaType != null && !mediaType.PropertyTypeExists("myNewPropertyAlias"))
{
var dataTypeDefinitions = dataTypeService.GetAllDataTypeDefinitions().ToArray();
var textStringDataTypeDefinition = dataTypeDefinitions.FirstOrDefault(p => p.Name.ToLower() == "textstring");
mediaType.AddPropertyType(new PropertyType(textStringDataTypeDefinition) { Name = "My New Property Name", Alias = "myNewPropertyAlias" });
contentTypeService.Save(mediaType);
}
}