Exemplo n.º 1
0
        public override void LoadFromXml(XmlElement e)
        {
            base.LoadFromXml(e);

            if (Type == ProMetaConst.DATATYPE_LOCALSTRUCT)
            {
                string lstr = XmlUtil.GetAttrStrVal(e, "struct-name", "");
                if (lstr == "")
                {
                    throw new exception.AnalysisException(String.Format("pro-meta/pro[{0}]/members/member type=local-struct must define struct-name property", owner_.Name));
                }

                ref_local_struct_ = owner_.GetLocalStructByName(lstr);
                if (ref_local_struct_ == null)
                {
                    throw new exception.AnalysisException(String.Format("pro-meta/pro[{0}]/members/member type=local-struct define struct-name[{1}] not exist", owner_.Name, lstr));
                }
            }

            if (Type == ProMetaConst.DATATYPE_GLOBALSTRUCT)
            {
                string lstr = XmlUtil.GetAttrStrVal(e, "struct-name", "");
                if (lstr == "")
                {
                    throw new exception.AnalysisException(String.Format("pro-meta/pro[{0}]/members/member type=global-struct must define struct-name property", owner_.Name));
                }

                ref_global_struct_ = ProMetaHelper.Instance().GetGlobalStructByName(lstr);
                if (ref_global_struct_ == null)
                {
                    throw new exception.AnalysisException(String.Format("pro-meta/pro[{0}]/members/member type=global-struct define struct-name[{1}] not exist", owner_.Name, lstr));
                }
            }
        }
Exemplo n.º 2
0
        public void AddLocalStruct(LocalStruct ls)
        {
            if (GetLocalStructByName(ls.Name) != null)
            {
                throw new exception.AnalysisException(String.Format("redefine {0} local struct on the protocol[{1}]", ls.Name, name_));
            }

            local_structs_.Add(ls);
        }
Exemplo n.º 3
0
        public virtual void LoadFromXml(XmlElement e)
        {
            name_ = XmlUtil.GetAttrStrVal(e, "name", "");
            if (name_ == "")
            {
                throw new exception.AnalysisException(String.Format("pro-region/pro-meta/pro node must define name property"));
            }

            pro_iid_ = XmlUtil.GetAttrStrVal(e, "id", "");
            if (pro_iid_ == "")
            {
                throw new exception.AnalysisException(String.Format("pro-region/pro-meta/pro node must define id property"));
            }

            onlyserver_ = XmlUtil.GetAttrBoolValByYesNo(e, "onlyserver", false);
            XmlElement desc = XmlUtil.GetFirstChildren(e, "desc");

            if (desc != null)
            {
                desc_ = XmlUtil.GetCDATAContent(desc);
            }

            XmlElement cb = XmlUtil.GetFirstChildren(e, "construct-block");

            if (cb != null)
            {
                XmlElement cbc = XmlUtil.GetFirstChildren(cb, "c");
                if (cbc != null)
                {
                    construct_block_c_ = XmlUtil.GetCDATAContent(cbc);
                }

                XmlElement cbj = XmlUtil.GetFirstChildren(cb, "java");
                if (cbj != null)
                {
                    construct_block_java_ = XmlUtil.GetCDATAContent(cbj);
                }
            }

            XmlElement db = XmlUtil.GetFirstChildren(e, "destruct-block");

            if (db != null)
            {
                XmlElement cbc = XmlUtil.GetFirstChildren(db, "c");
                if (cbc != null)
                {
                    destruct_block_c_ = XmlUtil.GetCDATAContent(cbc);
                }

                XmlElement cbj = XmlUtil.GetFirstChildren(db, "java");
                if (cbj != null)
                {
                    destruct_block_java_ = XmlUtil.GetCDATAContent(cbj);
                }
            }

            XmlElement cf = XmlUtil.GetFirstChildren(e, "custom-function");

            if (cf != null)
            {
                XmlElement cbc = XmlUtil.GetFirstChildren(cf, "c");
                if (cbc != null)
                {
                    custom_function_c_ = XmlUtil.GetCDATAContent(cbc);
                }

                XmlElement cbj = XmlUtil.GetFirstChildren(cf, "java");
                if (cbj != null)
                {
                    custom_function_java_ = XmlUtil.GetCDATAContent(cbj);
                }
            }

            //local-struct
            List <XmlElement> lss = XmlUtil.GetChildrenElement(e, "local-struct");

            foreach (XmlElement e1 in lss)
            {
                string name = XmlUtil.GetAttrStrVal(e1, "name", "");
                if (name == "")
                {
                    throw new exception.AnalysisException(String.Format("pro-meta/pro/local-struct node must define a name"));
                }
                LocalStruct ls = new LocalStruct(name, this);

                ls.LoadFromXml(e1);

                this.AddLocalStruct(ls);
            }

            //members
            XmlElement ms = XmlUtil.GetFirstChildren(e, "members");

            if (ms != null)
            {
                List <XmlElement> mm = XmlUtil.GetChildrenElement(ms, "member");
                foreach (XmlElement e1 in mm)
                {
                    ProMetaMember md = new ProMetaMember(this);
                    md.LoadFromXml(e1);

                    this.AddMember(md);
                }
            }
        }