-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0347ca6
commit e321766
Showing
22 changed files
with
313 additions
and
307 deletions.
There are no files selected for viewing
16 changes: 8 additions & 8 deletions
16
src/SheetToObjects.ConsoleApp/AppSettings.cs → src/SheetToObjects.Examples/AppSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
namespace SheetToObjects.ConsoleApp | ||
{ | ||
public class AppSettings | ||
{ | ||
public string ApiKey { get; set; } | ||
public string SheetId { get; set; } | ||
} | ||
} | ||
namespace SheetToObjects.Examples | ||
{ | ||
public class AppSettings | ||
{ | ||
public string ApiKey { get; set; } | ||
public string SheetId { get; set; } | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
....ConsoleApp/CsvAppWithValidationErrors.cs → ...ts.Examples/CsvAppWithValidationErrors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...nsoleApp/CsvAppWithoutValidationErrors.cs → ...Examples/CsvAppWithoutValidationErrors.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 40 additions & 40 deletions
80
src/SheetToObjects.ConsoleApp/ExcelApp.cs → src/SheetToObjects.Examples/ExcelApp.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
using System; | ||
using SheetToObjects.Adapters.MicrosoftExcel; | ||
using SheetToObjects.ConsoleApp.Models; | ||
using SheetToObjects.Core; | ||
using SheetToObjects.Lib; | ||
|
||
namespace SheetToObjects.ConsoleApp | ||
{ | ||
public class ExcelApp | ||
{ | ||
private readonly IProvideSheet _sheetProvider; | ||
private readonly IMapSheetToObjects _sheetMapper; | ||
|
||
public ExcelApp( | ||
IProvideSheet sheetProvider, | ||
IMapSheetToObjects sheetMapper) | ||
{ | ||
_sheetProvider = sheetProvider; | ||
_sheetMapper = sheetMapper; | ||
} | ||
|
||
public void Run() | ||
{ | ||
var result = Timer.TimeFunc(() => | ||
{ | ||
var excelRange = new ExcelRange(new ExcelCell("A", 1), new ExcelCell("U", 9995)); | ||
var sheet = _sheetProvider.GetFromPath(@"./Files/Sample - Superstore.xlsx", "orders", excelRange); | ||
return _sheetMapper.Map<Superstore>(sheet); | ||
}); | ||
|
||
foreach (var error in result.Item1.ValidationErrors) | ||
{ | ||
Console.WriteLine($"Column: {error.ColumnName} | Row: {error.RowIndex} | Message: {error.ErrorMessage}"); | ||
} | ||
Console.WriteLine($"Mapped {result.Item1.ParsedModels.Count} models in {result.Item2.ToString()} " + | ||
$"with {result.Item1.ValidationErrors.Count} validation errors"); | ||
Console.WriteLine("==============================================================="); | ||
} | ||
} | ||
using System; | ||
using SheetToObjects.Adapters.MicrosoftExcel; | ||
using SheetToObjects.Core; | ||
using SheetToObjects.Examples.Models; | ||
using SheetToObjects.Lib; | ||
|
||
namespace SheetToObjects.Examples | ||
{ | ||
public class ExcelApp | ||
{ | ||
private readonly IProvideSheet _sheetProvider; | ||
private readonly IMapSheetToObjects _sheetMapper; | ||
|
||
public ExcelApp( | ||
IProvideSheet sheetProvider, | ||
IMapSheetToObjects sheetMapper) | ||
{ | ||
_sheetProvider = sheetProvider; | ||
_sheetMapper = sheetMapper; | ||
} | ||
|
||
public void Run() | ||
{ | ||
var result = Timer.TimeFunc(() => | ||
{ | ||
var excelRange = new ExcelRange(new ExcelCell("A", 1), new ExcelCell("U", 9995)); | ||
var sheet = _sheetProvider.GetFromPath(@"./Files/Sample - Superstore.xlsx", "orders", excelRange); | ||
return _sheetMapper.Map<Superstore>(sheet); | ||
}); | ||
|
||
foreach (var error in result.Item1.ValidationErrors) | ||
{ | ||
Console.WriteLine($"Column: {error.ColumnName} | Row: {error.RowIndex} | Message: {error.ErrorMessage}"); | ||
} | ||
Console.WriteLine($"Mapped {result.Item1.ParsedModels.Count} models in {result.Item2.ToString()} " + | ||
$"with {result.Item1.ValidationErrors.Count} validation errors"); | ||
Console.WriteLine("==============================================================="); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
94 changes: 47 additions & 47 deletions
94
...etToObjects.ConsoleApp/GoogleSheetsApp.cs → ...heetToObjects.Examples/GoogleSheetsApp.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Options; | ||
using SheetToObjects.Adapters.GoogleSheets; | ||
using SheetToObjects.ConsoleApp.Models; | ||
using SheetToObjects.Core; | ||
using SheetToObjects.Lib; | ||
|
||
namespace SheetToObjects.ConsoleApp | ||
{ | ||
public class GoogleSheetsApp | ||
{ | ||
private readonly AppSettings _appSettings; | ||
private readonly IProvideSheet _sheetProvider; | ||
private readonly IMapSheetToObjects _sheetMapper; | ||
|
||
public GoogleSheetsApp( | ||
IOptions<AppSettings> appSettings, | ||
IProvideSheet sheetProvider, | ||
IMapSheetToObjects sheetMapper) | ||
{ | ||
_appSettings = appSettings.Value; | ||
_sheetProvider = sheetProvider; | ||
_sheetMapper = sheetMapper; | ||
} | ||
|
||
public async Task Run() | ||
{ | ||
var result = await Timer.TimeFuncAsync(async () => | ||
{ | ||
var sheet = await _sheetProvider.GetAsync( | ||
_appSettings.SheetId, | ||
"'Herstructurering Filters Data'!A1:H9", | ||
_appSettings.ApiKey); | ||
return _sheetMapper.Map<EpicTracking>(sheet); | ||
}); | ||
|
||
foreach (var error in result.Item1.ValidationErrors) | ||
{ | ||
Console.WriteLine($"Column: {error.ColumnName} | Row: {error.RowIndex} | Message: {error.ErrorMessage}"); | ||
} | ||
Console.WriteLine($"Mapped {result.Item1.ParsedModels.Count} models in {result.Item2.ToString()} " + | ||
$"with {result.Item1.ValidationErrors.Count} validation errors"); | ||
Console.WriteLine("==============================================================="); | ||
} | ||
} | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Options; | ||
using SheetToObjects.Adapters.GoogleSheets; | ||
using SheetToObjects.Core; | ||
using SheetToObjects.Examples.Models; | ||
using SheetToObjects.Lib; | ||
|
||
namespace SheetToObjects.Examples | ||
{ | ||
public class GoogleSheetsApp | ||
{ | ||
private readonly AppSettings _appSettings; | ||
private readonly IProvideSheet _sheetProvider; | ||
private readonly IMapSheetToObjects _sheetMapper; | ||
|
||
public GoogleSheetsApp( | ||
IOptions<AppSettings> appSettings, | ||
IProvideSheet sheetProvider, | ||
IMapSheetToObjects sheetMapper) | ||
{ | ||
_appSettings = appSettings.Value; | ||
_sheetProvider = sheetProvider; | ||
_sheetMapper = sheetMapper; | ||
} | ||
|
||
public async Task Run() | ||
{ | ||
var result = await Timer.TimeFuncAsync(async () => | ||
{ | ||
var sheet = await _sheetProvider.GetAsync( | ||
_appSettings.SheetId, | ||
"'Herstructurering Filters Data'!A1:H9", | ||
_appSettings.ApiKey); | ||
return _sheetMapper.Map<EpicTracking>(sheet); | ||
}); | ||
|
||
foreach (var error in result.Item1.ValidationErrors) | ||
{ | ||
Console.WriteLine($"Column: {error.ColumnName} | Row: {error.RowIndex} | Message: {error.ErrorMessage}"); | ||
} | ||
Console.WriteLine($"Mapped {result.Item1.ParsedModels.Count} models in {result.Item2.ToString()} " + | ||
$"with {result.Item1.ValidationErrors.Count} validation errors"); | ||
Console.WriteLine("==============================================================="); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...Objects.ConsoleApp/Models/EpicTracking.cs → ...ToObjects.Examples/Models/EpicTracking.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ToObjects.ConsoleApp/Models/Superstore.cs → ...etToObjects.Examples/Models/Superstore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 58 additions & 58 deletions
116
src/SheetToObjects.ConsoleApp/Program.cs → src/SheetToObjects.Examples/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace SheetToObjects.ConsoleApp | ||
{ | ||
internal class Program | ||
{ | ||
private static ServiceProvider _services; | ||
|
||
private static void Main() | ||
{ | ||
_services = new ServiceCollection().ConfigureServices().BuildServiceProvider(); | ||
|
||
RunGoogleSheetsExampleAsync().GetAwaiter().GetResult(); | ||
RunProtectedGoogleSheetsExampleAsync().GetAwaiter().GetResult(); | ||
RunExcelExample(); | ||
RunCsvWithValidationErrorsExample(); | ||
RunCsvWithoutValidationErrorsExample(); | ||
|
||
Console.ReadLine(); | ||
} | ||
|
||
private static async Task RunGoogleSheetsExampleAsync() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running Google Sheets example"); | ||
|
||
await _services.GetService<GoogleSheetsApp>().Run(); | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace SheetToObjects.Examples | ||
{ | ||
internal class Program | ||
{ | ||
private static ServiceProvider _services; | ||
|
||
private static void Main() | ||
{ | ||
_services = new ServiceCollection().ConfigureServices().BuildServiceProvider(); | ||
|
||
RunGoogleSheetsExampleAsync().GetAwaiter().GetResult(); | ||
RunProtectedGoogleSheetsExampleAsync().GetAwaiter().GetResult(); | ||
RunExcelExample(); | ||
RunCsvWithValidationErrorsExample(); | ||
RunCsvWithoutValidationErrorsExample(); | ||
|
||
Console.ReadLine(); | ||
} | ||
|
||
private static async Task RunGoogleSheetsExampleAsync() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running Google Sheets example"); | ||
|
||
await _services.GetService<GoogleSheetsApp>().Run(); | ||
} | ||
|
||
private static async Task RunProtectedGoogleSheetsExampleAsync() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running Protected Google Sheets example"); | ||
|
||
await _services.GetService<ProtectedGoogleSheetsApp>().Run(); | ||
} | ||
|
||
private static void RunExcelExample() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running Excel example"); | ||
|
||
_services.GetService<ExcelApp>().Run(); | ||
} | ||
|
||
private static void RunCsvWithValidationErrorsExample() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running CSV with validation errors example"); | ||
|
||
_services.GetService<CsvAppWithValidationErrors>().Run(); | ||
} | ||
|
||
private static void RunCsvWithoutValidationErrorsExample() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running CSV without validation errors example"); | ||
|
||
_services.GetService<CsvAppWithoutValidationErrors>().Run(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static void RunExcelExample() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running Excel example"); | ||
|
||
_services.GetService<ExcelApp>().Run(); | ||
} | ||
|
||
private static void RunCsvWithValidationErrorsExample() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running CSV with validation errors example"); | ||
|
||
_services.GetService<CsvAppWithValidationErrors>().Run(); | ||
} | ||
|
||
private static void RunCsvWithoutValidationErrorsExample() | ||
{ | ||
Console.WriteLine("==============================================================="); | ||
Console.WriteLine("Running CSV without validation errors example"); | ||
|
||
_services.GetService<CsvAppWithoutValidationErrors>().Run(); | ||
} | ||
} | ||
} |
Oops, something went wrong.