-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDoStuffService.cs
35 lines (29 loc) · 946 Bytes
/
DoStuffService.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
// DoStuffWithUnicore - Examples of Umbraco code for .net core
//
// File: DoStuffService Class
//
// Note: Demonstrates a Service class, that uses:
// - Dependency Injection
// - Logging
// - Configuration
using DoStuff.Core.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace DoStuff.Core.Services
{
public class DoStuffService
{
private readonly ILogger<DoStuffService> _logger;
private readonly DoStuffOptions _options;
public DoStuffService(ILogger<DoStuffService> logger, IOptions<DoStuffOptions> options)
{
_logger = logger;
_options = options.Value;
}
public bool IsHigherThanMagicNumber(int number)
{
_logger.LogDebug("Checking if {number} is higher than {magic}", number, _options.MagicNumber);
return number > _options.MagicNumber;
}
}
}