/
DemosBase.cs
41 lines (35 loc) · 1015 Bytes
/
DemosBase.cs
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using EntityFramework.Demo.Model;
using Microsoft.Extensions.Logging;
namespace EntityFramework.Demo.Demos
{
public abstract class DemosBase
{
protected DemoDbContext Context { get; }
protected ILogger Logger { get; }
protected DemosBase(DemoDbContext ctx, ILogger logger)
{
Context = ctx ?? throw new ArgumentNullException(nameof(ctx));
Logger = logger ?? throw new ArgumentNullException(nameof(logger));
}
protected void Print(string caption, IEnumerable<ProductGroup> groups)
{
Logger.LogInformation("== {caption} ==", caption);
foreach (var group in groups)
{
Logger.LogInformation("ProductGroup: {@group}, Products: {products} ", group, group.Products);
}
}
protected void Print(string caption, IEnumerable items)
{
Logger.LogInformation("== {caption} ==", caption);
foreach (var item in items)
{
Logger.LogInformation("{@item}", item);
}
}
}
}