protected DashboardContext([NotNull] IDashboardOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } Options = options; }
public OwinDashboardContext([NotNull] IDashboardOptions options, [NotNull] IDictionary <string, object> environment) : base(options) { if (environment == null) { throw new ArgumentNullException(nameof(environment)); } Environment = environment; Request = new OwinDashboardRequest(environment); Response = new OwinDashboardResponse(environment); }
private static MidFunc UseDashboard([NotNull] IDashboardOptions options, [NotNull] RouteCollection routes) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (routes == null) { throw new ArgumentNullException(nameof(routes)); } Func <IDictionary <string, object>, Task> OuterFunc(Func <IDictionary <string, object>, Task> next) { Task InnerFunc(IDictionary <string, object> env) { var owinContext = new OwinContext(env); var context = new OwinDashboardContext(options, env); if (options.Authorization.Any(filter => !filter.Authorize(context))) { return(Unauthorized(owinContext)); } var findResult = routes.FindDispatcher(owinContext.Request.Path.Value); if (findResult == null) { return(next(env)); } context.UriMatch = findResult.Item2; return(findResult.Item1.Dispatch(context)); } return(InnerFunc); } return (OuterFunc); }
public static IAppBuilder UseDashboard(this IAppBuilder app, string pathMatch, IDashboardOptions options, IRouteSource routeSource) { if (app == null) { throw new ArgumentNullException(nameof(app)); } if (pathMatch == null) { throw new ArgumentNullException(nameof(pathMatch)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (routeSource == null) { throw new ArgumentException(nameof(routeSource)); } SignatureConversions.AddConversions(app); app.Map(pathMatch, subApp => { var routes = routeSource.GetRoutes(); void TempQualifier(Func <IDictionary <string, object>, MidFunc> middleware) => subApp.Use(middleware(subApp.Properties)); if (routes == null) { throw new ArgumentNullException(nameof(routes)); } TempQualifier(_ => UseDashboard(options, routes)); }); return(app); }