Ejemplo n.º 1
0
        /// <summary>
        /// Returns the acionmals contained in the profile xml string
        /// </summary>
        /// <param name="xml">A default profile XML string</param>
        /// <returns>A filled SCActionMapList object</returns>
        public SCActionMapList ActionMapList(string xml)
        {
            log.Debug("DProfileReader.ActionMapList - Entry");

            SCActionMapList   aml      = new SCActionMapList( );
            XmlReaderSettings settings = new XmlReaderSettings {
                ConformanceLevel = ConformanceLevel.Fragment,
                IgnoreWhitespace = true,
                IgnoreComments   = true
            };

            using (XmlReader reader = XmlReader.Create(new StringReader(xml), settings)) {
                reader.MoveToContent( );
                if (XNode.ReadFrom(reader) is XElement el)
                {
                    IEnumerable <XElement> actionmaps = from x in el.Elements( )
                                                        where (x.Name == "actionmap")
                                                        select x;
                    foreach (XElement actionmap in actionmaps)
                    {
                        aml.AddActionMap((string)actionmap.Attribute("name"));
                    }
                }
            }
            return(aml);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the acionmals contained in the profile xml string
        /// </summary>
        /// <param name="xml">A default profile XML string</param>
        /// <returns>A filled SCActionMapList object</returns>
        public SCActionMapList ActionMapList(string xml)
        {
            SCActionMapList aml = new SCActionMapList();

            log.Debug("DProfileReader.ActionMapList - Entry");

            XmlReaderSettings settings = new XmlReaderSettings( );

            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments   = true;
            XmlReader reader = XmlReader.Create(new StringReader(xml), settings);

            reader.Read( );
            if (!reader.ReadToFollowing("actionmap"))
            {
                return(aml);                                    // ERROR empty one..
            }
            do
            {
                string attr = reader["name"];
                if (!string.IsNullOrEmpty(attr))
                {
                    aml.AddActionMap(attr);
                }
            } while (reader.ReadToFollowing("actionmap"));

            return(aml);
        }