.NET Fiddle

CSharp · Console

/Program.cs

using System;

public class Program
{
	public static void Main()
	{
		var b = new ServiceResolver();
		var c = new Service1();
		b.Register(c);
	}
}

public interface ICapability
{
}

public interface IBaseService<out T>
	where T : ICapability
{
}

public abstract class BaseService<T> : IBaseService<T> where T : ICapability
{
    public override string ToString()
	{
		return $"I am {this.GetType().Name} and I have the capability of type {typeof(T).Name}";
	}
}

public class SomeCapability : ICapability
{
}

public partial class Service1 : BaseService<SomeCapability>
{
	public Service1()
	{
	}
}

public class ServiceResolver
{
	public void Register(IBaseService<ICapability> serviceToRegister)
	{
		Console.WriteLine(serviceToRegister);
	}
}
;