private static AuditoriumSeatingAdapter InstantiateRightSideAdapter(string showId, string theaterJson, string theaterBookedSeatsJson) { var webClient = Stub.AWebClientWith(showId, theaterJson, theaterBookedSeatsJson); // But first its dependencies IProvideAuditoriumLayouts auditoriumLayoutProviderWebClient = new AuditoriumWebClient("http://fakehost:50950/", webClient); IProvideCurrentReservations seatsReservationsProviderWebClient = new SeatReservationsWebClient("http://fakehost:50951/", webClient); // Now the Adapter for the right-side port: IProvideUpToDateAuditoriumSeating var rightSideAdapter = new AuditoriumSeatingAdapter(auditoriumLayoutProviderWebClient, seatsReservationsProviderWebClient); return(rightSideAdapter); }
private static void ConfigureRightSidePortsAndAdapters(IServiceCollection services) { // The 3 steps initialization of the Hexagonal Architecture ------------------------------------------------------------------- // Step1: Instantiate the "I want to go out" (i.e. right-side) adapters in the ASP.NET IoC engine ------------------------------ // First, their dependencies var webClient = new WebClient(); services.AddSingleton <IWebClient>(webClient); // IProvideAuditoriumLayouts interface IProvideAuditoriumLayouts auditoriumSeatingRepository = new AuditoriumWebClient("http://localhost:50950/", webClient); services.AddSingleton <IProvideAuditoriumLayouts>(auditoriumSeatingRepository); // IProvideCurrentReservations interface IProvideCurrentReservations seatReservationsProvider = new SeatReservationsWebClient("http://localhost:50951/", webClient); services.AddSingleton <IProvideCurrentReservations>(seatReservationsProvider); // Now, the right-side adapter for the IProvideUpToDateAuditoriumSeating right-side port) services.AddScoped <IProvideUpToDateAuditoriumSeating, AuditoriumSeatingAdapter>(); }