Finds all controls in the InfoPathViews
Inheritance: InfoPathFeature
Esempio n. 1
0
        /// <summary>
        /// Instead of logging on feature per control, I do 1 feature per control type along with the number of occurrences
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public static IEnumerable<InfoPathFeature> ParseFeature(XDocument document)
        {
            PublishUrl pubRule = new PublishUrl();
            IEnumerable<XElement> allElements = document.Descendants(xsf3Namespace + baseUrl);
            // collect the control counts
            foreach (XElement element in allElements)
            {
                if (pubRule.RelativeBase != null) throw new ArgumentException("Should only see one xsf3:baseUrl node");
                XAttribute pathAttribute = element.Attribute(relativeUrlBaseAttribute);
                if (pathAttribute != null) // this attribute is technically optional per xsf3 spec
                {
                    pubRule.RelativeBase = pathAttribute.Value;
                }
            }

            allElements = document.Descendants(xsfNamespace + xDocumentClass);
            foreach (XElement element in allElements)
            {
                if (pubRule.Publish != null) throw new ArgumentException("Should only see one xsf:xDocumentClass node");
                XAttribute pubUrl = element.Attribute(publishUrlAttribute);
                if (pubUrl != null)
                {
                    pubRule.Publish = pubUrl.Value;
                }
            }

            yield return pubRule;
            // nothing left
            yield break;
        }
Esempio n. 2
0
        /// <summary>
        /// Instead of logging on feature per control, I do 1 feature per control type along with the number of occurrences
        /// </summary>
        /// <param name="document"></param>
        /// <returns></returns>
        public static IEnumerable <InfoPathFeature> ParseFeature(XDocument document)
        {
            PublishUrl             pubRule     = new PublishUrl();
            IEnumerable <XElement> allElements = document.Descendants(xsf3Namespace + baseUrl);

            // collect the control counts
            foreach (XElement element in allElements)
            {
                if (pubRule.RelativeBase != null)
                {
                    throw new ArgumentException("Should only see one xsf3:baseUrl node");
                }
                XAttribute pathAttribute = element.Attribute(relativeUrlBaseAttribute);
                if (pathAttribute != null)                 // this attribute is technically optional per xsf3 spec
                {
                    pubRule.RelativeBase = pathAttribute.Value;
                }
            }

            allElements = document.Descendants(xsfNamespace + xDocumentClass);
            foreach (XElement element in allElements)
            {
                if (pubRule.Publish != null)
                {
                    throw new ArgumentException("Should only see one xsf:xDocumentClass node");
                }
                XAttribute pubUrl = element.Attribute(publishUrlAttribute);
                if (pubUrl != null)
                {
                    pubRule.Publish = pubUrl.Value;
                }
            }

            yield return(pubRule);

            // nothing left
            yield break;
        }