Microsoft 365 and Office | Development | Other
Building custom solutions that extend, automate, and integrate Microsoft 365 apps.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In older versions of OpenXml-sdk, every element has ChildInfoAttributes. So, it was enough to look at the list of ChildInfoAttribute to determine which types of elements it can accept as a child. Recent versions of OpenXml-Sdk removed this.
//Doesn't work in recent versions of OpenXml-Sdk
bool IsLegitChild(Type parent, Type children)
{
var childInfos =
(ChildElementInfoAttribute[]) Attribute.GetCustomAttributes(
parent,
typeof(ChildElementInfoAttribute));
return childInfos.Any(x => x.ElementType == children);
}
How to implement this in recent versions of OpenXml-Sdk?