Skip to content

Commit

Permalink
refactor: remove the all delegates to Delegate.cs file and remove the…
Browse files Browse the repository at this point in the history
… 'Delegate' suffix
  • Loading branch information
yingtingxu committed Jul 10, 2018
1 parent 2cb105f commit a191daf
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 54 deletions.
38 changes: 38 additions & 0 deletions src/Delegates.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) rigofunc (xuyingting). All rights reserved.

namespace FluentExcel
{
/// <summary>
/// Typed row data validator delegate, validate current row before adding it to the result list.
/// </summary>
/// <param name="rowIndex">Index of current row in excel</param>
/// <param name="rowData">Model data of current row</param>
/// <returns>Whether the row data passes validation</returns>
public delegate bool RowDataValidator<TModel>(int rowIndex, TModel rowData) where TModel : class;

/// <summary>
/// Row data validator delegate, validate current row before adding it to the result list.
/// </summary>
/// <param name="rowIndex">Index of current row in excel</param>
/// <param name="rowData">Model data of current row</param>
/// <returns>Whether the row data passes validation</returns>
public delegate bool RowDataValidator(int rowIndex, object rowData);

/// <summary>
/// Cell value validator delegate, validate current cell value before <see cref="PropertyConfiguration.CellValueConverter"/>
/// </summary>
/// <param name="rowIndex">Row index of current cell in excel</param>
/// <param name="columnIndex">Column index of current cell in excel</param>
/// <param name="value">Value of current cell</param>
/// <returns>Whether the value passes validation</returns>
public delegate bool CellValueValidator(int rowIndex, int columnIndex, object value);

/// <summary>
/// Cell value converter delegate.
/// </summary>
/// <param name="rowIndex">Row index of current cell in excel</param>
/// <param name="columnIndex">Column index of current cell in excel</param>
/// <param name="value">Value of current cell</param>
/// <returns>The converted value</returns>
public delegate object CellValueConverter(int rowIndex, int columnIndex, object value);
}
1 change: 0 additions & 1 deletion src/ExcelSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace FluentExcel
{
using System;
using System.Collections.Generic;
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;

/// <summary>
Expand Down
14 changes: 3 additions & 11 deletions src/FluentConfiguration/FluentConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@ namespace FluentExcel
/// <typeparam name="TModel">The type of model.</typeparam>
public class FluentConfiguration<TModel> : IFluentConfiguration where TModel : class
{
/// <summary>
/// Typed row data validator delegate, validate current row before adding it to the result list.
/// </summary>
/// <param name="rowIndex">Index of current row in excel</param>
/// <param name="rowData">Model data of current row</param>
/// <returns>Whether the row data passes validation</returns>
public delegate bool RowDataValidatorTypedDelegate(int rowIndex, TModel rowData);

private Dictionary<string, PropertyConfiguration> _propertyConfigurations;
private List<StatisticsConfiguration> _statisticsConfigurations;
private List<FilterConfiguration> _filterConfigurations;
private List<FreezeConfiguration> _freezeConfigurations;
private RowDataValidatorDelegate _rowDataValidator;
private RowDataValidator _rowDataValidator;
private bool _skipInvalidRows;

/// <summary>
Expand Down Expand Up @@ -92,7 +84,7 @@ public IReadOnlyList<FreezeConfiguration> FreezeConfigurations
/// Gets the row data validator.
/// </summary>
/// <value>The row data validator.</value>
public RowDataValidatorDelegate RowDataValidator { get { return _rowDataValidator; } }
public RowDataValidator RowDataValidator { get { return _rowDataValidator; } }

/// <summary>
/// Gets the value indicating whether to skip the rows with validation failure while loading the excel data.
Expand Down Expand Up @@ -281,7 +273,7 @@ public FluentConfiguration<TModel> HasFreeze(int columnSplit, int rowSplit, int
/// </summary>
/// <returns>The <see cref="FluentConfiguration{TModel}"/>.</returns>
/// <param name="rowDataValidator">The row data validator</param>
public FluentConfiguration<TModel> HasRowDataValidator(RowDataValidatorTypedDelegate rowDataValidator)
public FluentConfiguration<TModel> HasRowDataValidator(RowDataValidator<TModel> rowDataValidator)
{
if (null == rowDataValidator)
{
Expand Down
10 changes: 1 addition & 9 deletions src/FluentConfiguration/IFluentConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ namespace FluentExcel
{
using System.Collections.Generic;

/// <summary>
/// Row data validator delegate, validate current row before adding it to the result list.
/// </summary>
/// <param name="rowIndex">Index of current row in excel</param>
/// <param name="rowData">Model data of current row</param>
/// <returns>Whether the row data passes validation</returns>
public delegate bool RowDataValidatorDelegate(int rowIndex, object rowData);

/// <summary>
/// Provides the interfaces for the fluent configuration.
/// </summary>
Expand Down Expand Up @@ -45,7 +37,7 @@ public interface IFluentConfiguration
/// Gets the row data validator.
/// </summary>
/// <value>The row data validator.</value>
RowDataValidatorDelegate RowDataValidator { get; }
RowDataValidator RowDataValidator { get; }

/// <summary>
/// Gets the value indicating whether to skip the rows with validation failure while loading the excel data.
Expand Down
30 changes: 6 additions & 24 deletions src/FluentConfiguration/PropertyConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@ namespace FluentExcel
{
using System;

/// <summary>
/// Cell value validator delegate, validate current cell value before <see cref="PropertyConfiguration.CellValueConverter"/>
/// </summary>
/// <param name="rowIndex">Row index of current cell in excel</param>
/// <param name="columnIndex">Column index of current cell in excel</param>
/// <param name="value">Value of current cell</param>
/// <returns>Whether the value passes validation</returns>
public delegate bool CellValueValidatorDelegate(int rowIndex, int columnIndex, object value);

/// <summary>
/// Cell value converter delegate.
/// </summary>
/// <param name="rowIndex">Row index of current cell in excel</param>
/// <param name="columnIndex">Column index of current cell in excel</param>
/// <param name="value">Value of current cell</param>
/// <returns>The converted value</returns>
public delegate object CellValueConverterDelegate(int rowIndex, int columnIndex, object value);

/// <summary>
/// Represents the configuration for the specfidied property.
/// </summary>
Expand Down Expand Up @@ -72,12 +54,12 @@ public class PropertyConfiguration
/// <summary>
/// Gets the cell value validator to validate the cell value.
/// </summary>
public CellValueValidatorDelegate CellValueValidator { get; internal set; }
public CellValueValidator CellValueValidator { get; internal set; }

/// <summary>
/// Gets the value converter to convert the value.
/// </summary>
public CellValueConverterDelegate CellValueConverter { get; internal set; }
public CellValueConverter CellValueConverter { get; internal set; }

/// <summary>
/// Configures the excel cell index for the property.
Expand Down Expand Up @@ -150,7 +132,7 @@ public PropertyConfiguration HasAutoIndex()
/// </summary>
/// <param name="cellValueConverter">The value converter.</param>
/// <returns>The <see cref="PropertyConfiguration"/>.</returns>
public PropertyConfiguration HasValueConverter(CellValueConverterDelegate cellValueConverter)
public PropertyConfiguration HasValueConverter(CellValueConverter cellValueConverter)
{
CellValueConverter = cellValueConverter;

Expand All @@ -162,7 +144,7 @@ public PropertyConfiguration HasValueConverter(CellValueConverterDelegate cellVa
/// </summary>
/// <param name="cellValueValidator">The value validator.</param>
/// <returns>The <see cref="PropertyConfiguration"/>.</returns>
public PropertyConfiguration HasValueValidator(CellValueValidatorDelegate cellValueValidator)
public PropertyConfiguration HasValueValidator(CellValueValidator cellValueValidator)
{
CellValueValidator = cellValueValidator;

Expand Down Expand Up @@ -223,7 +205,7 @@ public void IsIgnored(int index, string title, string formatter = null, bool exp
/// <param name="formatter">The formatter will be used for formatting the value.</param>
/// <param name="allowMerge">If set to <c>true</c> allow merge the same value cells.</param>
/// <param name="cellValueConverter">The value converter.</param>
public void HasExcelCell(int index, string title, string formatter = null, bool allowMerge = false, CellValueConverterDelegate cellValueConverter = null)
public void HasExcelCell(int index, string title, string formatter = null, bool allowMerge = false, CellValueConverter cellValueConverter = null)
{
if (index < 0)
{
Expand All @@ -248,7 +230,7 @@ public void HasExcelCell(int index, string title, string formatter = null, bool
/// This method will try to autodiscover the column index by its <paramref name="title"/>
/// </remarks>
/// <param name="cellValueConverter">The value converter.</param>
public void HasAutoIndexExcelCell(string title, string formatter = null, bool allowMerge = false, CellValueConverterDelegate cellValueConverter = null)
public void HasAutoIndexExcelCell(string title, string formatter = null, bool allowMerge = false, CellValueConverter cellValueConverter = null)
{
Index = -1;
Title = title;
Expand Down
5 changes: 2 additions & 3 deletions src/FluentExcel.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Authors>rigofunc (xuyingting)</Authors>
Expand All @@ -9,8 +8,8 @@
<PackageLicenseUrl>https://github.com/Arch/FluentExcel/blob/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/Arch/FluentExcel</RepositoryUrl>
<RepositoryType>GIT</RepositoryType>
<PackageTags>FluentExcel, NPOI, Fluent API, NPOI.Extension, xyting, Arch, dotnetcore</PackageTags>
<Version>1.1.3.0</Version>
<PackageTags>FluentExcel, NPOI, Fluent API, NPOI.Extension</PackageTags>
<Version>2.2.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/FluentExcel.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<iconUrl>https://nuget.org/Content/Images/packageDefaultIcon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>1. End user can specified the title cell style by setting Excel.Setting.TitleCellStyleApplier.</releaseNotes>
<releaseNotes>This release support netstandard 2.0.</releaseNotes>
<copyright>Copyright © rigofunc (xuyingting). All rights reserved.</copyright>
<tags>npoi, excel, fluentexcel</tags>
</metadata>
Expand Down
5 changes: 0 additions & 5 deletions src/packages.config

This file was deleted.

0 comments on commit a191daf

Please sign in to comment.