You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
3.0 KiB
64 lines
3.0 KiB
// Author: Gockner, Simon
|
|
// Created: 2020-02-12
|
|
// Copyright(c) 2020 SimonG. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GBase.Interfaces.DataHandling
|
|
{
|
|
/// <summary>
|
|
/// Interface for data writers to implement
|
|
/// </summary>
|
|
public interface IDataWriter
|
|
{
|
|
/// <summary>
|
|
/// Initialize the <see cref="IDataWriter"/>
|
|
/// </summary>
|
|
/// <param name="file"></param>
|
|
/// <param name="rootElementName"></param>
|
|
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the async operation</param>
|
|
/// <returns>Returns true if successful, false if not</returns>
|
|
Task<bool> InitFile(FileStream file, string rootElementName, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Write the data of a property
|
|
/// </summary>
|
|
/// <typeparam name="T">The <see cref="Type"/></typeparam>
|
|
/// <typeparam name="TProperty">The <see cref="Type"/> of the property</typeparam>
|
|
/// <param name="file"></param>
|
|
/// <param name="propertyName">The name of the property</param>
|
|
/// <param name="value">The value of the property</param>
|
|
/// <param name="overwrite">If true an existing value is overwritten, if false an additional value is added</param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>A <see cref="Task"/> to await</returns>
|
|
Task Write<T, TProperty>(FileStream file, string propertyName, string value, bool overwrite, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Write the data of a property
|
|
/// </summary>
|
|
/// <typeparam name="T">The <see cref="Type"/></typeparam>
|
|
/// <param name="file"></param>
|
|
/// <param name="propertyName">The name of the property</param>
|
|
/// <param name="value">The value of the property</param>
|
|
/// <param name="propertyType"></param>
|
|
/// <param name="overwrite">If true an existing value is overwritten, if false an additional value is added</param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>A <see cref="Task"/> to await</returns>
|
|
Task Write<T>(FileStream file, string propertyName, string value, Type propertyType, bool overwrite, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Remove the value for the given property
|
|
/// </summary>
|
|
/// <typeparam name="T">The <see cref="Type"/> of the property</typeparam>
|
|
/// <typeparam name="TProperty">The <see cref="Type"/> of the property</typeparam>
|
|
/// <param name="file"></param>
|
|
/// <param name="propertyName">The name of the property</param>
|
|
/// <param name="value">The value to set</param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns>A <see cref="Task"/> to await</returns>
|
|
Task Remove<T, TProperty>(FileStream file, string propertyName, string value, CancellationToken cancellationToken);
|
|
}
|
|
} |