Ejemplo n.º 1
0
        public void SerializeToXml(XmlWriter writer, string propertyName)
        {
            XmlProxy xmlRoot = new XmlProxy(propertyName);

            xmlRoot.AddAttribute("getter", this.Getter);
            xmlRoot.AddAttribute("setter", this.Setter);

            XmlProxySerializer.Instance.Serialize(xmlRoot, writer);
        }
Ejemplo n.º 2
0
        public void SerializeToXml(XmlWriter writer, string propertyName)
        {
            XmlProxy xmlRoot = new XmlProxy(propertyName);

            xmlRoot.AddAttribute("multiplicity", multiplicity.ToString());
            xmlRoot.AddAttribute("onOwnerRemove", OnOwnerRemove.ToString());
            xmlRoot.AddAttribute("onTargetRemove", OnTargetRemove.ToString());
            xmlRoot.AddAttribute("useAssociationAttribute", this.UseAssociationAttribute);

            XmlProxy xmlPairTo = xmlRoot.AddChild("pairTo");

            this.PairTo.SerializeToXml(xmlPairTo);

            XmlProxySerializer.Instance.Serialize(xmlRoot, writer);
        }
Ejemplo n.º 3
0
        protected override void SerializeValueToXml(XmlProxy parent)
        {
            XmlProxy xmlContent = parent.AddChild("content");

            xmlContent.AddAttribute("name", Name);
            InternalSerializeToXml(xmlContent);
        }
Ejemplo n.º 4
0
 public void SerializeToXml(XmlProxy xmlRoot)
 {
     foreach (PropertyConstraint constraint in AllConstraints)
     {
         XmlProxy xmlConstraint = xmlRoot.AddChild("constraint");
         xmlConstraint.AddAttribute("type", constraint.ConstrainType);
         constraint.SerializeToXml(xmlConstraint);
     }
 }
Ejemplo n.º 5
0
        public virtual void SerializeToXml(XmlProxy xmlRoot)
        {
            xmlRoot.AddAttribute("valueType", ValueType);

            if (CanSerializeValue())
            {
                SerializeValueToXml(xmlRoot);
            }
        }
Ejemplo n.º 6
0
        protected override void InternalSerializeToXml(XmlProxy xmlRoot)
        {
            //xmlRoot.AddAttribute("isReference", IsReference);
            var xmlisReference = xmlRoot.AddChild("isReference");

            this.IsReference.SerializeToXml(xmlisReference);

            xmlRoot.AddAttribute("namespace", this.Namespace);
        }
Ejemplo n.º 7
0
        protected override void SerializeValueToXml(XmlProxy parent)
        {
            XmlProxy xmlRoot = new XmlProxy("content");

            if (parent != null)
            {
                parent.AddChild(xmlRoot);
            }
            //xmlRoot.AddAttribute("type", this.ConstrainType);
            xmlRoot.AddAttribute("mode", this.Mode);
            XmlProxy xmlError = xmlRoot.AddChild("error");

            xmlError.AddAttribute("message", this.ErrorMessage);
            InternalSerializeToXml(xmlRoot);
        }
Ejemplo n.º 8
0
        public void SerializeToXml(XmlProxy parent, string propertyName)
        {
            XmlProxy xmlRoot = parent.AddChild(propertyName);

            xmlRoot.AddAttribute("useCustomExpression", UseCustomExpression);
            XmlProxy xmlValue = xmlRoot.AddChild("Value");

            if (UseCustomExpression)
            {
                xmlValue.ElementValue = this.CustomExpression;
            }
            else if (Value != null)
            {
                xmlValue.AddAttribute("type", Value.GetType().AssemblyQualifiedName);
                xmlValue.ElementValue = SerializeValueToXml(Value);
            }
        }
Ejemplo n.º 9
0
        protected override void SerializeValueToXml(XmlProxy parent)
        {
            object value       = InternalGetValue();
            string valueString = value == null ? string.Empty : InternalValueToString(value);
            //string valueString = value == null ? string.Empty : value.ToString();

            Type typeOfValue = GetTypeOfValue();

            if (typeOfValue.IsPrimitive)
            {
                parent.AddAttribute("value", valueString);
            }
            else
            {
//                if (typeOfValue == typeof(byte[]))
//                {
//                    valueString = Util.BytesToHexString((byte[]) value);
//                }

                XmlProxy xmlContent = parent.AddChild("value");
                xmlContent.ElementValue = valueString;
            }
        }
Ejemplo n.º 10
0
        public XmlProxy Deserialize(XmlReader reader)
        {
            reader.MoveToContent();
            int    startDepth       = reader.Depth;
            string startElementName = reader.Name;

            Dictionary <int, List <XmlProxy> > items = new Dictionary <int, List <XmlProxy> >();
            XmlProxy lastProxy = null;

            bool readedOk = !reader.EOF;

            while ((readedOk) && (!reader.EOF))
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    XmlProxy        pi = new XmlProxy(reader.Name);
                    List <XmlProxy> al = items.SingleOrDefault(pair => pair.Key == reader.Depth).Value;
                    if (al == null)
                    {
                        al = new List <XmlProxy>();
                        items.Add(reader.Depth, al);
                        //items[reader.Depth] = al;
                    }
                    al.Add(pi);

                    // parent
                    List <XmlProxy> pal = items.SingleOrDefault(pair => pair.Key == (reader.Depth - 1)).Value;
                    if ((pal != null) && (pal.Count > 0))
                    {
                        XmlProxy parent = pal[pal.Count - 1];
                        if (parent != null)
                        {
                            parent.AddChild(pi);
                        }
                    }

                    // read attributes
                    if (reader.HasAttributes)
                    {
                        while (reader.MoveToNextAttribute())
                        {
                            pi.AddAttribute(reader.Name, reader.Value);
                        }
                    }

                    lastProxy = pi;

                    break;

                case XmlNodeType.Text:
                    if (lastProxy != null)
                    {
                        lastProxy.ElementValue = reader.Value;
                    }
                    break;

                case XmlNodeType.EndElement:
                    break;
                }

                readedOk = reader.Read();
                reader.MoveToContent();

                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == startElementName && reader.Depth == startDepth)
                {
                    break;
                }
            }

            //reader.Close();

            if (items.Count > 0)
            {
                List <XmlProxy> firstProcyList = items.OrderBy(pair => pair.Key).Select(pair => pair.Value).First();

                //List<XmlProxy> al = items[0] as List<XmlProxy>;
                if ((firstProcyList != null) && (firstProcyList.Count > 0))
                {
                    return(firstProcyList[0]);
                }
            }

            return(null);
        }
Ejemplo n.º 11
0
 protected override void InternalSerializeToXml(XmlProxy content)
 {
     content.AddAttribute("pattern", this.Pattern);
     content.AddAttribute("options", this.Options);
 }