-
Notifications
You must be signed in to change notification settings - Fork 16
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
a02e31f
commit 6e3ef17
Showing
19 changed files
with
367 additions
and
146 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/Environment/Filtering/ExcludeCoverageFilters/=AzureVmCosterTests_003B_002A_003B_002A_003B_002A/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/Environment/Filtering/ExcludeCoverageFilters/=_005Fbuild_003B_002A_003B_002A_003B_002A/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coster/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace AzureVmCoster.Models; | ||
|
||
internal class PriceDirectory | ||
{ | ||
public string Directory { get; } | ||
|
||
public PriceDirectory(string priceDirectory) | ||
{ | ||
Directory = priceDirectory; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace AzureVmCoster.Services; | ||
|
||
internal class PriceService | ||
{ | ||
private readonly Pricer _pricer; | ||
private readonly VmPricingParser _vmPricingParser; | ||
private readonly PricedVmWriter _pricedVmWriter; | ||
|
||
public PriceService(Pricer pricer, VmPricingParser vmPricingParser, PricedVmWriter pricedVmWriter) | ||
{ | ||
_pricer = pricer; | ||
_vmPricingParser = vmPricingParser; | ||
_pricedVmWriter = pricedVmWriter; | ||
} | ||
|
||
public async Task PriceAsync(string? inputFilePath, string? configurationFilePath, CultureInfo culture) | ||
{ | ||
var inputFile = InputFileValidator.Validate(inputFilePath); | ||
var inputVms = InputVmParser.Parse(inputFile, culture); | ||
|
||
var vmPrices = await _vmPricingParser.ParseAsync(); | ||
|
||
var configuration = await CosterConfiguration.FromPathAsync(configurationFilePath); | ||
|
||
var pricedVms = _pricer.Price(inputVms, vmPrices, configuration); | ||
_pricedVmWriter.Write(inputFile.Name, pricedVms, culture); | ||
} | ||
} |
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,20 +1,32 @@ | ||
using AzureVmCoster.Models.Csv; | ||
using CsvHelper; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace AzureVmCoster.Services; | ||
|
||
internal static class PricedVmWriter | ||
internal class PricedVmWriter | ||
{ | ||
public static void Write(string filename, List<PricedVm> pricedVms, CultureInfo culture) | ||
private readonly ILogger<PricedVmWriter> _logger; | ||
|
||
public PricedVmWriter(ILogger<PricedVmWriter> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void Write(string filename, IList<PricedVm> pricedVms, CultureInfo culture) | ||
{ | ||
var csvConfiguration = new CsvConfiguration(culture) | ||
{ | ||
Delimiter = "," | ||
}; | ||
|
||
using var writer = new StreamWriter($@"Out\{filename}"); | ||
var fileInfo = new FileInfo($@"Out\{filename}"); | ||
|
||
using var writer = new StreamWriter(fileInfo.FullName); | ||
using var csv = new CsvWriter(writer, csvConfiguration); | ||
csv.Context.RegisterClassMap<PricedVmMap>(); | ||
csv.WriteRecords(pricedVms); | ||
|
||
_logger.LogInformation("Wrote priced VM to '{OutputFile}'", fileInfo); | ||
} | ||
} |
Oops, something went wrong.