Inheritance: IRouteHandler, IHttpHandler
Exemplo n.º 1
0
		/// <summary>
		/// Initializes the RavenProfiler for MVC.
		/// IMPORTANT! This method may only be called from the Application_Start method, otherwise
		/// it might lead to problems, since it modify the Routes table.
		/// </summary>
		public static void InitializeFor(IDocumentStore store, params string[] fieldsToFilter)
		{
			var existing = RouteTable.Routes
				.Select(x =>
				{
					var route = x as Route;
					if (route == null)
						return null;
					return route.RouteHandler;
				})
				.OfType<RavenProfilingHandler>()
				.FirstOrDefault();

			if (existing != null)
			{
				existing.AddStore(store);
				return;
			}
			store.Conventions.DisableProfiling = false;

			((DocumentStore)store).InitializeProfiling();
			
			ProfilingInformation.OnContextCreated += ProfilingInformationOnOnContextCreated;

			var ravenProfilingHandler = new RavenProfilingHandler(new HashSet<string>(fieldsToFilter ?? Enumerable.Empty<string>()));
			ravenProfilingHandler.AddStore(store);

			RouteTable.Routes.Insert(0, new Route("ravendb/profiling", new RouteValueDictionary(new { controller = "RavenProfilingHandler", action = "ProcessRequest" }), ravenProfilingHandler));
			GlobalFilters.Filters.Add(new RecordCurrentControllerContextFilter(), -100);
		}
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the RavenProfiler for MVC
        /// IMPORTANT! This method may only be called from the Application_Start method, otherwise
        /// it might lead to problems, since it modify the Routes table.
        /// </summary>
        public static void InitializeFor(IDocumentStore store, params string[] fieldsToFilter)
        {
            var existing = RouteTable.Routes.Select(x =>
            {
                var route = x as Route;
                if (route == null)
                {
                    return(null);
                }
                return(route.RouteHandler);
            })
                           .OfType <RavenProfilingHandler>()
                           .FirstOrDefault();

            if (existing != null)
            {
                existing.AddStore(store);
                return;
            }

            ProfilingInformation.OnContextCreated += ProfilingInformationOnOnContextCreated;

            var ravenProfilingHandler = new RavenProfilingHandler(new HashSet <string>(fieldsToFilter ?? Enumerable.Empty <string>()));

            ravenProfilingHandler.AddStore(store);

            RouteTable.Routes.Insert(0, new Route("ravendb/profiling", new RouteValueDictionary(new { controller = "RavenProfilingHandler", action = "ProcessRequest" }), ravenProfilingHandler));
            GlobalFilters.Filters.Add(new RecordCurrentControllerContextFilter(), -100);
        }