Esempio n. 1
0
File: Type.cs Progetto: e2wugui/zeze
        public static Type Compile(ModuleSpace space, String name, String key, String value)
        {
            Type type = null;

            if (Types.TryGetValue(name, out type))
            {
                return(type.Compile(space, key, value));
            }

            if (false == Program.IsFullName(name))
            {
                name = space.Path(".", name);
                if (Types.TryGetValue(name, out type))
                {
                    return(type.Compile(space, key, value));
                }
            }

            throw new Exception("type NOT FOUND! '" + name + "'" + key + "." + value);
        }
Esempio n. 2
0
        // ///////////////////////////////////////////
        public Bean(ModuleSpace space, XmlElement self)
        {
            Space = space;
            _name = self.GetAttribute("name").Trim();
            Program.CheckReserveName(_name);
            Type.Add(space, this);
            space.Add(this);

            // previous sibling comment
            Comment = self.GetAttribute("comment");
            string attr = self.GetAttribute("TypeId");

            TypeId = attr.Length > 0 ? int.Parse(attr) : Zeze.Transaction.Bean.Hash64(space.Path(".", _name));
            if (false == Program.BeanTypeIdDuplicateChecker.Add(TypeId))
            {
                throw new Exception("duplicate Bean.TypeId, please choice one.");
            }

            if (Comment.Length == 0)
            {
                for (XmlNode c = self.PreviousSibling; null != c; c = c.PreviousSibling)
                {
                    if (XmlNodeType.Element == c.NodeType)
                    {
                        break;
                    }
                    if (XmlNodeType.Comment == c.NodeType)
                    {
                        Comment = c.InnerText.Trim();
                        break;
                    }
                }
            }

            XmlNodeList childNodes = self.ChildNodes;

            foreach (XmlNode node in childNodes)
            {
                if (XmlNodeType.Element != node.NodeType)
                {
                    continue;
                }

                XmlElement e = (XmlElement)node;

                String nodename = e.Name;
                switch (e.Name)
                {
                case "variable":
                    Add(new Variable(this, e));
                    break;

                case "enum":
                    Add(new Enum(e));
                    break;

                default:
                    throw new Exception("node=" + nodename);
                }
            }
        }
Esempio n. 3
0
        // ///////////////////////////////////////////
        public BeanKey(ModuleSpace space, XmlElement self)
        {
            Space = space;
            _name = self.GetAttribute("name").Trim();
            Program.CheckReserveName(_name);
            Type.Add(space, this);
            space.Add(this);

            string attr = self.GetAttribute("TypeId");

            TypeId = attr.Length > 0 ? int.Parse(attr) : Zeze.Transaction.Bean.Hash64(space.Path(".", _name));
            if (false == Program.BeanTypeIdDuplicateChecker.Add(TypeId))
            {
                throw new Exception("duplicate Bean.TypeId, please choice one.");
            }

            parse(self);
        }