I have to write a comparison logic.
Following is the code to refactor (as it is looking bad).
// 1. item has filter criteria // 2. return true if current matches filter criteria // 3. Criteria -> 3 fields should be matched ( Security, OrderType, CounterType) // 4. Criteria -> User can specify All (*), If any matching field is All, (NONE for enum), that field should not be matched private static bool CompareOrderItem(Item item, Item current) { String all="All"; bool flag = true;
if (!( String.Equals(item.Security, all) ||String.Equals(current.Security, item.Security)))
flag = false;
if (!( item.OrderType == OrderTypeEnum.None ||Enum.Equals(current.OrderType, item.OrderType)))
flag = false;
if (!( String.Equals(item.Counterparty, all) || String.Equals(current.Counterparty, item.Counterparty)))
flag = false;
return flag ;
}