Esempio n. 1
0
 /// <summary>
 /// Faz a desserialização do objeto.
 /// </summary>
 /// <param name="reader"></param>
 protected override void Deserialize(Colosoft.Serialization.IO.CompactReader reader)
 {
     if (reader.ReadBoolean())
     {
         _term = GetConditionalTerm(reader);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Recupera os dados da instancia do leitor informado.
 /// </summary>
 /// <param name="reader"></param>
 protected override void ReadXml(System.Xml.XmlReader reader)
 {
     reader.ReadStartElement();
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         _left = GetConditionalTerm(reader);
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement)
     {
         _operator = (Operator)GetConditionalTerm(reader);
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         _right = GetConditionalTerm(reader);
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }
Esempio n. 3
0
        /// <summary>
        /// Preenche os dados da instancia com a expressões informadas.
        /// </summary>
        /// <param name="expressions"></param>
        private void Fill(List <Text.InterpreterExpression.Expression> expressions)
        {
            int ownerIndex;
            int aliasIndex;

            GetParameters(expressions, out ownerIndex, out aliasIndex);
            IEnumerator <Text.InterpreterExpression.Expression> enumerator = null;

            if (aliasIndex >= 0)
            {
                enumerator = (IEnumerator <Text.InterpreterExpression.Expression>)expressions.Take(aliasIndex).GetEnumerator();
            }
            else
            {
                enumerator = (IEnumerator <Text.InterpreterExpression.Expression>)expressions.GetEnumerator();
            }
            if (enumerator.MoveNext())
            {
                _term = ConditionalParser.GetContainer(ref enumerator, new Text.InterpreterExpression.ContainerChars('(', ')'));
            }
            if (aliasIndex >= 0 && _alias == null)
            {
                _alias = expressions[aliasIndex + 1].Text;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Desserializa o objeto.
 /// </summary>
 /// <param name="reader"></param>
 public void Deserialize(Colosoft.Serialization.IO.CompactReader reader)
 {
     if (reader.ReadBoolean())
     {
         _term = ConditionalTerm.GetConditionalTerm(reader);
     }
 }
 /// <summary>
 /// Adiciona a condição inicial. Essa operação limpa todas a outras condições já existentes.
 /// </summary>
 /// <param name="conditional"></param>
 /// <returns></returns>
 public virtual ConditionalContainer Start(ConditionalTerm conditional)
 {
     conditional.Require("conditional").NotNull();
     _conditionals.Clear();
     _logicalOperators.Clear();
     _conditionals.Add(conditional);
     return(this);
 }
Esempio n. 6
0
        /// <summary>
        /// Construtor usado na deserialização dos dados.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        private GroupByEntry(SerializationInfo info, StreamingContext context)
        {
            var termType = info.GetString("TermType");

            if (!string.IsNullOrEmpty(termType))
            {
                _term = (ConditionalTerm)info.GetValue("Term", Type.GetType(termType, true));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Construtor usado na deserialização dos dados.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected Conditional(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            var leftType  = Type.GetType(info.GetString("LeftType"));
            var rightType = Type.GetType(info.GetString("RightType"));

            _left     = (ConditionalTerm)info.GetValue("Left", typeof(ConditionalTerm));
            _operator = (Operator)info.GetValue("Operator", typeof(Operator));
            _right    = (ConditionalTerm)info.GetValue("Right", typeof(ConditionalTerm));
        }
Esempio n. 8
0
        /// <summary>
        /// Construtor usado na deserialização dos dados.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected MinusTerm(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
        {
            var termType = info.GetString("TermType");

            if (!string.IsNullOrEmpty(termType))
            {
                _term = (ConditionalTerm)info.GetValue("Term", Type.GetType(termType, true));
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Preenche os dados da instancia com a expressões informadas.
        /// </summary>
        /// <param name="expressions"></param>
        private void Fill(List <Colosoft.Text.InterpreterExpression.Expression> expressions)
        {
            var enumerator = (IEnumerator <Text.InterpreterExpression.Expression>)expressions.GetEnumerator();

            if (enumerator.MoveNext())
            {
                _term = ConditionalParser.GetContainer(ref enumerator, new Text.InterpreterExpression.ContainerChars('(', ')'));
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Adiciona uma condição do tipo OR.
 /// </summary>
 /// <param name="conditional"></param>
 /// <returns></returns>
 public virtual ConditionalContainer Or(ConditionalTerm conditional)
 {
     conditional.Require("conditional").NotNull();
     _conditionals.Add(conditional);
     if (_conditionals.Count > 1)
     {
         _logicalOperators.Add(LogicalOperator.Or);
     }
     return(this);
 }
Esempio n. 11
0
        /// <summary>
        /// Construtor usado na deserialização dos dados.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        private SortEntry(SerializationInfo info, StreamingContext context)
        {
            _reverse = info.GetBoolean("Reverse");
            var termType = info.GetString("TermType");

            if (!string.IsNullOrEmpty(termType))
            {
                _term = (ConditionalTerm)info.GetValue("Term", Type.GetType(termType, true));
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Faz a desserialização do objeto.
 /// </summary>
 /// <param name="reader"></param>
 void Colosoft.Serialization.ICompactSerializable.Deserialize(Colosoft.Serialization.IO.CompactReader reader)
 {
     if (reader.ReadBoolean())
     {
         _expression = ConditionalTerm.GetConditionalTerm(reader);
     }
     if (reader.ReadBoolean())
     {
         _resultExpression = ConditionalTerm.GetConditionalTerm(reader);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Construtor para serialização.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected FunctionCall(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            _call = (ConditionalTerm)info.GetValue("M", Type.GetType(info.GetString("T"), true));
            var size = info.GetInt32("S");

            _parameters = new ConditionalTerm[size];
            for (var i = 0; i < size; ++i)
            {
                _parameters[i] = GetTerm(info, i);
            }
            _options = (FunctionCallOptions)info.GetInt32("Options");
        }
Esempio n. 14
0
        /// <summary>
        /// Clona um array de valores.
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            var values = new ConditionalTerm[Values.Length];

            for (int i = 0; i < Values.Length; i++)
            {
                values[i] = (ConditionalTerm)Values[i].Clone();
            }
            return(new ValuesArray {
                Values = values
            });
        }
Esempio n. 15
0
        /// <summary>
        /// Construtor usado na deserialização dos dados.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected CaseWhenExpression(SerializationInfo info, StreamingContext context)
        {
            var expressionType       = info.GetString("ExpressionType");
            var resultExpressionType = info.GetString("ResultExpressionType");

            if (!string.IsNullOrEmpty(expressionType))
            {
                _expression = (ConditionalTerm)info.GetValue("Expression", Type.GetType(expressionType, true));
            }
            if (!string.IsNullOrEmpty(resultExpressionType))
            {
                _resultExpression = (ConditionalTerm)info.GetValue("ResultExpression", Type.GetType(resultExpressionType, true));
            }
        }
Esempio n. 16
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     reader.ReadStartElement();
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         reader.ReadStartElement();
         _term = ConditionalTerm.GetConditionalTerm(reader);
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }
Esempio n. 17
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="conditional">Condicionais do container.</param>
 public ConditionalContainer(ConditionalTerm conditional)
 {
     if (conditional != null)
     {
         _conditionals.Add(conditional);
         if (conditional is ConditionalContainer)
         {
             var cc = (ConditionalContainer)conditional;
             if (cc.ParameterContainer != this.ParameterContainer)
             {
                 cc.ParameterContainer = this.ParameterContainer;
             }
         }
     }
 }
Esempio n. 18
0
 /// <summary>
 /// Lê os dados serializados para a instancia.
 /// </summary>
 /// <param name="reader"></param>
 protected override void ReadXml(System.Xml.XmlReader reader)
 {
     reader.ReadStartElement();
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         reader.ReadStartElement();
         _term = GetConditionalTerm(reader);
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }
Esempio n. 19
0
        /// <summary>
        /// Serializa um termo na posição <paramref name="index"/>.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="index"></param>
        /// <param name="term"></param>
        private static void SetTerm(SerializationInfo info, int index, ConditionalTerm term)
        {
            var tName = String.Format("t{0}", index);
            var pName = String.Format("p{0}", index);

            if (term == null)
            {
                info.AddValue(tName, "NULL");
            }
            else
            {
                info.AddValue(tName, term.GetType().FullName);
                info.AddValue(pName, term);
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Desserializa a instância previamente serializada em formato binário.
        /// </summary>
        /// <param name="reader"></param>
        protected override void Deserialize(CompactReader reader)
        {
            _call    = GetConditionalTerm(reader);
            _options = (FunctionCallOptions)(int)reader.ReadInt32();
            var size = reader.ReadInt32();

            _parameters = new ConditionalTerm[size];
            for (var i = 0; i < size; ++i)
            {
                if (reader.ReadBoolean())
                {
                    _parameters[i] = GetConditionalTerm(reader);
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Serializa o termo em formato xml.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="term"></param>
        private static void WriteTerm(XmlWriter writer, ConditionalTerm term)
        {
            var qName = term.QualifiedName;

            writer.WriteStartElement(qName.Name, qName.Namespace);
            if (!"ConditionalTerm".Equals(qName.Name))
            {
                var prefix = writer.LookupPrefix(qName.Namespace);
                if (string.IsNullOrEmpty(prefix))
                {
                    writer.WriteAttributeString("xmlns", qName.Namespace);
                }
            }
            ((IXmlSerializable)term).WriteXml(writer);
            writer.WriteEndElement();
        }
Esempio n. 22
0
 /// <summary>
 /// Faz a desserialização do objeto.
 /// </summary>
 /// <param name="reader"></param>
 protected override void Deserialize(Colosoft.Serialization.IO.CompactReader reader)
 {
     if (reader.ReadBoolean())
     {
         _inputExpression = GetConditionalTerm(reader);
     }
     while (reader.ReadBoolean())
     {
         var caseWhenExpression = new CaseWhenExpression();
         ((Colosoft.Serialization.ICompactSerializable)caseWhenExpression).Deserialize(reader);
         _whenExpressions.Add(caseWhenExpression);
     }
     if (reader.ReadBoolean())
     {
         _elseResultExpression = GetConditionalTerm(reader);
     }
 }
Esempio n. 23
0
 /// <summary>
 /// Serializa os dados no escritor informado.
 /// </summary>
 /// <param name="writer"></param>
 void System.Xml.Serialization.IXmlSerializable.WriteXml(System.Xml.XmlWriter writer)
 {
     writer.WriteStartElement("Expression", Namespaces.Query);
     if (_expression != null)
     {
         ConditionalTerm.InsertConditionalTermType(writer, _expression);
         ((System.Xml.Serialization.IXmlSerializable)_expression).WriteXml(writer);
     }
     writer.WriteEndElement();
     writer.WriteStartElement("ResultExpression", Namespaces.Query);
     if (_resultExpression != null)
     {
         ConditionalTerm.InsertConditionalTermType(writer, _resultExpression);
         ((System.Xml.Serialization.IXmlSerializable)_resultExpression).WriteXml(writer);
     }
     writer.WriteEndElement();
 }
Esempio n. 24
0
        /// <summary>
        /// Determina se não existe chamada de função na avaliação do termo.
        /// </summary>
        /// <param name="term"></param>
        /// <returns></returns>
        public static bool HasNoFunctionCall(ConditionalTerm term)
        {
            if (term == null)
            {
                return(true);
            }
            if (term is FunctionCall)
            {
                return(false);
            }
            var cond = term as Conditional;

            if (cond == null)
            {
                return(true);
            }
            return(HasNoFunctionCall(cond.Left) && HasNoFunctionCall(cond.Right));
        }
Esempio n. 25
0
        /// <summary>
        /// Faz a desserialização do objeto.
        /// </summary>
        /// <param name="reader"></param>
        protected override void Deserialize(Colosoft.Serialization.IO.CompactReader reader)
        {
            string position = reader.ReadString();

            if (position == "Left")
            {
                _left = GetConditionalTerm(reader);
            }
            position = reader.ReadString();
            if (position == "Operator")
            {
                _operator = (Operator)GetConditionalTerm(reader);
            }
            position = reader.ReadString();
            if (position == "Right")
            {
                _right = GetConditionalTerm(reader);
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Preenche os dados da instancia com a expressões informadas.
        /// </summary>
        /// <param name="expressions"></param>
        private void Fill(List <Colosoft.Text.InterpreterExpression.Expression> expressions)
        {
            var last = expressions.Last();

            if (last.Token == (int)Parser.SqlTokenID.kDesc)
            {
                _reverse = true;
            }
            if (last.Token == (int)Parser.SqlTokenID.kAsc || last.Token == (int)Parser.SqlTokenID.kDesc)
            {
                expressions.RemoveAt(expressions.Count - 1);
            }
            var enumerator = (IEnumerator <Text.InterpreterExpression.Expression>)expressions.GetEnumerator();

            if (enumerator.MoveNext())
            {
                _term = ConditionalParser.GetContainer(ref enumerator, new Text.InterpreterExpression.ContainerChars('(', ')'));
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Construtor usado na deserialização dos dados.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        protected CaseConditional(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            var inputExpressionType      = info.GetString("InputExpressionType");
            var elseResultExpressionType = info.GetString("ElseResultExpressionType");

            if (!string.IsNullOrEmpty(inputExpressionType))
            {
                _inputExpression = (ConditionalTerm)info.GetValue("InputExpression", Type.GetType(inputExpressionType, true));
            }
            if (!string.IsNullOrEmpty(elseResultExpressionType))
            {
                _elseResultExpression = (ConditionalTerm)info.GetValue("ElseResultExpression", Type.GetType(elseResultExpressionType, true));
            }
            var count = info.GetInt32("WhenExpressionsCount");

            for (var i = 0; i < count; i++)
            {
                _whenExpressions.Add((CaseWhenExpression)info.GetValue(string.Format("WhenExpression{0}", i), typeof(CaseWhenExpression)));
            }
        }
Esempio n. 28
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     if (reader.MoveToAttribute("Reverse"))
     {
         _reverse = reader.ReadContentAsBoolean();
     }
     reader.MoveToElement();
     reader.ReadStartElement();
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         reader.ReadStartElement();
         _term = ConditionalTerm.GetConditionalTerm(reader);
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }
Esempio n. 29
0
 /// <summary>
 /// Recupera os parametros.
 /// </summary>
 /// <param name="term"></param>
 /// <returns></returns>
 private static IEnumerable <QueryParameter> GetParameters(ConditionalTerm term)
 {
     if (term is Conditional)
     {
         var conditional = (Conditional)term;
         if (conditional.Left != null)
         {
             foreach (var i in GetParameters(conditional.Left))
             {
                 yield return(i);
             }
         }
         if (conditional.Right != null)
         {
             foreach (var i in GetParameters(conditional.Right))
             {
                 yield return(i);
             }
         }
     }
     else if (term is FunctionCall)
     {
         var functionCall = (FunctionCall)term;
         foreach (var parameter in functionCall.Parameters)
         {
             foreach (var i in GetParameters(parameter))
             {
                 yield return(i);
             }
         }
     }
     else if (term is ConditionalContainer)
     {
         foreach (var i in GetParameters((ConditionalContainer)term))
         {
             yield return(i);
         }
     }
 }
Esempio n. 30
0
 /// <summary>
 /// Lê os dados serializados em XML.
 /// </summary>
 /// <param name="reader"></param>
 protected override void ReadXml(System.Xml.XmlReader reader)
 {
     reader.ReadStartElement();
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         _inputExpression = GetConditionalTerm(reader);
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement && reader.LocalName == "WhenExpressions")
     {
         reader.ReadStartElement("WhenExpressions", Namespaces.Query);
         while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
         {
             var caseWhenExpression = new CaseWhenExpression();
             ((System.Xml.Serialization.IXmlSerializable)caseWhenExpression).ReadXml(reader);
             _whenExpressions.Add(caseWhenExpression);
         }
         reader.ReadEndElement();
     }
     else
     {
         reader.Skip();
     }
     if (!reader.IsEmptyElement || reader.HasAttributes)
     {
         _elseResultExpression = GetConditionalTerm(reader);
     }
     else
     {
         reader.Skip();
     }
     reader.ReadEndElement();
 }