示例#1
0
        /// <summary>
        /// Recupera o termo condicional contido no reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal static protected ConditionalTerm GetConditionalTerm(Colosoft.Serialization.IO.CompactReader reader)
        {
            var             type = reader.ReadString();
            ConditionalTerm term = null;

            if (string.IsNullOrEmpty(type))
            {
                term = new Constant();
            }
            else
            {
                if (type == "Conditional")
                {
                    term = new Conditional();
                }
                else if (type == "ConditionalContainer")
                {
                    term = new ConditionalContainer();
                }
                else if (type == "Operator")
                {
                    term = new Operator();
                }
                else if (type == "Constant")
                {
                    term = new Constant();
                }
                else if (type == "Column")
                {
                    term = new Column();
                }
                else if (type == "Variable")
                {
                    term = new Variable();
                }
                else if (type == "ValuesArray")
                {
                    term = new ValuesArray();
                }
                else if (type == "QueryTerm")
                {
                    term = new QueryTerm();
                }
                else if (type == "FunctionCall")
                {
                    term = new FunctionCall();
                }
                else if (type == "MinusTerm")
                {
                    term = new MinusTerm();
                }
                else if (type == "Formula")
                {
                    term = new Formula();
                }
                else if (type == "Empty")
                {
                    return(null);
                }
                else
                {
                    throw new QueryInvalidOperationException("Invalid conditional type");
                }
            }
            ((ICompactSerializable)term).Deserialize(reader);
            return(term);
        }
示例#2
0
        /// <summary>
        /// Recupera o termo condicional contido no reader.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        internal protected static ConditionalTerm GetConditionalTerm(System.Xml.XmlReader reader)
        {
            var type = reader.GetAttribute("type", Namespaces.SchemaInstance);

            if (string.IsNullOrEmpty(type))
            {
                type = reader.LocalName;
            }
            ConditionalTerm term = null;

            if (string.IsNullOrEmpty(type))
            {
                term = new Constant();
            }
            else
            {
                var index1 = type.IndexOf(":");
                if (index1 >= 0)
                {
                    type = type.Substring(index1 + 1);
                }
                var startPoint = type.IndexOf('.');
                if (startPoint >= 0)
                {
                    type = type.Substring(startPoint + 1);
                }
                if (type == "Conditional")
                {
                    term = new Conditional();
                }
                else if (type == "ConditionalContainer")
                {
                    term = new ConditionalContainer();
                }
                else if (type == "Operator")
                {
                    term = new Operator();
                }
                else if (type == "Constant")
                {
                    term = new Constant();
                }
                else if (type == "Column")
                {
                    term = new Column();
                }
                else if (type == "Variable")
                {
                    term = new Variable();
                }
                else if (type == "ValuesArray")
                {
                    term = new ValuesArray();
                }
                else if (type == "QueryTerm")
                {
                    term = new QueryTerm();
                }
                else if (type == "FunctionCall")
                {
                    term = new FunctionCall();
                }
                else if (type == "MinusTerm")
                {
                    term = new MinusTerm();
                }
                else if (type == "Formula")
                {
                    term = new Formula();
                }
                else if (type == "Empty")
                {
                    return(null);
                }
                else if (type == "Case")
                {
                    term = new CaseConditional();
                }
                else
                {
                    throw new QueryInvalidOperationException("Invalid conditional type");
                }
            }
            ((System.Xml.Serialization.IXmlSerializable)term).ReadXml(reader);
            return(term);
        }