Given my code below, is there a way that the first WebTestingApp constructor can call the second before returning the new instance? I want to set some readonly fields in the constructor and, short of copy/pasting, I can't see how I can.
I feel that the answer will have something to do with constructor chaining, but I can't figure out how to do it, since the second WebTestingApp constructor implicitly calls base() (which is important as external users of the class shouldn't have to provide IRemoteFile and IWebServiceGateway instances).
internal WebTestingApp(Result result, BrowserApp browserApp, IRemoteFile remoteFile, IWebServiceGateway webServiceGateway) : base(remoteFile, webServiceGateway)
{
// TODO: Need to invoke WebTestingApp(Result result, BrowserApp browserApp)
}
public WebTestingApp(Result result, BrowserApp browserApp)
{
// Set readonly vars here
}
Here's the base class TestingApp's constructors:
protected TestingApp() : this(S3File.Instance, WebServiceGateway.Instance) { }
internal TestingApp(IRemoteFile remoteFile, IWebServiceGateway webServiceGateway)
{
this.remoteFile = remoteFile;
this.webServiceGateway = webServiceGateway;
}
WebTestingApp is derived from TestingApp. S3File and WebServiceGateway are singletons.