예제 #1
0
        /// <summary>
        /// 向XML节点保存对象数据
        /// </summary>
        /// <param name="myElement">XML节点</param>
        /// <returns>保存是否成功</returns>
        public virtual bool ToXML(System.Xml.XmlElement myElement)
        {
            switch (myOwnerDocument.Info.SaveMode)
            {
            case 0:     // 保存所有数据
                myAttributes.ToXML(myElement);
                break;

            case 1:     // 只保存文本数据
                if (this.isField())
                {
                    myElement.SetAttribute(ZYTextConst.c_Name, myAttributes.GetString(ZYTextConst.c_Name));
                    if (StringCommon.isBlankString(myAttributes.GetString(ZYTextConst.c_ID)))
                    {
                        myAttributes.SetValue(ZYTextConst.c_ID, StringCommon.AllocObjectName());
                    }
                    myElement.SetAttribute(ZYTextConst.c_ID, myAttributes.GetString(ZYTextConst.c_ID));
                    myElement.InnerText = this.ToEMRString();
                }
                break;

            case 2:     // 只保存结构化数据
                if (this.isField())
                {
                    myElement.SetAttribute(ZYTextConst.c_Name, myAttributes.GetString(ZYTextConst.c_Name));
                    if (StringCommon.isBlankString(myAttributes.GetString(ZYTextConst.c_ID)))
                    {
                        myAttributes.SetValue(ZYTextConst.c_ID, StringCommon.AllocObjectName());
                    }
                    myElement.SetAttribute(ZYTextConst.c_ID, myAttributes.GetString(ZYTextConst.c_ID));
                    myElement.InnerText = this.ToEMRString();
                }
                break;
            }
            return(true);
        }