Esempio n. 1
0
        public static MidFunc UsePugTraceDashboard(
            DashboardOptions options,
            TraceStorage storage,
            RouteCollection routes)
        {
            if (options == null) throw new ArgumentNullException("options");
            if (routes == null) throw new ArgumentNullException("routes");

            return
                next =>
                env =>
                {
                    var context = new OwinContext(env);
                    var dispatcher = routes.FindDispatcher(context.Request.Path.Value);

                    if (dispatcher == null)
                    {
                        return next(env);
                    }

                    if (options.AuthorizationFilters.Any(filter => !filter.Authorize(context.Environment)))
                    {
                        context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                        return Task.FromResult(false);
                    }

                    var dispatcherContext = new RequestDispatcherContext(
                        options.AppPath,
                        storage,
                        context.Environment,
                        dispatcher.Item2);

                    return dispatcher.Item1.Dispatch(dispatcherContext);
                };
        }
Esempio n. 2
0
        public static BuildFunc UsePugTraceDashboard(
            this BuildFunc builder,
            DashboardOptions options,
            TraceStorage storage,
            RouteCollection routes)
        {
            if (builder == null) throw new ArgumentNullException("builder");
            if (options == null) throw new ArgumentNullException("options");
            if (routes == null) throw new ArgumentNullException("routes");

            builder(_ => UsePugTraceDashboard(options, storage, routes));

            return builder;
        }
        public RequestDispatcherContext(
            string appPath,
            TraceStorage storage,
            IDictionary<string, object> owinEnvironment,
            Match uriMatch)
        {
            if (appPath == null) throw new ArgumentNullException("appPath");
            if (storage == null) throw new ArgumentNullException("storage");
            if (owinEnvironment == null) throw new ArgumentNullException("owinEnvironment");
            if (uriMatch == null) throw new ArgumentNullException("uriMatch");

            AppPath = appPath;
            Storage = storage;
            OwinEnvironment = owinEnvironment;
            UriMatch = uriMatch;
        }
Esempio n. 4
0
        public void Save()
        {
            var path = GetFilePath();

            if (Application.isEditor && !Application.isPlaying)
            {
                var simvaconf = new SimpleJSON.JSONClass();
                simvaconf["study"]         = Study;
                simvaconf["host"]          = Host;
                simvaconf["protocol"]      = Protocol;
                simvaconf["port"]          = Port;
                simvaconf["sso"]           = SSO;
                simvaconf["client_id"]     = ClientId;
                simvaconf["url"]           = URL;
                simvaconf["trace_storage"] = TraceStorage.ToString();
                simvaconf["backup"]        = Backup.ToString();
                simvaconf["realtime"]      = Realtime.ToString();
                System.IO.File.WriteAllText(path, simvaconf.ToJSON(4));
            }
        }