Пример #1
0
        public int PathDepth()
        {
            int depth = 0;

            for (ModuleSpace p = Parent; null != p; p = p.Parent)
            {
                ++depth;
            }
            return(depth);
        }
Пример #2
0
        public ModuleSpace GetRootModuleSpace()
        {
            ModuleSpace last = this;

            for (ModuleSpace p = Parent; null != p; p = p.Parent)
            {
                last = p;
            }
            return(last);
        }
Пример #3
0
        public Module(ModuleSpace space, XmlElement self) : base(space, self, true)
        {
            if (space.Modules.ContainsKey(Name))
            {
                throw new Exception("duplicate module name:" + Name);
            }
            space.Modules.Add(Name, this);
            Program.AddNamedObject(Path(".", $"Module{Name}"), this);
            Program.AddNamedObject(Path(".", "AbstractModule"), this);

            XmlNodeList childNodes = self.ChildNodes;

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

                XmlElement e = (XmlElement)node;
                switch (e.Name)
                {
                case "enum":
                    Add(new Types.Enum(e));
                    break;

                case "bean":
                    new Types.Bean(this, e);
                    break;

                case "module":
                    new Module(this, e);
                    break;

                case "protocol":
                    new Protocol(this, e);
                    break;

                case "rpc":
                    new Rpc(this, e);
                    break;

                case "table":
                    new Table(this, e);
                    break;

                case "beankey":
                    new BeanKey(this, e);
                    break;

                default:
                    throw new Exception("unknown nodename=" + e.Name + " in module=" + Path());
                }
            }
        }
Пример #4
0
        public Table(ModuleSpace space, XmlElement self)
        {
            Space = space;
            Name  = self.GetAttribute("name").Trim();
            space.Add(this);

            Key   = self.GetAttribute("key");
            Value = self.GetAttribute("value");
            Gen   = self.GetAttribute("gen");
            string attr = self.GetAttribute("memory");

            IsMemory  = attr.Length > 0 ? bool.Parse(attr) : false;
            attr      = self.GetAttribute("autokey");
            IsAutoKey = attr.Length > 0 ? bool.Parse(attr) : false;
        }
Пример #5
0
        public string PathPinyin(string sep = ".", string ObjectName = null)
        {
            string path = NamePinyin;

            for (ModuleSpace p = Parent; null != p; p = p.Parent)
            {
                path = p.NamePinyin + sep + path;
            }
            if (null == ObjectName)
            {
                return(path);
            }

            return(path + sep + ObjectName);
        }
Пример #6
0
        public ModuleSpace(ModuleSpace parent, XmlElement self, bool hasId = false)
        {
            Parent = parent;
            Name   = self.GetAttribute("name").Trim();
            Program.CheckReserveName(Name);

            if (hasId)
            {
                Id = short.Parse(self.GetAttribute("id"));
                if (Id <= 0)
                {
                    throw new Exception("module id <= 0 is reserved. @" + this.Path());
                }

                Solution.ModuleIdAllowRanges.AssertInclude(Id);
                Solution.ModuleIdCurrentRanges.CheckAdd(Id);
            }
        }
Пример #7
0
        public Protocol(ModuleSpace space, XmlElement self)
        {
            Space = space;
            Name  = self.GetAttribute("name").Trim();
            space.Add(this);

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

            Id = attr.Length > 0 ? ushort.Parse(attr) : Zeze.Transaction.Bean.Hash16(space.Path(".", Name));
            space.ProtocolIdRanges.CheckAdd(Id);

            Argument    = self.GetAttribute("argument");
            Handle      = self.GetAttribute("handle");
            HandleFlags = Program.ToHandleFlags(Handle);
            NoProcedure = "true".Equals(self.GetAttribute("NoProcedure"));

            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 "enum":
                    Add(new Types.Enum(e));
                    break;

                default:
                    throw new Exception("node=" + nodename);
                }
            }
        }
Пример #8
0
 public Rpc(ModuleSpace space, XmlElement self) : base(space, self)
 {
     Result = self.GetAttribute("result");
 }