Доработан winui
This commit is contained in:
@@ -37,6 +37,10 @@ public class ContentRegistry
|
||||
if (factory == null)
|
||||
throw new ArgumentNullException(nameof(factory));
|
||||
|
||||
// Дополнительная проверка на пустую строку
|
||||
if (string.IsNullOrEmpty(contentTypeId.Trim()))
|
||||
throw new ArgumentException("Идентификатор типа контента не может быть пустой строкой.", nameof(contentTypeId));
|
||||
|
||||
if (_contentTypes.ContainsKey(contentTypeId))
|
||||
throw new ArgumentException($"Тип контента '{contentTypeId}' уже зарегистрирован.");
|
||||
|
||||
@@ -70,13 +74,7 @@ public class ContentRegistry
|
||||
throw new KeyNotFoundException($"Тип контента '{contentTypeId}' не зарегистрирован.");
|
||||
|
||||
var content = descriptor.Factory();
|
||||
|
||||
// Устанавливаем ID через рефлексию, если есть свойство Id
|
||||
var property = content.GetType().GetProperty("Id");
|
||||
if (property != null && property.CanWrite)
|
||||
{
|
||||
property.SetValue(content, id);
|
||||
}
|
||||
content.SetId(id);
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user