namespace IoC.Tests.UsageScenarios { using System.Diagnostics.CodeAnalysis; using Shouldly; using Xunit; [SuppressMessage("ReSharper", "UnusedVariable")] public class Tags { [Fact] public void Run() { // $visible=true // $tag=1 Basics // $priority=01 // $description=Tags // $header=Tags are useful while binding to several implementations of the same abstract types. // { using var container = Container .Create() .Bind().To() // Bind using several tags .Bind().Tag(10).Tag().Tag("abc").To() .Container; // Resolve instances using tags var instance1 = container.Resolve("abc".AsTag()); var instance2 = container.Resolve(10.AsTag()); // Resolve the instance using the empty tag var instance3 = container.Resolve(); // } // Check instances instance1.ShouldBeOfType(); instance2.ShouldBeOfType(); instance3.ShouldBeOfType(); } } }