Class Filter
- Namespace
- GroupeIsa.Neos.Application.Filters
- Assembly
- GroupeIsa.Neos.Application.Abstractions.dll
Represents the filter of a property.
[ExcludeFromCodeCoverage]
public class Filter : ICloneable
- Inheritance
-
Filter
- Implements
- Inherited Members
- Extension Methods
Constructors
Filter()
Initializes a new instance of the Filter class.
public Filter()
Filter(FilterCondition)
Initializes a new instance of the Filter class.
public Filter(FilterCondition condition)
Parameters
conditionFilterConditionFilter condition.
Filter(FilterCondition?, FilterLogicalOperator, params Filter[])
Initializes a new instance of the Filter class.
public Filter(FilterCondition? condition, FilterLogicalOperator logicalOperator, params Filter[] children)
Parameters
conditionFilterConditionFilter condition.
logicalOperatorFilterLogicalOperatorFilter operator logical.
childrenFilter[]Children filter collection.
Filter(params Filter[])
Initializes a new instance of the Filter class.
public Filter(params Filter[] children)
Parameters
childrenFilter[]Children filter collection.
Filter(string, FilterOperator, params object?[])
Initializes a new instance of the Filter class.
public Filter(string propertyPath, FilterOperator filterOperator, params object?[] values)
Parameters
propertyPathstringProperty path.
filterOperatorFilterOperatorCondition operator.
valuesobject[]Value of the filter condition.
Properties
Active
Gets or sets a value indicating whether the filter is active. Only for transpilation.
public bool Active { get; set; }
Property Value
Children
Gets or sets the children.
public List<Filter> Children { get; set; }
Property Value
Condition
Gets or sets the filter condition.
public FilterCondition? Condition { get; set; }
Property Value
IsCondition
Gets a value indicating whether if the filter is a condition.
public bool IsCondition { get; }
Property Value
IsEmpty
Gets a value indicating whether if the filter is empty.
public bool IsEmpty { get; }
Property Value
IsSimple
Gets a value indicating whether if the filter is composed of only condition filters linked by the "And" operator for all filters.
public bool IsSimple { get; }
Property Value
LogicalOperator
Gets the filter logical operator.
public FilterLogicalOperator LogicalOperator { get; }
Property Value
NamedFilterId
Gets or sets the named filter identifier.
public string? NamedFilterId { get; set; }
Property Value
ReadOnly
Gets or sets a value indicating whether the filter is read only. Only for transpilation.
public bool ReadOnly { get; set; }
Property Value
Visible
Gets or sets a value indicating whether the filter is visible. Only for transpilation.
public bool Visible { get; set; }
Property Value
Methods
Add(Filter)
Adds the specified filter to the children of this filter.
public Filter Add(Filter filter)
Parameters
filterFilterThe filter to add.
Returns
- Filter
Return the filter with the specified filter added.
Clear()
Removes all filters from the filter.
public void Clear()
Clone()
Creates a shallow copy of the filter.
public object Clone()
Returns
- object
A shallow copy of the filter.
ConvertFromJson(string)
Converts from JSON.
[Obsolete("Use IViewModel.ConvertFilterFromJsonAsync method instead.", true)]
public static Filter ConvertFromJson(string value)
Parameters
valuestringValue.
Returns
ConvertToJson()
Converts to JSON. Only for transpilation.
[SuppressMessage("Minor Code Smell", "S2325:Methods and properties that don't access instance data should be static", Justification = "Transpilation")]
public string ConvertToJson()
Returns
- string
string representation.
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
- bool
true if the specified object is equal to the current object; otherwise, false.
Expand(FilterLogicalOperator?)
Expands a filter.
This filter becomes a child.
public void Expand(FilterLogicalOperator? logicalOperator = null)
Parameters
logicalOperatorFilterLogicalOperator?The logical operator.
Examples
The following example shows how to build the filter : ShipCountry = 'France' or ShipCountry = 'Spain'.
var filter = new Filter("ShipCountry", FilterOperator.Equal, "France");
filter.Expand(FilterLogicalOperator.Or);
filter.Add(new Filter("ShipCountry", FilterOperator.Equal, "Spain"));
ExtractWritableFilter()
Extracts the filter without the invisible or read-only filters. Only for transpilation.
[SuppressMessage("Minor Code Smell", "S2325:Methods and properties that don't access instance data should be static", Justification = "Transpilation")]
public Filter ExtractWritableFilter()
Returns
Find(string)
Returns the first filter found whose property path is the specified property path.
public Filter? Find(string propertyPath)
Parameters
propertyPathstringProperty path.
Returns
- Filter
The first filter found whose property path is the specified property path.
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Join(Filter, FilterLogicalOperator)
Joins the specified filter to this filter with the specified operator.
public Filter Join(Filter filter, FilterLogicalOperator logicalOperator)
Parameters
filterFilterThe filter to add.
logicalOperatorFilterLogicalOperatorThe logical operator.
Returns
- Filter
Return the filter with the specified filter added.
Remove(Filter)
Removes a specific filter recursively.
public bool Remove(Filter filter)
Parameters
filterFilterThe filter to remove.
Returns
- bool
Return true if removes a specific filter recursively.
Simplify()
Simplifies the filter. Only for transpilation.
[SuppressMessage("Minor Code Smell", "S2325:Methods and properties that don't access instance data should be static", Justification = "Transpilation")]
public Filter Simplify()
Returns
- Filter
Same instance.
ToODataString()
Converts the filter to OData string.
public string ToODataString()
Returns
- string
The OData string.
Exceptions
- NotSupportedException
When the filter cannot be converted.
ToSimplifiedFilter()
Converts the filter to a simplified filter.
public Filter ToSimplifiedFilter()
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
ToText()
Converts to human readable text. Only for transpilation.
[SuppressMessage("Minor Code Smell", "S2325:Methods and properties that don't access instance data should be static", Justification = "Transpilation")]
public string? ToText()
Returns
- string
A human readable text.