Participants

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ada1d77d-f684-4447-8054-34dec5d51219/Untitled.png

var factory = new ApiFactory();

var endPoint1 = factory.GetEndPoint("EndPoint1");
var client1 = endPoint1.GetClient("Api/Test1");
var endPoint2 = factory.GetEndPoint("EndPoint2");
var client2 = endPoint1.GetClient("Api/Test2");

public class ApiFactory
{
	private Dictionary<string, IApiEndPoint> _EndPoints = new Dictionary<string, IApiEndPoint>();

	public IApiEndPoint GetEndPoint(string name)
	{
		IApiEndPoint endPoint = null;
		if (_EndPoints.ContainsKey(name))
			endPoint = _EndPoints[name];
		else
		{
			switch (name)
			{
				case "EndPoint1": endPoint = new EndPoint1(); break;
				case "EndPoint2": endPoint = new EndPoint2(); break;
			}
			_EndPoints.Add(name, endPoint);
		}
		return endPoint;
	}
}

public interface IApiEndPoint
{
	string Name { get; set; }
	string Url { get; set; }
	HttpClient GetClient(string route);
}

public class EndPoint1 : IApiEndPoint
{
	public string Name { get; set; } = "Name1";
	public string Url { get; set; } "www.Test1.com";

	public HttpClient GetClient(string route) => throw new NotImplementedException();
}

public class EndPoint2 : IApiEndPoint
{
	public string Name { get; set; } = "Name2";
	public string Url { get; set; } = "www.Test2.com";

	public HttpClient GetClient(string route) => throw new NotImplementedException();
}

Rules of Thumb