41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System;
|
|
|
|
namespace SmallInjectorDemo
|
|
{
|
|
/// <summary>
|
|
/// A very useful class.
|
|
/// </summary>
|
|
public class UsefulClass
|
|
{
|
|
private readonly IServiceOne _service1;
|
|
private readonly IServiceTwo _service2;
|
|
private readonly int _rand;
|
|
|
|
/// <summary>
|
|
/// Creates a new instance of <see cref="UsefulClass"/>.
|
|
/// </summary>
|
|
/// <param name="service1">injected service one.</param>
|
|
/// <param name="service2">injected service two.</param>
|
|
public UsefulClass(IServiceOne service1, IServiceTwo service2)
|
|
{
|
|
_service1 = service1;
|
|
_service2 = service2;
|
|
_rand = RandomHelper.NewRandomInteger(10, 99);
|
|
Console.WriteLine(nameof(UsefulClass) + ".ctor\tId: " + _rand);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Test the injected services.
|
|
/// </summary>
|
|
public void TestTheServices()
|
|
{
|
|
Console.WriteLine(ToString());
|
|
Console.WriteLine(_service1.ToString());
|
|
Console.WriteLine(_service2.ToString());
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString() => nameof(UsefulClass) + ".ToString()\tId: " + _rand;
|
|
|
|
}
|
|
} |