Skip to content

Commit

Permalink
optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
izanhzh committed Jan 3, 2025
1 parent 42cb66c commit 07d89d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 42 deletions.
16 changes: 4 additions & 12 deletions src/MiniExcel/IMiniExcelDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@ public interface IMiniExcelDataReader : IDataReader, IAsyncDisposable
{
Task CloseAsync();

Task<string> GetNameAsync(int i);
Task<string> GetNameAsync(int i, CancellationToken cancellationToken = default);

Task<string> GetNameAsync(int i, CancellationToken cancellationToken);
Task<object> GetValueAsync(int i, CancellationToken cancellationToken = default);

Task<object> GetValueAsync(int i);
Task<bool> NextResultAsync(CancellationToken cancellationToken = default);

Task<object> GetValueAsync(int i, CancellationToken cancellationToken);

Task<bool> NextResultAsync();

Task<bool> NextResultAsync(CancellationToken cancellationToken);

Task<bool> ReadAsync();

Task<bool> ReadAsync(CancellationToken cancellationToken);
Task<bool> ReadAsync(CancellationToken cancellationToken = default);
}
}
34 changes: 4 additions & 30 deletions src/MiniExcel/MiniExcelDataReaderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,12 @@ public abstract class MiniExcelDataReaderBase : IMiniExcelDataReader
/// <returns></returns>
public virtual bool NextResult() => false;

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
public Task<bool> NextResultAsync() => NextResultAsync(CancellationToken.None);

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public virtual Task<bool> NextResultAsync(CancellationToken cancellationToken)
public virtual Task<bool> NextResultAsync(CancellationToken cancellationToken = default)
{
if (cancellationToken.IsCancellationRequested)
{
Expand All @@ -241,20 +235,13 @@ public virtual Task<bool> NextResultAsync(CancellationToken cancellationToken)
/// <returns></returns>
public abstract string GetName(int i);

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
public Task<string> GetNameAsync(int i) => GetNameAsync(i, CancellationToken.None);

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="i"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public virtual Task<string> GetNameAsync(int i, CancellationToken cancellationToken)
public virtual Task<string> GetNameAsync(int i, CancellationToken cancellationToken = default)
{
if (cancellationToken.IsCancellationRequested)
{
Expand All @@ -280,20 +267,13 @@ public virtual Task<string> GetNameAsync(int i, CancellationToken cancellationTo
/// <returns></returns>
public abstract object GetValue(int i);

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="i"></param>
/// <returns></returns>
public Task<object> GetValueAsync(int i) => GetValueAsync(i, CancellationToken.None);

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="i"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public virtual Task<object> GetValueAsync(int i, CancellationToken cancellationToken)
public virtual Task<object> GetValueAsync(int i, CancellationToken cancellationToken = default)
{
if (cancellationToken.IsCancellationRequested)
{
Expand All @@ -318,18 +298,12 @@ public virtual Task<object> GetValueAsync(int i, CancellationToken cancellationT
/// <returns></returns>
public abstract bool Read();

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns></returns>
public Task<bool> ReadAsync() => ReadAsync(CancellationToken.None);

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public virtual Task<bool> ReadAsync(CancellationToken cancellationToken)
public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default)
{
if (cancellationToken.IsCancellationRequested)
{
Expand Down

0 comments on commit 07d89d3

Please sign in to comment.