예제 #1
0
        /// <summary>
        /// Wraps existing view engines with ViewTrackerRazorEngine.
        /// </summary>
        /// <param name="application">Mvc Application</param>
        /// <param name="viewEngines">View Engines</param>
        public void StartTracking(HttpApplication application, ViewEngineCollection viewEngines)
        {
            _viewUsage = new ConcurrentDictionary <string, ulong>(_directoryHelper
                                                                  .GetFiles(HostingEnvironment.ApplicationPhysicalPath, "*.cshtml", SearchOption.AllDirectories)
                                                                  .ToDictionary(f => f, _ => (ulong)0));
            var engines = viewEngines.Select(v => new ViewTrackerRazorEngine(v, this)).ToList();

            viewEngines.Clear();
            engines.ForEach(viewEngines.Add);
        }