1
我有一个应用程序,我在哪些方面使用过滤器条件,但我不知道在这个过滤条件中使用字 “递归”的含义 这是一些代码为什么我们需要递归地过滤内容
// Indicates a recursive filter. Only valid for object type property filters.
private bool m_recursive = false;
------------------------
/// <summary>
/// Method to apply an object filter to an object.
/// </summary>
/// <param name="myObject">the object to which to apply the filter</param>
/// <returns>true if the object passes the filter, false otherwise</returns>
public bool Apply(DataModelObject myObject)
{
----------------------
/// Method to apply a property filter
/// </summary>
/// <param name="myObject">the object to which to apply the filter</param>
/// <param name="filteredType">type of the object to which to apply the filter</param>
/// <returns>true if the object passes the property filter, false otherwise</returns>
public bool Apply(DataModelObject myObject, Type filteredType)
{
switch(FilterType)
{
case enumFilterType.regularExpr:
switch(Operator)
{
case enumOperator.eq:
------------------------------------
case enumFilterType.strExpr:
switch(Operator)
{
case enumOperator.eq:
-------------------------------------
case enumFilterType.objectFilt:
do
{
retval = ((ObjectFilter)m_filterValue).Apply(propVal);
myObject = propVal;
if (m_recursive && retval == false && myObject != null)
{
propVal = (DataModelObject)prop.GetValue(myObject, null);
}
else
{
myObject = null;
}
} while (myObject != null);
}
if(m_operator == enumOperator.ne)
{
retval = !retval;
}
-----------------------
public object Clone()
{
clone.m_recursive = this.m_recursive;
return clone;
}
可为什么递归错误使用这里
请缩进代码 – 2010-10-13 07:02:52
另外,请让我们知道您在代码中显示的方法的签名。 – 2010-10-13 07:08:43
我编辑了我的问题 – peter 2010-10-13 07:38:43