Please consider the following immutable type:
public class/struct AServiceOptions {
public AServiceOptions (Uri baseAddress, int workersCount, TimeSpan maxIdleTime) {
BaseAddress = baseAddress;
WorkersCount = workersCount;
MaxIdleTime = maxIdleTime;
}
public Uri BaseAddress { get; }
public int WorkersCount { get; }
public TimeSpan MaxIdleTime { get; }
}
Used in the following manner:
public class AService {
public AService (AServiceOptions options) {
Options = options;
Initialize();
}
AServiceOptions Options { get; }
private void Initialize () {
InitHttpClient(Options.BaseAddress);
InitWorkers(Options.WorkersCount);
InitTimer(Options.MaxIdleTime);
}
// Service implementation details
}
Is the AServiceOptions
type a good candidate for a Struct? Why / Why not?