/// <summary> /// Constructs a new instance /// </summary> public JsonFactory(IJsonReaderFactory jsonReaderFactory, IJsonWriterFactory jsonWriterFactory, IServiceProvider serviceProvider = null) { ServiceProvider = serviceProvider; JsonReaderFactory = jsonReaderFactory; JsonWriterFactory = jsonWriterFactory; TypeHandlers = new ConcurrentDictionary <Type, IJsonTypeHandler>(); }
public JsonObjectWriter(IJsonWriterFactory factory, IOptions <JsonObjectWriterOptions> options) { Ensure.IsNotNull(factory, nameof(factory)); Ensure.IsNotNull(options, nameof(options)); this.factory = factory; this.options = options.Value; }
public AITelemetrySerializer(IJsonWriterFactory jsonWriterFactory, IContextTagKeys contextTagKeys) { if (jsonWriterFactory == null) { throw new ArgumentNullException("jsonWriterFactory"); } if (contextTagKeys == null) { throw new ArgumentNullException("contextTagKeys"); } _contextTagKeys = contextTagKeys; _jsonWriterFactory = jsonWriterFactory; }
private static IJsonWriter CreateJsonWriter(IServiceProvider container, TextWriter textWriter, bool isIeee754Compatible, ODataMessageWriterSettings writerSettings) { IJsonWriter jsonWriter; if (container == null) { jsonWriter = new JsonWriter(textWriter, isIeee754Compatible); } else { IJsonWriterFactory jsonWriterFactory = container.GetRequiredService <IJsonWriterFactory>(); jsonWriter = jsonWriterFactory.CreateJsonWriter(textWriter, isIeee754Compatible); Debug.Assert(jsonWriter != null, "jsonWriter != null"); } JsonWriter writer = jsonWriter as JsonWriter; if (writer != null && writerSettings.ArrayPool != null) { writer.ArrayPool = writerSettings.ArrayPool; } return(jsonWriter); }