namespace ServicesLab.Services; // Components depend on this interface, not on a class. public interface IGreeting { string Greet(string name); } public sealed class FriendlyGreeting : IGreeting { public string Greet(string name) => $"Hi {name}, nice to see you!"; } public sealed class FormalGreeting : IGreeting { public string Greet(string name) => $"Good day, {name}."; } // Each new instance takes the next number for its own class, so a page can show which object it received. public abstract class Tracked { private static readonly Dictionary created = []; protected Tracked() { Number = created.GetValueOrDefault(GetType()) + 1; created[GetType()] = Number; } public int Number { get; } public int Clicks { get; set; } } public sealed class SingletonTag : Tracked { } public sealed class ScopedTag : Tracked { } public sealed class TransientTag : Tracked { }