コード例 #1
0
        /// <summary>
        /// Gets all the parts needs to be validated.
        /// </summary>
        private IEnumerable <OpenXmlPart> PartsToBeValidated(OpenXmlPackage package)
        {
            var mainPart = package.RootPart;

            if (mainPart != null)
            {
                var parts = new Dictionary <OpenXmlPart, bool>();
                package.FindAllReachableParts(parts);

                foreach (var part in parts.Keys)
                {
                    // Only validate the parts defined in the specified version.
                    // Example: do not validate new Office2010 parts if the FileFormat is Office2007.
                    if (part.IsInVersion(_cache.Version))
                    {
                        yield return(part);
                    }
                }
            }
        }