title: How to filter objects based on type-imposed predicate collections?
body: <p>I have a situation in which i would like to filter objects based on collections of predicates imposed on their particular types:
  Could this be done via precompiled  <code>ExpressionTrees</code> ?</p>
  
  <pre><code>class A
  {
     public int Value {get;set;}
  }
  class B
  {
    public string Name {get;set;}
    public bool IsMajor{get;set;}
  }
  
  
  Dictionary&lt;Type,IEnumerable&lt;Predicate&lt;[object casted to type]&gt;&gt; typePredicateMap=new Dictionary&lt;Type,Predicate&lt;[object casted to type]&gt;&gt;{
     {typeof(A),new List&lt;Predicate&lt;[object casted to A]&gt; { x=&gt;x.Value &gt;100,x=&gt;x.Value&lt;200 }},
     {typeof(B),new List&lt;Predicate&lt;[object casted to B]&gt; { x=&gt;x.Name!="johhnny",x=&gt;x.IsMajor==true }}
  }
  </code></pre>
  
  <p>I said above <code>object casted to Type</code> since i want my predicate to be based on that particular type..</p>
  
  <pre><code>public static bool MeetsCriteria(object data)
  {
      Type type=typeof(data);
      IEnumerable&lt;Predicate&lt;object&gt;predicates=typePredicateMap[type];
      bool isValid=true;
      foreach(var predicate in predicates)
      {
          isValid&amp;=predicate(data);  //
      }
      return isValid;
  }
  </code></pre>