-
Notifications
You must be signed in to change notification settings - Fork 575
Closed
Labels
Description
When trying to modify a document, one needs to know if a particular element can add a particular child before doing so. Before, this was one way of doing so which is no longer works:
public static bool CanAddChild<T>(this OpenXmlElement element)
{
if (element == null)
return false;
var attributes = element.GetType().GetCustomAttributes<ChildElementInfoAttribute>();
return attributes.Any(r => r.ElementType == typeof(T));
}There does not appear to be a way to do this anymore as all of the metadata information is internal and created in the internal ConfigureMetadata override.
Describe the solution you'd like
An API such as the above to determine and/or list the valid children of a given element.
Describe alternatives you've considered
One way might be to add the child then validate it, but this seems the wrong approach.