Beispiel #1
0
        public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
        {
            ViewEngineResult         result;
            string                   requiredString = controllerContext.RouteData.GetRequiredString("controller");
            ViewEngineResultCacheKey key            = new ViewEngineResultCacheKey(requiredString, viewName);

            if (!useCache)
            {
                result = this.InternalFindView(controllerContext, viewName, requiredString);
                this.viewEngineResults[key] = result;
                return(result);
            }
            if (this.viewEngineResults.TryGetValue(key, out result))
            {
                return(result);
            }
            lock (this.syncHelper)
            {
                if (!this.viewEngineResults.TryGetValue(key, out result))
                {
                    result = this.InternalFindView(controllerContext, viewName, requiredString);
                    this.viewEngineResults[key] = result;
                }
                return(result);
            }
        }
Beispiel #2
0
        public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
        {
            string controllerName        = controllerContext.RouteData.GetRequiredString("controller");
            ViewEngineResultCacheKey key = new ViewEngineResultCacheKey(controllerName, viewName);
            ViewEngineResult         result;

            if (!useCache)
            {
                result = InternalFindView(controllerContext, viewName, controllerName);
                viewEngineResults[key] = result;
                return(result);
            }
            if (viewEngineResults.TryGetValue(key, out result))
            {
                return(result);
            }
            lock (syncHelper)
            {
                if (viewEngineResults.TryGetValue(key, out result))
                {
                    return(result);
                }

                result = InternalFindView(controllerContext, viewName, controllerName);
                viewEngineResults[key] = result;
                return(result);
            }
        }
Beispiel #3
0
        public override bool Equals(object obj)
        {
            ViewEngineResultCacheKey key = obj as ViewEngineResultCacheKey;

            if (null == key)
            {
                return(false);
            }
            return(key.GetHashCode() == this.GetHashCode());
        }