public void Serialize(XElement node, XmlSerializeContext context)
        {
            List <int> idList = new List <int>(50);

            foreach (PropertyValue pv in this)
            {
                int objID = 0;
                var newpv = pv.Clone();
                if (newpv.Definition.DefaultValue.IsNullOrEmpty())
                {
                    newpv.Definition.DefaultValue = string.Empty;
                }

                if (newpv.StringValue.IsNullOrEmpty())
                {
                    newpv.StringValue = string.Empty;
                }

                if (context.ObjectContext.TryGetValue(newpv, out objID) && newpv.Definition.DefaultValue.ToLower() == newpv.StringValue.ToLower())
                {
                    idList.Add(objID);
                }
                else
                {
                    XElement itemNode = node.AddChildElement("I");
                    newpv.Serialize(itemNode, context);
                }
            }
            if (idList.Count > 0)
            {
                node.SetAttributeValue("_pvs", string.Join(",", idList.ToArray()));
            }
        }
Exemple #2
0
        public void Serialize(XElement node, XmlSerializeContext context)
        {
            PropertyValue pv    = this.Clone();
            int           objID = 0;

            if (pv.Definition.DefaultValue.IsNullOrEmpty())
            {
                pv.Definition.DefaultValue = string.Empty;
            }

            if (pv.StringValue.IsNullOrEmpty())
            {
                pv.StringValue = string.Empty;
            }

            if (context.ObjectContext.TryGetValue(pv, out objID) == false)
            {
                objID = context.CurrentID;
                context.ObjectContext.Add(pv, objID);
                node.SetAttributeValue("id", context.CurrentID++);
                pv.Definition.Serialize(node, context);
            }
            else
            {
                node.SetAttributeValue("v", objID);
            }

            if (!pv.StringValue.IsNullOrEmpty() && pv.Definition.DefaultValue.ToLower() != pv.StringValue.ToLower())
            {
                node.SetAttributeValue("_sv", pv.StringValue);
            }
        }
        public void Serialize(System.Xml.Linq.XElement node, XmlSerializeContext context)
        {
            if (this.Name.IsNotEmpty())
            {
                node.SetAttributeValue("_N", this.Name);
            }

            if (this.MessageTemplate.IsNotEmpty())
            {
                node.SetAttributeValue("_MT", this.MessageTemplate);
            }

            if (this.Tag.IsNotEmpty())
            {
                node.SetAttributeValue("_tag", this.Tag);
            }

            if (this.TypeDescription.IsNotEmpty())
            {
                node.SetAttributeValue("_TD", this.TypeDescription);
            }

            if (this._Parameters != null)
            {
                this._Parameters.Serialize(node, context);
            }
        }
 public void Serialize(System.Xml.Linq.XElement node, XmlSerializeContext context)
 {
     foreach (PropertyValidatorDescriptor pvpd in this)
     {
         XElement itemNode = node.AddChildElement("pvDesp");
         pvpd.Serialize(itemNode, context);
     }
 }
Exemple #5
0
        void IXElementSerializable.Serialize(System.Xml.Linq.XElement node, XmlSerializeContext context)
        {
            XElement items = new XElement(ns + "items");

            node.SetAttributeValue(ns + "name", Name);
            node.SetAttributeValue(ns + "desc", Description);

            foreach (PropertyValueCollection item in Items)
            {
                XElement subitem = new XElement(ns + "item");
                item.Serialize(subitem, context);
                items.Add(subitem);
            }

            node.Add(items);
        }
        public void Serialize(XElement node, XmlSerializeContext context)
        {
            PropertyLayout pl    = this.Clone();
            int            objID = 0;

            if (context.ObjectContext.TryGetValue(pl, out objID) == false)
            {
                objID = context.CurrentID;
                context.ObjectContext.Add(pl, objID);
                node.SetAttributeValue("id", context.CurrentID++);
                pl.LayoutSection.Serialize(node, context);
            }
            else
            {
                node.SetAttributeValue("v", objID);
            }
        }
        public void Serialize(System.Xml.Linq.XElement node, XmlSerializeContext context)
        {
            if (this.ParamName.IsNotEmpty())
            {
                node.SetAttributeValue("_parName", this.ParamName);
            }

            if (this.DataType != PropertyDataType.String)
            {
                node.SetAttributeValue("_dType", this.DataType);
            }

            if (this.ParamValue.IsNotEmpty())
            {
                node.SetAttributeValue("_parV", this.ParamValue);
            }
        }
Exemple #8
0
        /// <summary>
        /// 为通用的序列化而显示实现接口IXElementSerializable
        /// </summary>
        /// <param name="node"></param>
        /// <param name="context"></param>
        void IXElementSerializable.Serialize(XElement node, XmlSerializeContext context)
        {
            if (this.Definition.DefaultValue.IsNullOrEmpty())
            {
                this.Definition.DefaultValue = string.Empty;
            }

            if (this.StringValue.IsNullOrEmpty())
            {
                this.StringValue = string.Empty;
            }

            this.Definition.Serialize(node, context);

            if (!this.StringValue.IsNullOrEmpty() && this.Definition.DefaultValue.ToLower() != this.StringValue.ToLower())
            {
                node.SetAttributeValue("_sv", this.StringValue);
            }
        }
Exemple #9
0
        public void PropertyValueSerializeTest()
        {
            PropertyValue pv = PreparePropertyValue();

            XElementFormatter   formatter = new XElementFormatter();
            XmlSerializeContext context   = new XmlSerializeContext();
            XElement            root      = new XElement("root");

            pv.Serialize(root, context);

            Console.WriteLine(root.ToString());

            XmlDeserializeContext dcontext         = new XmlDeserializeContext();
            PropertyValue         newPropertyValue = new PropertyValue(new PropertyDefine());

            newPropertyValue.Deserialize(root, dcontext);

            //Assert.AreEqual(root.ToString(), rootReserialized.ToString());
            Assert.AreEqual(pv.StringValue, newPropertyValue.StringValue);
            Assert.AreEqual(pv.Definition.Name, newPropertyValue.Definition.Name);
        }
        public void Serialize(XElement node, XmlSerializeContext context)
        {
            if (this.Name.IsNotEmpty())
            {
                node.SetAttributeValue("_na", this.Name);
            }

            if (this.DisplayName.IsNotEmpty())
            {
                node.SetAttributeValue("_dn", this.DisplayName);
            }

            if (this.Columns > 0)
            {
                node.SetAttributeValue("_columns", this.Columns);
            }

            if (this.DefaultRowHeight.IsNotEmpty())
            {
                node.SetAttributeValue("_drh", this.DefaultRowHeight);
            }
        }
        public void Serialize(XElement node, XmlSerializeContext context)
        {
            List <int> idList = new List <int>(50);

            foreach (PropertyLayout pl in this)
            {
                int objID = 0;
                var newpl = pl.Clone();

                if (context.ObjectContext.TryGetValue(newpl, out objID))
                {
                    idList.Add(objID);
                }
                else
                {
                    XElement itemNode = node.AddChildElement("I");
                    newpl.Serialize(itemNode, context);
                }
            }
            if (idList.Count > 0)
            {
                node.SetAttributeValue("_pvs", string.Join(",", idList.ToArray()));
            }
        }
Exemple #12
0
 public void Serialize(System.Xml.Linq.XElement node, XmlSerializeContext context)
 {
     throw new NotImplementedException();
     //参考MCS.Library.SOA.DataObjects.PropertyDefine
 }
Exemple #13
0
        public virtual void Serialize(XElement node, XmlSerializeContext context)
        {
            if (this.Name.IsNotEmpty())
            {
                node.SetAttributeValue("_n", this.Name);
            }

            if (this.DisplayName.IsNotEmpty())
            {
                node.SetAttributeValue("_dn", this.DisplayName);
            }

            if (this.Category.IsNotEmpty())
            {
                node.SetAttributeValue("_category", this.Category);
            }

            if (this._DataType != PropertyDataType.String)
            {
                node.SetAttributeValue("_dataType", this._DataType);
            }

            if (this.DefaultValue.IsNotEmpty())
            {
                node.SetAttributeValue("_dv", this.DefaultValue);
            }

            if (this.Description.IsNotEmpty())
            {
                node.SetAttributeValue("_desp", this.Description);
            }

            if (this.EditorKey.IsNotEmpty())
            {
                node.SetAttributeValue("_eKey", this.EditorKey);
            }

            if (this.PersisterKey.IsNotEmpty())
            {
                node.SetAttributeValue("_perKey", this.PersisterKey);
            }

            if (this.EditorParamsSettingsKey.IsNotEmpty())
            {
                node.SetAttributeValue("_ePS", this.EditorParamsSettingsKey);
            }

            if (this.EditorParams.IsNotEmpty())
            {
                node.SetAttributeValue("_eP", this.EditorParams);
            }

            if (this.ReadOnly)
            {
                node.SetAttributeValue("_ro", this.ReadOnly);
            }

            if (this._Visible == false)
            {
                node.SetAttributeValue("_visible", this._Visible);
            }

            if (this._AllowOverride == false)
            {
                node.SetAttributeValue("_override", this._AllowOverride);
            }

            if (this.SortOrder != 0)
            {
                node.SetAttributeValue("_sortOrder", this.SortOrder);
            }

            if (this.MaxLength != 0)
            {
                node.SetAttributeValue("_ml", this.MaxLength);
            }

            if (this.IsRequired)
            {
                node.SetAttributeValue("_isRequired", this.SortOrder);
            }

            if (!this.ShowTitle)
            {
                node.SetAttributeValue("_showTitle", this.ShowTitle);
            }

            if (this._Validators != null)
            {
                this._Validators.Serialize(node, context);
            }
        }