private string GetOperandError <T>(string operand) { var dataSchema = new DataSchema(); var rootColumn = ColumnDescriptor.RootColumn(dataSchema, typeof(DataRowWithProperty <T>)); var column = rootColumn.ResolveChild("Property"); var stringWriter = new StringWriter(); using (var xmlTextWriter = new XmlTextWriter(stringWriter)) { xmlTextWriter.WriteStartElement("filter"); xmlTextWriter.WriteAttributeString("opname", FilterOperations.OP_EQUALS.OpName); xmlTextWriter.WriteAttributeString("operand", operand); xmlTextWriter.WriteEndElement(); } var xmlReader = new XmlTextReader(new StringReader(stringWriter.ToString())); while (!xmlReader.IsStartElement()) { xmlReader.Read(); } FilterPredicate filterPredicate = FilterPredicate.ReadXml(xmlReader); FilterInfo filterInfo = new FilterInfo(new FilterSpec(column.PropertyPath, filterPredicate), column, rootColumn); return(filterInfo.Error); }
public static RowFilter ReadXml(XmlReader reader) { var rowFilter = new RowFilter(); rowFilter.Text = reader.GetAttribute("text"); if (!string.IsNullOrEmpty(rowFilter.Text)) { rowFilter.CaseSensitive = reader.GetAttribute("caseSensitive") != null; } if (reader.IsEmptyElement) { reader.Read(); return(rowFilter); } reader.Read(); var columnFilters = new List <ColumnFilter>(); var columnSorts = new List <ColumnSort>(); while (true) { if (reader.IsStartElement("columnFilter")) { var columnFilter = new ColumnFilter(new ColumnId(reader.GetAttribute("column")), FilterPredicate.ReadXml(reader)); if (reader.IsEmptyElement) { reader.Read(); } else { reader.Read(); reader.ReadEndElement(); } columnFilters.Add(columnFilter); } else if (reader.IsStartElement("columnSort")) { var direction = Equals(SORT_DESC, reader.GetAttribute("direction")) ? ListSortDirection.Descending : ListSortDirection.Ascending; var columnSort = new ColumnSort(new ColumnId(reader.GetAttribute("column")), direction); columnSorts.Add(columnSort); if (reader.IsEmptyElement) { reader.Read(); } else { reader.Read(); reader.ReadEndElement(); } } else if (reader.NodeType == XmlNodeType.EndElement) { reader.ReadEndElement(); break; } else { reader.Read(); } } rowFilter.ColumnFilters = ImmutableList.ValueOf(columnFilters); rowFilter.ColumnSorts = ImmutableList.ValueOf(columnSorts); return(rowFilter); }