/// <summary> /// Use the WebStreams middleware for all loaded stream controller types. /// </summary> /// <param name="app"> /// The app. /// </param> /// <param name="settings"> /// The settings, or <see langword="null"/> to use <see cref="WebStreamsSettings.Default"/>. /// </param> public static void UseWebStreams(this IAppBuilder app, WebStreamsSettings settings = null) { settings = settings ?? WebStreamsSettings.Default; var assemblies = AppDomain.CurrentDomain.GetAssemblies(); var types = assemblies.SelectMany(_ => _.GetTypes()); var controllers = types.Where( _ => _.GetCustomAttribute <RoutePrefixAttribute>() != null || _.GetCustomAttribute <StreamControllerAttribute>() != null); var routes = controllers.SelectMany(controller => ControllerBuilder.GetRoutes(controller, settings)); app.UseWebStreams(settings, routes.ToDictionary(_ => _.Key, _ => _.Value)); }
/// <summary> /// Use the WebStreams middleware for the provided controller type. /// </summary> /// <param name="app"> /// The app. /// </param> /// <param name="controllerType"> /// The stream controller type. /// </param> /// <param name="settings"> /// The settings, or <see langword="null"/> to use <see cref="WebStreamsSettings.Default"/>. /// </param> private static void UseWebStreams(this IAppBuilder app, Type controllerType, WebStreamsSettings settings = null) { settings = settings ?? WebStreamsSettings.Default; app.UseWebStreams(settings, ControllerBuilder.GetRoutes(controllerType, settings)); }