Ejemplo n.º 1
0
        /// <summary>
        /// Desserializa o objeto.
        /// </summary>
        /// <param name="reader"></param>
        public void Deserialize(Serialization.IO.CompactReader reader)
        {
            _expression = reader.ReadString();
            var parameters = new List <PersistenceParameter>();
            var count      = reader.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var parameter = new PersistenceParameter();
                ((ICompactSerializable)parameter).Deserialize(reader);
                parameters.Add(parameter);
            }
            _parameters = new PersistenceParameterCollection(parameters);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Lê os dados do XML.
 /// </summary>
 /// <param name="reader"></param>
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     reader.MoveToElement();
     reader.ReadStartElement();
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("Parameters", Namespaces.Data);
         var parameters = new List <PersistenceParameter>();
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             if (reader.LocalName == "Parameter")
             {
                 var parameter = new PersistenceParameter();
                 ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader);
                 parameters.Add(parameter);
             }
             else
             {
                 reader.Skip();
             }
         }
         _parameters = new PersistenceParameterCollection(parameters);
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         reader.ReadStartElement("Expression");
         _expression = reader.ReadElementContentAs(typeof(string), null) as string;
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Desserializa o objeto.
        /// </summary>
        /// <param name="reader"></param>
        public void Deserialize(Serialization.IO.CompactReader reader)
        {
            ActionId       = reader.ReadInt32();
            Type           = (PersistenceActionType)reader.ReadInt32();
            EntityFullName = reader.ReadString();
            ProviderName   = reader.ReadString();
            var RowVersionString = reader.ReadString();

            if (!string.IsNullOrEmpty(RowVersionString))
            {
                RowVersion = long.Parse(RowVersionString);
            }
            else
            {
                RowVersion = null;
            }
            var parameters = new List <PersistenceParameter>();
            var count      = reader.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var parameter = new PersistenceParameter();
                ((ICompactSerializable)parameter).Deserialize(reader);
                parameters.Add(parameter);
            }
            Parameters = new PersistenceParameterCollection(parameters);
            if (reader.ReadBoolean())
            {
                var conditional = new Colosoft.Query.ConditionalContainer();
                ((ICompactSerializable)conditional).Deserialize(reader);
                this.Conditional = conditional;
            }
            var actions = new List <PersistenceAction>();

            count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var persistenceAction = new PersistenceAction();
                ((ICompactSerializable)persistenceAction).Deserialize(reader);
                actions.Add(persistenceAction);
            }
            AlternativeActions.AddRange(actions);
            var beforeActions = new List <PersistenceAction>();

            count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var persistenceAction = new PersistenceAction();
                ((ICompactSerializable)persistenceAction).Deserialize(reader);
                beforeActions.Add(persistenceAction);
            }
            BeforeActions.AddRange(beforeActions);
            var afterActions = new List <PersistenceAction>();

            count = reader.ReadInt32();
            for (var i = 0; i < count; i++)
            {
                var persistenceAction = new PersistenceAction();
                ((ICompactSerializable)persistenceAction).Deserialize(reader);
                afterActions.Add(persistenceAction);
            }
            AfterActions.AddRange(afterActions);
            if (reader.ReadBoolean())
            {
                _storedProcedureName = new Colosoft.Query.StoredProcedureName();
                ((ICompactSerializable)_storedProcedureName).Deserialize(reader);
            }
            if (reader.ReadBoolean())
            {
                var query = new Colosoft.Query.QueryInfo();
                ((ICompactSerializable)query).Deserialize(reader);
                this.Query = query;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Lê os dados do XML.
        /// </summary>
        /// <param name="reader"></param>
        void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToAttribute("ActionId");
            ActionId = reader.ReadContentAsInt();
            reader.MoveToAttribute("Type");
            var typeString = reader.ReadContentAsString();

            Type = (PersistenceActionType)Enum.Parse(typeof(PersistenceActionType), typeString);
            reader.MoveToAttribute("EntityFullName");
            EntityFullName = reader.ReadContentAsString();
            reader.MoveToAttribute("ProviderName");
            ProviderName = reader.ReadContentAsString();
            reader.MoveToAttribute("RowVersion");
            var RowVersionString = reader.ReadContentAsString();

            if (!string.IsNullOrEmpty(RowVersionString))
            {
                RowVersion = long.Parse(RowVersionString);
            }
            else
            {
                RowVersion = null;
            }
            if (reader.MoveToAttribute("CommandTimeout"))
            {
                var timeout = 0;
                if (int.TryParse(reader.ReadContentAsString(), out timeout))
                {
                    CommandTimeout = timeout;
                }
            }
            reader.MoveToElement();
            reader.ReadStartElement();
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("Parameters", Namespaces.Data);
                var parameters = new List <PersistenceParameter>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "Parameter")
                    {
                        var parameter = new PersistenceParameter();
                        ((System.Xml.Serialization.IXmlSerializable)parameter).ReadXml(reader);
                        parameters.Add(parameter);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                Parameters = new PersistenceParameterCollection(parameters);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                var conditional = new Colosoft.Query.ConditionalContainer();
                ((System.Xml.Serialization.IXmlSerializable)conditional).ReadXml(reader);
                this.Conditional = conditional;
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AlternativeActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                AlternativeActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("BeforeActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                BeforeActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            if (!reader.IsEmptyElement)
            {
                reader.ReadStartElement("AfterActions");
                var actions = new List <PersistenceAction>();
                while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
                {
                    if (reader.LocalName == "PersistenceAction")
                    {
                        var persistenceAction = new PersistenceAction();
                        ((System.Xml.Serialization.IXmlSerializable)persistenceAction).ReadXml(reader);
                        actions.Add(persistenceAction);
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                AfterActions.AddRange(actions);
                reader.ReadEndElement();
            }
            else
            {
                reader.Skip();
            }
            _storedProcedureName = ReadItem <Colosoft.Query.StoredProcedureName>(reader, "StoredProcedureName");
            if (!reader.IsEmptyElement)
            {
                var query = new Colosoft.Query.QueryInfo();
                ((System.Xml.Serialization.IXmlSerializable)query).ReadXml(reader);
                this.Query = query;
            }
            else
            {
                reader.Skip();
            }
            reader.ReadEndElement();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Construtor usado na deserialização dos dados.
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 private ExpressionParameter(SerializationInfo info, StreamingContext context)
 {
     Expression  = info.GetString("Expression");
     _parameters = (PersistenceParameterCollection)info.GetValue("Parameters", typeof(PersistenceParameterCollection));
 }