title: System.Text.Json JsonConverter with Factory
body: <p>I have <code>DomainObject</code> which combines data and process together. It's need a few services from service provider. But System.Text.Json can't deserialize object with constructor with services. So I want to introduce <code>DomainObjectFactory</code>. How can I use this factory for deserialization?</p>
  <pre><code>    public record DomainObject
      {
          private readonly IDateTimeProvider dateTimeProvider;
          public Guid Id { get; }
          public string Name { get; }
  
          public DomainObject(IDateTimeProvider dateTimeProvider, Guid id, string name)
          {
              this.dateTimeProvider = dateTimeProvider;
  
              Id = id;
              Name = name;
          }
      }
  
      public class DomainObjectFactory
      {
          private readonly IDateTimeProvider dateTimeProvider;
  
          public DomainObjectFactory(IDateTimeProvider dateTimeProvider)
          {
              this.dateTimeProvider = dateTimeProvider;
          }
  
          public DomainObject Create(Guid id, string name)
          {
              return new(dateTimeProvider, id, name);
          }
      }
  </code></pre>
  <p>Have to I use custom <code>JsonConverter</code>? Or is there a better option for me?</p>
  <pre><code>public class DomainObjectJsonConverter : JsonConverter&lt;DomainObject&gt;
  {
      private readonly DomainObjectFactory domainObjectFactory;
  
      public DomainObjectJsonConverter(DomainObjectFactory domainObjectFactory)
      {
          this.domainObjectFactory = domainObjectFactory;
      }
  
  
      public override DomainObject Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
      {
  
          return domainObjectFactory.Create( ??? );
      }
  
      public override void Write(Utf8JsonWriter writer, DomainObject domainObject, JsonSerializerOptions options)
      {
          //I don't want to customize this
      }
  }
  </code></pre>