title: Limit objects in a collection from being serialized based on User
body: <p>I have a webapi that returns an object that contains some collections of objects which also contains a collection of objects. Each of these objects has a bool that represents if the object is 'published' See classes below for general idea.</p>
  
  <pre><code>public class A {
    public int ID { get; set; }
    public List&lt;B&gt; b { get; set;}
  }
  
  public class B {
    public List&lt;C&gt; c { get; set; }
    public List&lt;D&gt; d { get; set; }
    public bool published { get; set; }
  }
  
  public class C {
    public string Title { get; set; }
    public bool published { get; set; }
  }
  
  public class D {
    public string Title { get; set; }
    public bool published { get; set; }
  }
  </code></pre>
  
  <p>What is the best way to make it so when I serialize any of these objects that an unpublished child objects are not included if the user doesn't meet the requirements, IE not in a specific role. Can I add data attributes to my model in some way? I have had a look into using a custom  <code>IContractResolver</code> but I'm not sure its the best way to handle the nested objects. Should I be handling this in the serializing stage or should I be removing the unpublished objects from the children after I get the object from the database.</p>