/// <summary>
 /// Adds the HTTP end point.
 /// </summary>
 /// <param name="theater">The theater.</param>
 /// <param name="endpointAddress">The endpoint address.</param>
 /// <param name="appBuilder">The application builder.</param>
 public static void AddHttpEndPoint(this Theater theater, Uri endpointAddress, IAppBuilder appBuilder)
 {
     var histrioSettings = new TheaterSettings
     {
         Theater = theater,
         EndpointAddress = endpointAddress
     };
     theater.AddEndpoint(endpointAddress);
     appBuilder.UseTheater(histrioSettings);
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="TheaterMiddleware" /> class.
        /// </summary>
        /// <param name="theaterSettings">The histrio settings used to configure the middelware</param>
        internal TheaterMiddleware(TheaterSettings theaterSettings)
        {
            var controllerActivator = new TheaterControllerActivator(theaterSettings.Theater);

            MidFunc = next =>
            {
                var app = new AppBuilder();
                app.UseWebApi(GetWebApiConfiguration(controllerActivator));
                app.Run(ctx => next(ctx.Environment));
                return app.Build();
            };
        }
 /// <summary>
 ///     Uses the histrio.
 /// </summary>
 /// <param name="appBuilder">The application builder.</param>
 /// <param name="theaterSettings">The histrio settings.</param>
 /// <returns></returns>
 public static IAppBuilder UseTheater(this IAppBuilder appBuilder, TheaterSettings theaterSettings)
 {
     appBuilder.Use(new TheaterMiddleware(theaterSettings).MidFunc);
     theaterSettings.Theater.AddEndpoint(theaterSettings.EndpointAddress);
     return appBuilder;
 }