/// <summary> /// Creates a new instance of <see cref="IDataSinkAdapter" /> with the provided configuration. /// </summary> /// <param name="configuration">Data sink adapter configuration.</param> /// <param name="context">Data transfer operation context.</param> /// <param name="cancellation">Cancellation token.</param> /// <returns>Task that represents asynchronous create operation.</returns> public async Task <IDataSinkAdapter> CreateAsync(IJsonFileSinkAdapterConfiguration configuration, IDataTransferContext context, CancellationToken cancellation) { Guard.NotNull("configuration", configuration); return(new JsonFileSinkAdapter( await SinkStreamProvidersFactory.Create(configuration.File, configuration.Overwrite).CreateWriter(cancellation), JsonSerializersFactory.Create(configuration.Prettify))); }
private static IDataSinkAdapter Create(IJsonFileSinkAdapterConfiguration configuration) { Guard.NotNull("configuration", configuration); // Ensure output folder exists try { Directory.CreateDirectory(Path.GetDirectoryName(configuration.File)); } catch { } return(new JsonFileSinkAdapter( File.Open(configuration.File, configuration.Overwrite ? FileMode.Create : FileMode.CreateNew), JsonSerializersFactory.Create(configuration.Prettify))); }
/// <summary> /// Creates a new instance of <see cref="JsonFileSourceAdapterFactory" />. /// </summary> public JsonFileSourceAdapterFactory() { serializer = JsonSerializersFactory.Create(false); }