Ejemplo n.º 1
0
        public void SaveAs(XmlDocument xml, XmlElement parent, bool create)
        {
            XmlElement self = create ? null : Self;

            if (null == Name) // 添加在beandefine尾部的var,不需要保存。应该是没有加到Bean.Varaibles里面的。
            {
                return;
            }

            if (null == self)
            {
                self = xml.CreateElement("variable");
                parent.AppendChild(self);
                if (false == create)
                {
                    Self = self;
                }
            }

            self.SetAttribute("name", Name);
            SetAttribute(self, "type", System.Enum.GetName(typeof(EType), Type));
            SetAttribute(self, "value", Value);
            SetAttribute(self, "foreign", Foreign);
            SetAttribute(self, "properties", Properties);
            SetAttribute(self, "comment", Comment);
            SetAttribute(self, "default", Default);

            if (GridColumnNameWidth > 0)
            {
                self.SetAttribute("nw", GridColumnNameWidth.ToString());
            }
            if (GridColumnValueWidth > 0)
            {
                self.SetAttribute("vw", GridColumnValueWidth.ToString());
            }
        }
Ejemplo n.º 2
0
Archivo: Bean.cs Proyecto: e2wugui/zeze
            public void SaveAs(XmlDocument xml, XmlElement parent, bool create, Property.DataOutputFlags flags)
            {
                XmlElement self     = create ? null : Self;
                XmlElement selfList = create ? null : SelfList;

                if (null == self)
                {
                    // new
                    self = xml.CreateElement(Name);
                    parent.AppendChild(self);
                    if (false == create)
                    {
                        Self = self;
                    }
                }
                else
                {
                    if (self.Name != Name)
                    {
                        // Name Change
                        XmlElement e = xml.CreateElement(Name);
                        parent.ReplaceChild(e, self);
                        self = e;
                        if (null != selfList)
                        {
                            self.AppendChild(selfList);
                        }
                    }
                }

                if (flags == Property.DataOutputFlags.All)
                {
                    if (GridColumnNameWidth > 0)
                    {
                        self.SetAttribute("nw", GridColumnNameWidth.ToString());
                    }
                    if (GridColumnValueWidth > 0)
                    {
                        self.SetAttribute("vw", GridColumnValueWidth.ToString());
                    }
                }

                if (_Beans.Count > 0) // 这里没有判断Type,直接根据数据来决定怎么保存。
                {
                    if (null == selfList)
                    {
                        selfList = xml.CreateElement("list");
                        self.AppendChild(selfList);
                        if (false == create)
                        {
                            SelfList = selfList;
                        }
                    }
                    for (int i = 0; i < _Beans.Count; ++i)
                    {
                        Bean b = _Beans[i];
                        b.RowIndex = i;
                        b.SaveAs(xml, selfList, create, flags);
                    }
                }
                else
                {
                    self.InnerText = Value;
                }
            }