title: Automatically apply JsonConverter attribute to all properties of type
body: <p><strong>I have a custom JsonConverter</strong> for <code>DateTimeOffset</code> properties in my ViewModels. I have 100+ ViewModels.</p>
  
  <pre><code>public class ItemViewModel 
  {
    public string Name { get; set; }
  
    [JsonConverter(typeof(CustomDateTimeOffsetConverter))]
    public DateTimeOffset DateCreated { get; set; }
  }
  </code></pre>
  
  <p>How can I apply this attribute to all DateTimeOffset properties, without adding it to all my ViewModels?</p>
  
  <p>I thought I had the solution when I read <a href="https://stackoverflow.com/a/27333955/433384">this answer</a>, but when I apply it, the CustomResolver only fires on the parent object itself, and not the DateTimeOffset property, or any property.</p>
  
  <pre><code>public class CustomResolver : DefaultContractResolver
  {
      protected override JsonObjectContract CreateObjectContract(Type objectType)
      {
          JsonObjectContract contract = base.CreateObjectContract(objectType);
          if (objectType == typeof(DateTimeOffset))
          {
              contract.Converter = new CustomDateTimeOffsetConverter();
          }
          return contract;
      }
  }
  </code></pre>
  
  <p>So to recap, I have everything else working. If I add the <code>[JsonConverter(typeof(CustomDateTimeOffsetConverter))]</code> attribute manually, then my application works like a charm. I am only asking how to add the attribute automatically, instead of manually.</p>