Skip to content

Commit ab190d3

Browse files
committed
Migrate the main project to the latest version of C#
1 parent f2eb701 commit ab190d3

File tree

112 files changed

+4190
-4418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+4190
-4418
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,55 @@
11
using ExcelReportGenerator.Enums;
2-
using System;
32

4-
namespace ExcelReportGenerator.Attributes
3+
namespace ExcelReportGenerator.Attributes;
4+
5+
/// <summary>
6+
/// An attribute that allows you to configure excel column output more flexibly
7+
/// </summary>
8+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
9+
public class ExcelColumnAttribute : Attribute
510
{
6-
/// <summary>
7-
/// An attribute that allows you to configure excel column output more flexibly
8-
/// </summary>
9-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
10-
public class ExcelColumnAttribute : Attribute
11+
public ExcelColumnAttribute()
1112
{
12-
public ExcelColumnAttribute()
13-
{
14-
AggregateFunction = AggregateFunction.NoAggregation;
15-
}
16-
17-
/// <summary>
18-
/// Column caption which will be displayed in excel sheet
19-
/// </summary>
20-
public string Caption { get; set; }
21-
22-
/// <summary>
23-
/// Column width if panel is vertical or row height if panel is horizontal
24-
/// </summary>
25-
public double Width { get; set; }
26-
27-
/// <summary>
28-
/// Aggregate function applied to this column
29-
/// </summary>
30-
public AggregateFunction AggregateFunction { get; set; }
31-
32-
/// <summary>
33-
/// Do not apply an aggregate function even it is specified
34-
/// </summary>
35-
public bool NoAggregate { get; set; }
36-
37-
/// <summary>
38-
/// Display format for number and date columns
39-
/// </summary>
40-
public string DisplayFormat { get; set; }
41-
42-
/// <summary>
43-
/// Do not apply display format even it is specified
44-
/// </summary>
45-
public bool IgnoreDisplayFormat { get; set; }
46-
47-
/// <summary>
48-
/// Adjust to content column width if panel is vertical or row height if panel is horizontal
49-
/// </summary>
50-
public bool AdjustToContent { get; set; }
51-
52-
/// <summary>
53-
/// Order in which the column appears in Excel
54-
/// </summary>
55-
public int Order { get; set; }
13+
AggregateFunction = AggregateFunction.NoAggregation;
5614
}
15+
16+
/// <summary>
17+
/// Column caption which will be displayed in excel sheet
18+
/// </summary>
19+
public string Caption { get; set; }
20+
21+
/// <summary>
22+
/// Column width if panel is vertical or row height if panel is horizontal
23+
/// </summary>
24+
public double Width { get; set; }
25+
26+
/// <summary>
27+
/// Aggregate function applied to this column
28+
/// </summary>
29+
public AggregateFunction AggregateFunction { get; set; }
30+
31+
/// <summary>
32+
/// Do not apply an aggregate function even it is specified
33+
/// </summary>
34+
public bool NoAggregate { get; set; }
35+
36+
/// <summary>
37+
/// Display format for number and date columns
38+
/// </summary>
39+
public string DisplayFormat { get; set; }
40+
41+
/// <summary>
42+
/// Do not apply display format even it is specified
43+
/// </summary>
44+
public bool IgnoreDisplayFormat { get; set; }
45+
46+
/// <summary>
47+
/// Adjust to content column width if panel is vertical or row height if panel is horizontal
48+
/// </summary>
49+
public bool AdjustToContent { get; set; }
50+
51+
/// <summary>
52+
/// Order in which the column appears in Excel
53+
/// </summary>
54+
public int Order { get; set; }
5755
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
using System;
1+
namespace ExcelReportGenerator.Attributes;
22

3-
namespace ExcelReportGenerator.Attributes
3+
/// <summary>
4+
/// Marks panel property which can be populated from excel
5+
/// </summary>
6+
[AttributeUsage(AttributeTargets.Property)]
7+
internal class ExternalPropertyAttribute : Attribute
48
{
5-
// Marks panel property which can be populated from excel
6-
[AttributeUsage(AttributeTargets.Property)]
7-
internal class ExternalPropertyAttribute : Attribute
8-
{
9-
public Type Converter { get; set; }
10-
}
9+
public Type Converter { get; set; }
1110
}
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
using System;
1+
namespace ExcelReportGenerator.Attributes;
22

3-
namespace ExcelReportGenerator.Attributes
3+
/// <summary>
4+
/// An attribute that allows you to mark property as no excel column
5+
/// </summary>
6+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
7+
public class NoExcelColumnAttribute : Attribute
48
{
5-
/// <summary>
6-
/// An attribute that allows you to mark property as no excel column
7-
/// </summary>
8-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
9-
public class NoExcelColumnAttribute : Attribute
10-
{
11-
}
129
}
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
using System;
1+
namespace ExcelReportGenerator.Attributes;
22

3-
namespace ExcelReportGenerator.Attributes
3+
/// <summary>
4+
/// An attribute that allows you to replace null-values to more readable
5+
/// </summary>
6+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
7+
public class NullValueAttribute : Attribute
48
{
5-
/// <summary>
6-
/// An attribute that allows you to replace null-values to more readable
7-
/// </summary>
8-
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
9-
public class NullValueAttribute : Attribute
9+
public NullValueAttribute(object value)
1010
{
11-
public NullValueAttribute(object value)
12-
{
13-
Value = value;
14-
}
15-
16-
/// <summary>
17-
/// The value that will be write to Excel if original value is null
18-
/// </summary>
19-
public object Value { get; }
11+
Value = value;
2012
}
13+
14+
/// <summary>
15+
/// The value that will be write to Excel if original value is null
16+
/// </summary>
17+
public object Value { get; }
2118
}

ExcelReportGenerator/Constants.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
namespace ExcelReportGenerator
1+
namespace ExcelReportGenerator;
2+
3+
internal static class Constants
24
{
3-
internal static class Constants
4-
{
5-
public const string InvalidTemplateMessage = "Template \"{0}\" is invalid";
6-
}
5+
public const string InvalidTemplateMessage = "Template \"{0}\" is invalid";
76
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
namespace ExcelReportGenerator.Converters.ExternalPropertiesConverters
1+
namespace ExcelReportGenerator.Converters.ExternalPropertiesConverters;
2+
3+
internal interface IExternalPropertyConverter<out TOut> : IGenericConverter<string, TOut>
24
{
3-
internal interface IExternalPropertyConverter<out TOut> : IGenericConverter<string, TOut>
4-
{
5-
}
65
}
Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
11
using ExcelReportGenerator.Enums;
22
using ExcelReportGenerator.Helpers;
3-
using System;
43

5-
namespace ExcelReportGenerator.Converters.ExternalPropertiesConverters
4+
namespace ExcelReportGenerator.Converters.ExternalPropertiesConverters;
5+
6+
internal class PanelTypeConverter : IExternalPropertyConverter<PanelType>
67
{
7-
internal class PanelTypeConverter : IExternalPropertyConverter<PanelType>
8+
public PanelType Convert(string panelType)
89
{
9-
public PanelType Convert(string panelType)
10+
if (string.IsNullOrWhiteSpace(panelType))
1011
{
11-
if (string.IsNullOrWhiteSpace(panelType))
12-
{
13-
throw new ArgumentException("Type property cannot be null or empty");
14-
}
15-
16-
try
17-
{
18-
return EnumHelper.Parse<PanelType>(panelType.Trim());
19-
}
20-
catch (ArgumentException e)
21-
{
22-
throw new ArgumentException($"Value \"{panelType}\" is invalid for Type property", e);
23-
}
12+
throw new ArgumentException("Type property cannot be null or empty");
2413
}
2514

26-
object IConverter.Convert(object input)
15+
try
16+
{
17+
return EnumHelper.Parse<PanelType>(panelType.Trim());
18+
}
19+
catch (ArgumentException e)
2720
{
28-
return Convert((string)input);
21+
throw new ArgumentException($"Value \"{panelType}\" is invalid for Type property", e);
2922
}
3023
}
24+
25+
object IConverter.Convert(object input)
26+
{
27+
return Convert((string)input);
28+
}
3129
}
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
using System;
1+
namespace ExcelReportGenerator.Converters.ExternalPropertiesConverters;
22

3-
namespace ExcelReportGenerator.Converters.ExternalPropertiesConverters
3+
internal class RenderPriorityConverter : IExternalPropertyConverter<int>
44
{
5-
internal class RenderPriorityConverter : IExternalPropertyConverter<int>
5+
public int Convert(string input)
66
{
7-
public int Convert(string input)
7+
if (string.IsNullOrWhiteSpace(input))
88
{
9-
if (string.IsNullOrWhiteSpace(input))
10-
{
11-
throw new ArgumentException("RenderPriority property cannot be null or empty");
12-
}
13-
14-
if (int.TryParse(input, out int renderPriority))
15-
{
16-
return renderPriority;
17-
}
18-
19-
throw new ArgumentException($"Cannot convert value \"{input}\" to int");
9+
throw new ArgumentException("RenderPriority property cannot be null or empty");
2010
}
2111

22-
object IConverter.Convert(object input)
12+
if (int.TryParse(input, out int renderPriority))
2313
{
24-
return Convert((string)input);
14+
return renderPriority;
2515
}
16+
17+
throw new ArgumentException($"Cannot convert value \"{input}\" to int");
18+
}
19+
20+
object IConverter.Convert(object input)
21+
{
22+
return Convert((string)input);
2623
}
2724
}

0 commit comments

Comments
 (0)