/* F E V A L U A T E */ /*---------------------------------------------------------------------------- * %%Function: FEvaluate * %%Qualified: AzLog.AzLogFilter.FEvaluate * %%Contact: rlittle * * Evaluate the item against the filter, return true if it matches * ----------------------------------------------------------------------------*/ public bool FEvaluate(ILogFilterItem ilf) { if (m_plazlfo == null || m_plazlfo.Count == 0) { return(true); } // evaluate the list using a stack... List <bool> plfStack = new List <bool>(); for (int i = 0; i < m_plazlfo.Count; i++) { AzLogFilterOperation azlfo = m_plazlfo[i]; switch (azlfo.Op) { case AzLogFilterOperation.OperationType.Value: plfStack.Add(azlfo.Condition.FEvaluate(ilf)); break; case AzLogFilterOperation.OperationType.And: { bool f1 = plfStack[plfStack.Count - 1]; bool f2 = plfStack[plfStack.Count - 2]; plfStack.RemoveRange(plfStack.Count - 2, 2); plfStack.Add(f1 && f2); break; } case AzLogFilterOperation.OperationType.Or: { bool f1 = plfStack[plfStack.Count - 1]; bool f2 = plfStack[plfStack.Count - 2]; plfStack.RemoveRange(plfStack.Count - 2, 2); plfStack.Add(f1 || f2); break; } } } if (plfStack.Count > 1) { throw new Exception("expression did not reduce"); } return(plfStack[0]); }
/* A D D */ /*---------------------------------------------------------------------------- %%Function: Add %%Qualified: AzLog.AzLogFilter.Add %%Contact: rlittle add a boolean log filter operation ----------------------------------------------------------------------------*/ public void Add(AzLogFilterOperation.OperationType ot) { InvalFilterID(); m_plazlfo.Add(new AzLogFilterOperation(ot, null)); }