Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\1_task\\ExchangeRateUpdater\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{F718280A-7459-4E33-B42A-E19CB8ACE541}|ExchangeRateUpdater\\ExchangeRateUpdater.csproj|c:\\1_task\\exchangerateupdater\\exchangerateupdater\\exchangerateprovider.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F718280A-7459-4E33-B42A-E19CB8ACE541}|ExchangeRateUpdater\\ExchangeRateUpdater.csproj|solutionrelative:exchangerateupdater\\exchangerateprovider.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{4A3E62F0-B85E-4261-BBFD-354692E70DD6}|Demo\\Demo.csproj|c:\\1_task\\exchangerateupdater\\demo\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4A3E62F0-B85E-4261-BBFD-354692E70DD6}|Demo\\Demo.csproj|solutionrelative:demo\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "ExchangeRateProvider.cs",
"DocumentMoniker": "C:\\1_task\\ExchangeRateUpdater\\ExchangeRateUpdater\\ExchangeRateProvider.cs",
"RelativeDocumentMoniker": "ExchangeRateUpdater\\ExchangeRateProvider.cs",
"ToolTip": "C:\\1_task\\ExchangeRateUpdater\\ExchangeRateUpdater\\ExchangeRateProvider.cs",
"RelativeToolTip": "ExchangeRateUpdater\\ExchangeRateProvider.cs",
"ViewState": "AgIAALcAAAAAAAAAAAAIwNUAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-12-29T16:03:14.636Z",
"IsPinned": true,
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Program.cs",
"DocumentMoniker": "C:\\1_task\\ExchangeRateUpdater\\Demo\\Program.cs",
"RelativeDocumentMoniker": "Demo\\Program.cs",
"ToolTip": "C:\\1_task\\ExchangeRateUpdater\\Demo\\Program.cs",
"RelativeToolTip": "Demo\\Program.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAADsAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-12-29T16:05:37.307Z",
"EditorCaption": ""
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\1_task\\ExchangeRateUpdater\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{F718280A-7459-4E33-B42A-E19CB8ACE541}|ExchangeRateUpdater\\ExchangeRateUpdater.csproj|c:\\1_task\\exchangerateupdater\\exchangerateupdater\\exchangerateprovider.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{F718280A-7459-4E33-B42A-E19CB8ACE541}|ExchangeRateUpdater\\ExchangeRateUpdater.csproj|solutionrelative:exchangerateupdater\\exchangerateprovider.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{4A3E62F0-B85E-4261-BBFD-354692E70DD6}|Demo\\Demo.csproj|c:\\1_task\\exchangerateupdater\\demo\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{4A3E62F0-B85E-4261-BBFD-354692E70DD6}|Demo\\Demo.csproj|solutionrelative:demo\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "ExchangeRateProvider.cs",
"DocumentMoniker": "C:\\1_task\\ExchangeRateUpdater\\ExchangeRateUpdater\\ExchangeRateProvider.cs",
"RelativeDocumentMoniker": "ExchangeRateUpdater\\ExchangeRateProvider.cs",
"ToolTip": "C:\\1_task\\ExchangeRateUpdater\\ExchangeRateUpdater\\ExchangeRateProvider.cs",
"RelativeToolTip": "ExchangeRateUpdater\\ExchangeRateProvider.cs",
"ViewState": "AgIAALcAAAAAAAAAAAAIwNUAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-12-29T16:03:14.636Z",
"IsPinned": true,
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "Program.cs",
"DocumentMoniker": "C:\\1_task\\ExchangeRateUpdater\\Demo\\Program.cs",
"RelativeDocumentMoniker": "Demo\\Program.cs",
"ToolTip": "C:\\1_task\\ExchangeRateUpdater\\Demo\\Program.cs",
"RelativeToolTip": "Demo\\Program.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAADsAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2025-12-29T16:05:37.307Z",
"EditorCaption": ""
}
]
}
]
}
]
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions ExchangeRateUpdater/Demo/Demo.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ExchangeRateUpdater\ExchangeRateUpdater.csproj" />
</ItemGroup>

</Project>
74 changes: 74 additions & 0 deletions ExchangeRateUpdater/Demo/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using ExchangeRateUpdater;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

internal static class Program
{
private static async Task<int> Main(string[] args)
{
using var cts = new CancellationTokenSource();
Console.CancelKeyPress += (_, e) =>
{
e.Cancel = true;
cts.Cancel();
};

var services = new ServiceCollection();

services.AddLogging(b =>
{
b.AddSimpleConsole(o =>
{
o.SingleLine = true;
o.TimestampFormat = "HH:mm:ss ";
});
b.SetMinimumLevel(LogLevel.Information);
});

services.AddHttpClient<ExchangeRateProvider>(c =>
{
c.Timeout = TimeSpan.FromSeconds(10);
});

using var provider = services.BuildServiceProvider();

var rateProvider = provider.GetRequiredService<ExchangeRateProvider>();

var currencies = new[]
{
new Currency("CZK"),
new Currency("EUR"),
new Currency("USD"),
new Currency("GBP"),
};

try
{
var rates = await rateProvider
.GetCzkBasedRatesAsync(currencies, cts.Token)
.ConfigureAwait(false);

foreach (var r in rates.OrderBy(r => r.TargetCurrency.Code))
{
Console.WriteLine(r);
}

return 0;
}
catch (OperationCanceledException)
{
Console.WriteLine("Cancelled.");
return 1;
}
catch (Exception ex)
{
Console.Error.WriteLine($"Error: {ex.Message}");
return 2;
}
}
}
31 changes: 31 additions & 0 deletions ExchangeRateUpdater/ExchangeRateUpdater.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36705.20 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExchangeRateUpdater", "ExchangeRateUpdater\ExchangeRateUpdater.csproj", "{F718280A-7459-4E33-B42A-E19CB8ACE541}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{4A3E62F0-B85E-4261-BBFD-354692E70DD6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F718280A-7459-4E33-B42A-E19CB8ACE541}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F718280A-7459-4E33-B42A-E19CB8ACE541}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F718280A-7459-4E33-B42A-E19CB8ACE541}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F718280A-7459-4E33-B42A-E19CB8ACE541}.Release|Any CPU.Build.0 = Release|Any CPU
{4A3E62F0-B85E-4261-BBFD-354692E70DD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A3E62F0-B85E-4261-BBFD-354692E70DD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A3E62F0-B85E-4261-BBFD-354692E70DD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A3E62F0-B85E-4261-BBFD-354692E70DD6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7BB53F43-2197-4A44-BBD1-967E5B8C1B6F}
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions ExchangeRateUpdater/ExchangeRateUpdater/Currency.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace ExchangeRateUpdater
{
public class Currency
{
public Currency(string code)
{
Code = code;
}

/// <summary>
/// Three-letter ISO 4217 code of the currency.
/// </summary>
public string Code { get; }

public override string ToString()
{
return Code;
}
}
}
23 changes: 23 additions & 0 deletions ExchangeRateUpdater/ExchangeRateUpdater/ExchangeRate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace ExchangeRateUpdater
{
public class ExchangeRate
{
public ExchangeRate(Currency sourceCurrency, Currency targetCurrency, decimal value)
{
SourceCurrency = sourceCurrency;
TargetCurrency = targetCurrency;
Value = value;
}

public Currency SourceCurrency { get; }

public Currency TargetCurrency { get; }

public decimal Value { get; }

public override string ToString()
{
return $"{SourceCurrency}/{TargetCurrency}={Value}";
}
}
}
Loading