Exemplo n.º 1
0
        /// <summary>
        /// Adds a new <see cref="FilterStatement{TPropertyType}" /> to the <see cref="Filter{TClass}" />.
        /// </summary>
        /// <typeparam name="TPropertyType"></typeparam>
        /// <param name="propertyId">Name of the property that will be filtered.</param>
        /// <param name="operation">Express the interaction between the property and the constant value.</param>
        /// <param name="value">Constant value that will interact with the property.</param>
        /// <param name="connector">Establishes how this filter statement will connect to the next one.</param>
        /// <param name="matchType">Establishes how the IList values will be matched to the property</param>
        /// <returns></returns>
        public IFilterStatementConnection By <TPropertyType>(string propertyId, Operation operation, TPropertyType value, Connector connector = Connector.And, MatchType matchType = MatchType.Default)
        {
            IFilterStatement statement = new FilterStatement <TPropertyType>(propertyId, operation, value, connector, matchType);

            CurrentStatementGroup.Add(statement);
            return(new FilterStatementConnection <TClass>(this, statement));
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The System.Xml.XmlReader stream from which the object is deserialized.</param>
        public void ReadXml(XmlReader reader)
        {
            while (reader.Read())
            {
                if (reader.IsStartElement("FilterGroup"))
                {
                    StartGroup();
                }

                if (reader.Name.StartsWith("FilterStatementOf"))
                {
                    var type       = reader.GetAttribute("Type");
                    var filterType = typeof(FilterStatement <>).MakeGenericType(Type.GetType(type));
                    var serializer = new XmlSerializer(filterType);
                    var statement  = (IFilterStatement)serializer.Deserialize(reader);
                    CurrentStatementGroup.Add(statement);
                }

                if (reader.Name == "FilterGroup" && reader.NodeType == XmlNodeType.EndElement)
                {
                    EndGroup();
                }
            }
        }