Select() public method

public Select ( XPathNavigator top, string path ) : XPathNodeIterator
top System.Xml.XPath.XPathNavigator
path string
return System.Xml.XPath.XPathNodeIterator
Exemplo n.º 1
0
        /// <summary>
        /// Loads a configuration file passed to the new Swiffotron and parses it,
        /// creating any implementing classes named in the configuration.
        /// </summary>
        /// <param name="configXml">A stream ready and primed with lovely XML
        /// configuration data.</param>
        private void LoadConfigXML(Stream configXml)
        {
            this.Xml = new XMLHelper();
            this.Xml.SetContext(new SwiffotronContext("Swiffotron configuration"));

            Xml.LoadConfigurationXML(configXml);

            /* First, set up any caches: */
            XmlAttribute attrib;
            foreach (XPathNavigator hit in Xml.Select(@"/con:config/con:cache"))
            {
                XmlAttributeCollection attribs = ((XmlElement)hit.UnderlyingObject).Attributes;

                /* The schema defines these attributes as mandatory, so they will exist: */
                string name = attribs[@"name"].Value;
                string classname = attribs[@"classname"].Value;

                /* Optional parameters, which we default to null before we call Initialise on
                 * any implementor. */
                attrib = attribs[@"init"];
                string init = (attrib == null) ? null : attrib.Value;
                attrib = attribs[@"assembly"];
                string assembly = (attrib == null) ? null : attrib.Value;

                /* Create our named cache as specified by our config file. */
                ISwiffotronCache newCache = Extern.CreateCache(name, assembly, classname, init);

                /* Use Add method here to ensure that the name is unique. Key errors get thrown
                 * upwards and destroy the app. Hey, fix your config file, user. */
                this.Caches.Register(name, newCache);

            }

            /* Now, set up any stores: */

            foreach (XPathNavigator hit in Xml.Select(@"/con:config/con:store"))
            {
                XmlAttributeCollection attribs = ((XmlElement)hit.UnderlyingObject).Attributes;

                /* The schema defines these attributes as mandatory, so they will exist: */
                string name = attribs[@"name"].Value;
                string classname = attribs[@"classname"].Value;

                /* Optional parameter, which we default to null before we call Initialise on
                 * any implementor. */
                attrib = attribs[@"init"];
                string init = (attrib == null) ? null : attrib.Value;
                attrib = attribs[@"assembly"];
                string assembly = (attrib == null) ? null : attrib.Value;

                /* Create our named store as specified by our config file. */
                ISwiffotronStore newStore = Extern.CreateStore(name, assembly, classname, init);

                /* Use Add method here rather than the index operator to ensure that the
                 * name is unique. Key errors get thrown upwards and destroy the app.
                 * Hey, fix your config file, user. */
                this.Stores.Register(name, newStore);

            }

            /* ISSUE 68: Staggeringly inefficient xpath queries that navigate from the root node every damned
             * time. Do we care? */

            this.EnableStoreWrites = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:storeWriteEnabled/text()");

            this.swfReaderOptions = new SWFReaderOptions()
            {
                StrictTagLength = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:stricttaglength/text()")
            };

            this.swfWriterOptions = new SWFWriterOptions()
            {
                Compressed = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:compression/text()"),
                EnableDebugger = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:debugcode/text()")
            };

            string htmlType = Xml.SelectString(@"/con:config/con:htmlType/text()", "JQuery");
            this.HTMLType = (SWF2HTMLOptions.FrameworkType)Enum.Parse(typeof(SWF2HTMLOptions.FrameworkType), htmlType);
            this.HTMLStandalone = Xml.SelectBoolean(@"/con:config/con:htmlStandalone/text()", false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads a configuration file passed to the new Swiffotron and parses it,
        /// creating any implementing classes named in the configuration.
        /// </summary>
        /// <param name="configXml">A stream ready and primed with lovely XML
        /// configuration data.</param>
        private void LoadConfigXML(Stream configXml)
        {
            this.Xml = new XMLHelper();
            this.Xml.SetContext(new SwiffotronContext("Swiffotron configuration"));

            Xml.LoadConfigurationXML(configXml);

            /* First, set up any caches: */
            XmlAttribute attrib;

            foreach (XPathNavigator hit in Xml.Select(@"/con:config/con:cache"))
            {
                XmlAttributeCollection attribs = ((XmlElement)hit.UnderlyingObject).Attributes;

                /* The schema defines these attributes as mandatory, so they will exist: */
                string name      = attribs[@"name"].Value;
                string classname = attribs[@"classname"].Value;

                /* Optional parameters, which we default to null before we call Initialise on
                 * any implementor. */
                attrib = attribs[@"init"];
                string init = (attrib == null) ? null : attrib.Value;
                attrib = attribs[@"assembly"];
                string assembly = (attrib == null) ? null : attrib.Value;

                /* Create our named cache as specified by our config file. */
                ISwiffotronCache newCache = Extern.CreateCache(name, assembly, classname, init);

                /* Use Add method here to ensure that the name is unique. Key errors get thrown
                 * upwards and destroy the app. Hey, fix your config file, user. */
                this.Caches.Register(name, newCache);
            }

            /* Now, set up any stores: */

            foreach (XPathNavigator hit in Xml.Select(@"/con:config/con:store"))
            {
                XmlAttributeCollection attribs = ((XmlElement)hit.UnderlyingObject).Attributes;

                /* The schema defines these attributes as mandatory, so they will exist: */
                string name      = attribs[@"name"].Value;
                string classname = attribs[@"classname"].Value;

                /* Optional parameter, which we default to null before we call Initialise on
                 * any implementor. */
                attrib = attribs[@"init"];
                string init = (attrib == null) ? null : attrib.Value;
                attrib = attribs[@"assembly"];
                string assembly = (attrib == null) ? null : attrib.Value;

                /* Create our named store as specified by our config file. */
                ISwiffotronStore newStore = Extern.CreateStore(name, assembly, classname, init);

                /* Use Add method here rather than the index operator to ensure that the
                 * name is unique. Key errors get thrown upwards and destroy the app.
                 * Hey, fix your config file, user. */
                this.Stores.Register(name, newStore);
            }

            /* ISSUE 68: Staggeringly inefficient xpath queries that navigate from the root node every damned
             * time. Do we care? */

            this.EnableStoreWrites = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:storeWriteEnabled/text()");

            this.swfReaderOptions = new SWFReaderOptions()
            {
                StrictTagLength = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:stricttaglength/text()")
            };

            this.swfWriterOptions = new SWFWriterOptions()
            {
                Compressed     = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:compression/text()"),
                EnableDebugger = Xml.SelectBoolean(@"/con:config/con:swfprefs/con:debugcode/text()")
            };

            string htmlType = Xml.SelectString(@"/con:config/con:htmlType/text()", "JQuery");

            this.HTMLType       = (SWF2HTMLOptions.FrameworkType)Enum.Parse(typeof(SWF2HTMLOptions.FrameworkType), htmlType);
            this.HTMLStandalone = Xml.SelectBoolean(@"/con:config/con:htmlStandalone/text()", false);
        }