Webサービスアクセス用の接続構成情報を保持するためのインターフェイスがあります。
public interface IServiceConnectionConfiguration
{
string Username { get; }
string Password { get; }
string ChannelEndpointUrl { get; }
string MediaEndpointUrl { get; }
string PlayerlEndpointUrl { get; }
string PlaylistEndpointUrl { get; }
}
要求されたサービスのタイプに固有のサービスインスタンスを返すファクトリクラスがあります。
public static class ServiceClientFactory
{
public static void Configure(IServiceConnectionConfiguration config)
{
_config = config;
}
public static T GetService<T>() where T : class, IServiceClient
{
}
}
工場はとして呼ばれます
Channel channelService = factory.GetService<Channel>();
私が理解しようとしているのは、初期化中に渡された構成オブジェクトに基づいて、渡された型自体のエンドポイントURLをファクトリコードが解決するための洗練された方法です。例えば。渡されるtypeパラメーターがchannelの場合、ChannelServiceの構築中にChannelEndpointUrlを取得する必要があります。
configクラスの属性を使用して、エンドポイントURLをそれらが対応するサービスタイプで装飾することを考えましたが、それは悪い設計のようです。
何か案は。