title: Custom JSON contract resolver to ignore all properties without a custom annotation
body: <p>I'm looking to combine <code>[JsonProperty(&quot;name&quot;)]</code> and <code>![JsonIgnore]</code> into my own custom resolver and I just need some help on the syntax.</p>
  <p>So when serializing this class I want to ignore all properties without my custom attribute and also specify the serialized name for the property like so:</p>
  <pre><code>public class MyClass
  {
      [MyCustomProperty(&quot;name&quot;)]
      public string SomeName { get; set; }
  
      [MyCustomProperty(&quot;value&quot;)]
      public string SomeValue { get; set; }
      
      public string AnotherName {get; set; }
      
      public string AnotherValue {get; set; }
  }
  </code></pre>
  <p>Expected result:</p>
  <pre><code>{
      &quot;name&quot;: &quot;Apple&quot;,
      &quot;value&quot;: &quot;Delicious&quot;
  }
  </code></pre>
  <p>This is how far I got with my resolver:</p>
  <pre><code>public class MyCustomProperty : Attribute
  {
      public string Property { get; set; }
      public MyCustomProperty(string property)
      {
          Property = property;
      }
  }
  
  public class CustomResolver : DefaultContractResolver
  {
      protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
      {
          JsonProperty property = base.CreateProperty(member, memberSerialization);
          Type itemType = property.PropertyType.GetGenericArguments().First();
          MyCustomProperty customProperty = itemType.GetCustomAttribute&lt;MyCustomProperty&gt;();
          property.PropertyName = MyCustomProperty.Property;
          return property;
      }
  }
  </code></pre>
  <p>I'm not exactly sure where to add the <em>ignore if no attribute</em> part.</p>