title: Operator In/Contains for a Rules Engine
body: <p>I am trying to implement the IN operator for a rules engine
  LeftResult IN RightResult</p>
  
  <pre><code>object leftResult = methodInfo.Invoke(classInstance, leftParams.ToArray());
  object rightResult = methodInfo.Invoke(classInstance, rightParams.ToArray());
  </code></pre>
  
  <p>leftResult is a list of values  and RightResult is a comma seperated string.</p>
  
  <pre><code> case Enumerations.ComparisonType.In:
  
                      if (leftResult != null &amp;&amp; rightResult != null)
                      {
                          List&lt;object&gt; leftList;
                          List&lt;object&gt; rightList;
                          if (leftResult.ToString().Contains(","))
                          {
                              rightList = rightResult as List&lt;object&gt;;
                              if ((leftResult.ToString().Split(',')).Contains(rightList[0].ToString())) result = true;
                              else result = false;
                          }
                          else if (rightResult.ToString().Contains(","))
                          {
                              leftList = leftResult as List&lt;object&gt;;
                              if ((rightResult.ToString().Split(',')).Contains(leftList[0].ToString())) result = true;
                              else result = false;
                          }
                          else if (rightResult.GetType() == typeof(List&lt;object&gt;))
                          {
  
                              if ((rightResult as List&lt;object&gt;).Contains(leftResult)) result = true;
                              else result = false;
                          }
                          else if (leftResult.GetType() == typeof(List&lt;object&gt;))
                          {
  
                              if ((leftResult as List&lt;object&gt;).Contains(rightResult)) result = true;
                              else result = false;
                          }
                      }
  </code></pre>
  
  <p>This is the code I have done to handle cases where the left or the right could be a list or  comma separated string. But it is not working correctly. Can anyone suggest a better way of implementing In/Contains operator for a rules engine</p>
  
  <p>Thank you</p>