getInt() public method

public getInt ( String key ) : int
key String
return int
Exemplo n.º 1
0
        protected void DoInit(String xml)
        {
            Util.tryInitCache();

            {
                root = XDocument.Parse(xml).Root;
                foreach (var att in root.Attributes())
                {
                    attrs.set(att.Name.LocalName, att.Value);
                }
            }

            {
                foreach (var p in root.Elements())
                {
                    if (p.HasAttributes == false)
                    {
                        if (new List <XNode>(p.Nodes()).Count == 1)
                        {
                            var p2 = p.FirstNode;
                            if (p2 != null && p2.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                attrs.set(p.Name.LocalName, p.Value);
                            }
                        }
                    }
                }
            }

            schema  = attrs.getInt("schema");
            isDebug = attrs.getInt("debug") > 0;
        }
Exemplo n.º 2
0
        internal SdNodeSet buildForNode(XElement element)
        {
            if (element == null)
            {
                return(this);
            }

            name = element.Name.LocalName;

            _items.Clear();
            attrs.clear();

            {
                foreach (var p in element.Attributes())
                {
                    attrs.set(p.Name.LocalName, p.Value);
                }

                foreach (var p in element.Elements())
                {
                    if (p.HasAttributes == false)
                    {
                        if (new List <XNode>(p.Nodes()).Count == 1)
                        {
                            var p2 = p.FirstNode;
                            if (p2 != null && p2.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                attrs.set(p.Name.LocalName, p.Value);
                            }
                        }
                    }
                }
            }

            _dtype = attrs.getInt("dtype");

            foreach (XElement e1 in element.Elements())
            {
                if (e1.HasAttributes)
                {
                    SdNode temp = Util.createNode(source).buildForNode(e1);
                    this.add(temp);
                }
                else if (e1.HasElements)
                {
                    SdNodeSet temp = Util.createNodeSet(source).buildForNode(e1);
                    this.add(temp);
                }
            }

            OnDidInit();

            return(this);
        }
Exemplo n.º 3
0
        internal SdNode buildForNode(XElement cfg)
        {
            _isEmpty = (cfg == null);

            if (cfg != null)
            {
                this.name = cfg.Name.LocalName;

                foreach (XAttribute att in cfg.Attributes())
                {
                    attrs.set(att.Name.LocalName, att.Value);
                }

                _dtype = attrs.getInt("dtype");
                _btype = attrs.getInt("btype");

                this.title    = attrs.getString("title");
                this.method   = attrs.getString("method", "get");
                this.parse    = attrs.getString("parse");
                this.parseUrl = attrs.getString("parseUrl");
                this.url      = attrs.getString("url");
                this.lib      = attrs.getString("lib");
                this.expr     = attrs.getString("expr");

                this._encode = attrs.getString("encode");
                this._ua     = attrs.getString("ua");

                //book,section 特有
                this.header = attrs.getString("header", "");

                this.buildArgs   = attrs.getString("buildArgs");
                this.buildRef    = attrs.getString("buildRef");
                this.buildUrl    = attrs.getString("buildUrl");
                this.buildHeader = attrs.getString("buildHeader");

                this.args = attrs.getString("args");

                this.addCookie = attrs.getString("addCookie");
                this.addKey    = attrs.getString("addKey");
                this.addPage   = attrs.getInt("addPage");

                {
                    string temp = cfg.Attribute("cache")?.Value;
                    if (string.IsNullOrEmpty(temp) == false)
                    {
                        int len = temp.Length;
                        if (len == 1)
                        {
                            cache = int.Parse(temp);
                        }
                        else if (len > 1)
                        {
                            cache = int.Parse(temp.Substring(0, len - 1));

                            string p = temp.Substring(len - 1);
                            switch (p)
                            {
                            case "d": cache = cache * 24 * 60 * 60; break;

                            case "h": cache = cache * 60 * 60; break;

                            case "m": cache = cache * 60; break;
                            }
                        }
                    }
                }



                if (cfg.HasElements)
                {
                    _items = new List <SdNode>();
                    _adds  = new List <SdNode>();

                    foreach (XElement e1 in cfg.Elements())
                    {
                        if (e1.Name.LocalName.Equals("item"))
                        {
                            SdNode temp = Util.createNode(source).buildForItem(e1, this);
                            _items.Add(temp);
                        }
                        else if (e1.HasAttributes)
                        {
                            SdNode temp = Util.createNode(source).buildForAdd(e1, this);
                            _adds.Add(temp);
                        }
                        else
                        {
                            attrs.set(e1.Name.LocalName, e1.Value);
                        }
                    }
                }
            }

            OnDidInit();

            return(this);
        }