Static Domain class

Date: 2019-01-18

Domain driven development with hidden depency ‘injection’ / control via a single static class

class Domain {
    private static portResolver: IPortResolver;
    public static setPortResolver(portResolver : IPortResolver) { Domain.portResolver = portResolver; }
    static get RequestUserSession() : IRequestUserSession { return Domain.portResolver.resolve<IRequestUserSession>("IRequestUserSession"); }
}
const portResolver = new PortResolver();
portResolver.registerInstance<IRequestUserSession>("IRequestUserSession", () => new UserSessionService());
Domain.setPortResolver(portResolver);
Domain.RequestUserSession.requestUserSession(null, null, null);
18340cookie-checkStatic Domain class