Skip to content

Commit a191daf

Browse files
author
yingtingxu
committed
refactor: remove the all delegates to Delegate.cs file and remove the 'Delegate' suffix
1 parent 2cb105f commit a191daf

File tree

8 files changed

+51
-54
lines changed

8 files changed

+51
-54
lines changed

src/Delegates.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) rigofunc (xuyingting). All rights reserved.
2+
3+
namespace FluentExcel
4+
{
5+
/// <summary>
6+
/// Typed row data validator delegate, validate current row before adding it to the result list.
7+
/// </summary>
8+
/// <param name="rowIndex">Index of current row in excel</param>
9+
/// <param name="rowData">Model data of current row</param>
10+
/// <returns>Whether the row data passes validation</returns>
11+
public delegate bool RowDataValidator<TModel>(int rowIndex, TModel rowData) where TModel : class;
12+
13+
/// <summary>
14+
/// Row data validator delegate, validate current row before adding it to the result list.
15+
/// </summary>
16+
/// <param name="rowIndex">Index of current row in excel</param>
17+
/// <param name="rowData">Model data of current row</param>
18+
/// <returns>Whether the row data passes validation</returns>
19+
public delegate bool RowDataValidator(int rowIndex, object rowData);
20+
21+
/// <summary>
22+
/// Cell value validator delegate, validate current cell value before <see cref="PropertyConfiguration.CellValueConverter"/>
23+
/// </summary>
24+
/// <param name="rowIndex">Row index of current cell in excel</param>
25+
/// <param name="columnIndex">Column index of current cell in excel</param>
26+
/// <param name="value">Value of current cell</param>
27+
/// <returns>Whether the value passes validation</returns>
28+
public delegate bool CellValueValidator(int rowIndex, int columnIndex, object value);
29+
30+
/// <summary>
31+
/// Cell value converter delegate.
32+
/// </summary>
33+
/// <param name="rowIndex">Row index of current cell in excel</param>
34+
/// <param name="columnIndex">Column index of current cell in excel</param>
35+
/// <param name="value">Value of current cell</param>
36+
/// <returns>The converted value</returns>
37+
public delegate object CellValueConverter(int rowIndex, int columnIndex, object value);
38+
}

src/ExcelSetting.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace FluentExcel
44
{
55
using System;
66
using System.Collections.Generic;
7-
using NPOI.HSSF.Util;
87
using NPOI.SS.UserModel;
98

109
/// <summary>

src/FluentConfiguration/FluentConfiguration.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,11 @@ namespace FluentExcel
1414
/// <typeparam name="TModel">The type of model.</typeparam>
1515
public class FluentConfiguration<TModel> : IFluentConfiguration where TModel : class
1616
{
17-
/// <summary>
18-
/// Typed row data validator delegate, validate current row before adding it to the result list.
19-
/// </summary>
20-
/// <param name="rowIndex">Index of current row in excel</param>
21-
/// <param name="rowData">Model data of current row</param>
22-
/// <returns>Whether the row data passes validation</returns>
23-
public delegate bool RowDataValidatorTypedDelegate(int rowIndex, TModel rowData);
24-
2517
private Dictionary<string, PropertyConfiguration> _propertyConfigurations;
2618
private List<StatisticsConfiguration> _statisticsConfigurations;
2719
private List<FilterConfiguration> _filterConfigurations;
2820
private List<FreezeConfiguration> _freezeConfigurations;
29-
private RowDataValidatorDelegate _rowDataValidator;
21+
private RowDataValidator _rowDataValidator;
3022
private bool _skipInvalidRows;
3123

3224
/// <summary>
@@ -92,7 +84,7 @@ public IReadOnlyList<FreezeConfiguration> FreezeConfigurations
9284
/// Gets the row data validator.
9385
/// </summary>
9486
/// <value>The row data validator.</value>
95-
public RowDataValidatorDelegate RowDataValidator { get { return _rowDataValidator; } }
87+
public RowDataValidator RowDataValidator { get { return _rowDataValidator; } }
9688

9789
/// <summary>
9890
/// Gets the value indicating whether to skip the rows with validation failure while loading the excel data.
@@ -281,7 +273,7 @@ public FluentConfiguration<TModel> HasFreeze(int columnSplit, int rowSplit, int
281273
/// </summary>
282274
/// <returns>The <see cref="FluentConfiguration{TModel}"/>.</returns>
283275
/// <param name="rowDataValidator">The row data validator</param>
284-
public FluentConfiguration<TModel> HasRowDataValidator(RowDataValidatorTypedDelegate rowDataValidator)
276+
public FluentConfiguration<TModel> HasRowDataValidator(RowDataValidator<TModel> rowDataValidator)
285277
{
286278
if (null == rowDataValidator)
287279
{

src/FluentConfiguration/IFluentConfiguration.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ namespace FluentExcel
44
{
55
using System.Collections.Generic;
66

7-
/// <summary>
8-
/// Row data validator delegate, validate current row before adding it to the result list.
9-
/// </summary>
10-
/// <param name="rowIndex">Index of current row in excel</param>
11-
/// <param name="rowData">Model data of current row</param>
12-
/// <returns>Whether the row data passes validation</returns>
13-
public delegate bool RowDataValidatorDelegate(int rowIndex, object rowData);
14-
157
/// <summary>
168
/// Provides the interfaces for the fluent configuration.
179
/// </summary>
@@ -45,7 +37,7 @@ public interface IFluentConfiguration
4537
/// Gets the row data validator.
4638
/// </summary>
4739
/// <value>The row data validator.</value>
48-
RowDataValidatorDelegate RowDataValidator { get; }
40+
RowDataValidator RowDataValidator { get; }
4941

5042
/// <summary>
5143
/// Gets the value indicating whether to skip the rows with validation failure while loading the excel data.

src/FluentConfiguration/PropertyConfiguration.cs

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,6 @@ namespace FluentExcel
44
{
55
using System;
66

7-
/// <summary>
8-
/// Cell value validator delegate, validate current cell value before <see cref="PropertyConfiguration.CellValueConverter"/>
9-
/// </summary>
10-
/// <param name="rowIndex">Row index of current cell in excel</param>
11-
/// <param name="columnIndex">Column index of current cell in excel</param>
12-
/// <param name="value">Value of current cell</param>
13-
/// <returns>Whether the value passes validation</returns>
14-
public delegate bool CellValueValidatorDelegate(int rowIndex, int columnIndex, object value);
15-
16-
/// <summary>
17-
/// Cell value converter delegate.
18-
/// </summary>
19-
/// <param name="rowIndex">Row index of current cell in excel</param>
20-
/// <param name="columnIndex">Column index of current cell in excel</param>
21-
/// <param name="value">Value of current cell</param>
22-
/// <returns>The converted value</returns>
23-
public delegate object CellValueConverterDelegate(int rowIndex, int columnIndex, object value);
24-
257
/// <summary>
268
/// Represents the configuration for the specfidied property.
279
/// </summary>
@@ -72,12 +54,12 @@ public class PropertyConfiguration
7254
/// <summary>
7355
/// Gets the cell value validator to validate the cell value.
7456
/// </summary>
75-
public CellValueValidatorDelegate CellValueValidator { get; internal set; }
57+
public CellValueValidator CellValueValidator { get; internal set; }
7658

7759
/// <summary>
7860
/// Gets the value converter to convert the value.
7961
/// </summary>
80-
public CellValueConverterDelegate CellValueConverter { get; internal set; }
62+
public CellValueConverter CellValueConverter { get; internal set; }
8163

8264
/// <summary>
8365
/// Configures the excel cell index for the property.
@@ -150,7 +132,7 @@ public PropertyConfiguration HasAutoIndex()
150132
/// </summary>
151133
/// <param name="cellValueConverter">The value converter.</param>
152134
/// <returns>The <see cref="PropertyConfiguration"/>.</returns>
153-
public PropertyConfiguration HasValueConverter(CellValueConverterDelegate cellValueConverter)
135+
public PropertyConfiguration HasValueConverter(CellValueConverter cellValueConverter)
154136
{
155137
CellValueConverter = cellValueConverter;
156138

@@ -162,7 +144,7 @@ public PropertyConfiguration HasValueConverter(CellValueConverterDelegate cellVa
162144
/// </summary>
163145
/// <param name="cellValueValidator">The value validator.</param>
164146
/// <returns>The <see cref="PropertyConfiguration"/>.</returns>
165-
public PropertyConfiguration HasValueValidator(CellValueValidatorDelegate cellValueValidator)
147+
public PropertyConfiguration HasValueValidator(CellValueValidator cellValueValidator)
166148
{
167149
CellValueValidator = cellValueValidator;
168150

@@ -223,7 +205,7 @@ public void IsIgnored(int index, string title, string formatter = null, bool exp
223205
/// <param name="formatter">The formatter will be used for formatting the value.</param>
224206
/// <param name="allowMerge">If set to <c>true</c> allow merge the same value cells.</param>
225207
/// <param name="cellValueConverter">The value converter.</param>
226-
public void HasExcelCell(int index, string title, string formatter = null, bool allowMerge = false, CellValueConverterDelegate cellValueConverter = null)
208+
public void HasExcelCell(int index, string title, string formatter = null, bool allowMerge = false, CellValueConverter cellValueConverter = null)
227209
{
228210
if (index < 0)
229211
{
@@ -248,7 +230,7 @@ public void HasExcelCell(int index, string title, string formatter = null, bool
248230
/// This method will try to autodiscover the column index by its <paramref name="title"/>
249231
/// </remarks>
250232
/// <param name="cellValueConverter">The value converter.</param>
251-
public void HasAutoIndexExcelCell(string title, string formatter = null, bool allowMerge = false, CellValueConverterDelegate cellValueConverter = null)
233+
public void HasAutoIndexExcelCell(string title, string formatter = null, bool allowMerge = false, CellValueConverter cellValueConverter = null)
252234
{
253235
Index = -1;
254236
Title = title;

src/FluentExcel.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<TargetFrameworks>netstandard2.0</TargetFrameworks>
54
<Authors>rigofunc (xuyingting)</Authors>
@@ -9,8 +8,8 @@
98
<PackageLicenseUrl>https://github.com/Arch/FluentExcel/blob/master/LICENSE</PackageLicenseUrl>
109
<RepositoryUrl>https://github.com/Arch/FluentExcel</RepositoryUrl>
1110
<RepositoryType>GIT</RepositoryType>
12-
<PackageTags>FluentExcel, NPOI, Fluent API, NPOI.Extension, xyting, Arch, dotnetcore</PackageTags>
13-
<Version>1.1.3.0</Version>
11+
<PackageTags>FluentExcel, NPOI, Fluent API, NPOI.Extension</PackageTags>
12+
<Version>2.2.0</Version>
1413
</PropertyGroup>
1514

1615
<ItemGroup>

src/FluentExcel.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<iconUrl>https://nuget.org/Content/Images/packageDefaultIcon.png</iconUrl>
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<description>$description$</description>
14-
<releaseNotes>1. End user can specified the title cell style by setting Excel.Setting.TitleCellStyleApplier.</releaseNotes>
14+
<releaseNotes>This release support netstandard 2.0.</releaseNotes>
1515
<copyright>Copyright © rigofunc (xuyingting). All rights reserved.</copyright>
1616
<tags>npoi, excel, fluentexcel</tags>
1717
</metadata>

src/packages.config

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)