private FilterOperand[] GetOperands(ContentFilterElement element, int expectedCount)
{
FilterOperand[] operands = new FilterOperand[element.FilterOperands.Count];
int ii = 0;
foreach (ExtensionObject extension in element.FilterOperands)
{
if (ExtensionObject.IsNull(extension))
{
throw new ServiceResultException(StatusCodes.BadUnexpectedError, "FilterOperand is null.");
}
FilterOperand operand = extension.Body as FilterOperand;
if (operand == null)
{
throw new ServiceResultException(StatusCodes.BadUnexpectedError, "FilterOperand is not supported.");
}
operands[ii++] = operand;
}
if (expectedCount > 0 && expectedCount != operands.Length)
{
throw new ServiceResultException(StatusCodes.BadUnexpectedError, "ContentFilterElement does not have the correct number of operands.");
}
return operands;
}