-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProductParametersExtractor.cs
More file actions
42 lines (34 loc) · 1.41 KB
/
Copy pathProductParametersExtractor.cs
File metadata and controls
42 lines (34 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using DancingGoat.Models;
namespace DancingGoat.Commerce
{
/// <summary>
/// Extractor of product-specific parameters.
/// </summary>
public sealed class ProductParametersExtractor
{
private readonly IEnumerable<IProductTypeParametersExtractor> parametersExtractors;
public ProductParametersExtractor(IEnumerable<IProductTypeParametersExtractor> parametersExtractors)
{
this.parametersExtractors = parametersExtractors;
}
/// <summary>
/// Extract product parameters and update the dictionary of parameters.
/// </summary>
/// <param name="product">Product to process.</param>
/// <param name="languageName">Language name used.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>Dictionary containing product parameters.</returns>
public async Task<IDictionary<string, string>> ExtractParameters(IProductFields product, string languageName, CancellationToken cancellationToken)
{
var parameters = new Dictionary<string, string>();
foreach (var item in parametersExtractors)
{
await item.ExtractParameter(parameters, product, languageName, cancellationToken);
}
return parameters;
}
}
}