/// <exclude />
        public static void ApplicationStartInitialize(bool displayDebugInfo = false)
        {
            ThreadDataManager.InitializeThroughHttpContext();

            if (displayDebugInfo)
            {
                Log.LogVerbose("Global.asax", "--- Web Application Start, {0} Id = {1} ---", DateTime.Now.ToLongTimeString(), AppDomain.CurrentDomain.Id);
            }

            PerformanceCounterFacade.SystemStartupIncrement();

            using (GlobalInitializerFacade.GetPreInitHandlersScope())
            {
                ApplicationStartupFacade.FireConfigureServices(ServiceLocator.ServiceCollection);

                ServiceLocator.BuildServiceProvider();
                ServiceLocator.CreateRequestServicesScope(HttpContext.Current);

                ApplicationStartupFacade.FireBeforeSystemInitialize(ServiceLocator.ServiceProvider);
            }

            TempDirectoryFacade.OnApplicationStart();

            HostnameBindingsFacade.Initialize();

            ApplicationStartupFacade.FireSystemInitialized(ServiceLocator.ServiceProvider);

            ThreadDataManager.FinalizeThroughHttpContext();
        }
        /// <exclude />
        public static void CompileAll()
        {
            FieldInfo theBuildManagerFieldInfo = typeof(System.Web.Compilation.BuildManager).GetField("_theBuildManager", BindingFlags.NonPublic | BindingFlags.Static);
            FieldInfo cachesManagerFieldInfo   = typeof(System.Web.Compilation.BuildManager).GetField("_caches", BindingFlags.NonPublic | BindingFlags.Instance);

            object      currentBuilderManager = theBuildManagerFieldInfo.GetValue(null);
            IEnumerable caches = cachesManagerFieldInfo.GetValue(currentBuilderManager) as IEnumerable;

            Type      standardDiskBuildResultCacheType = caches.OfType <object>().Where(f => f.GetType().FullName == "System.Web.Compilation.StandardDiskBuildResultCache").Select(f => f.GetType()).Single();
            FieldInfo maxRecompilationsFieldInfo       = standardDiskBuildResultCacheType.BaseType.GetField("s_maxRecompilations", BindingFlags.NonPublic | BindingFlags.Static);

            object oldValue = maxRecompilationsFieldInfo.GetValue(null);

            maxRecompilationsFieldInfo.SetValue(null, 500);

            IEnumerable <string> paths = GetControlPaths();

            IPerformanceCounterToken performanceCounterToken = PerformanceCounterFacade.BeginAspNetControlCompile();

            // ParallelFacade.ForEach(paths, path => // Call to parallelization facade causes a deadlock while starting-up!!!
            foreach (string path in paths)
            {
                int  t1   = Environment.TickCount;
                Type type = BuildManagerHelper.GetCompiledType(path);
                int  t2   = Environment.TickCount;

                LoggingService.LogVerbose("RGB(180, 180, 255)ControlCompilerService", string.Format("{0} compiled in {1} ms", path, t2 - t1));
            }

            PerformanceCounterFacade.EndAspNetControlCompile(performanceCounterToken, paths.Count());

            // maxRecompilationsFieldInfo.SetValue(null, oldValue);
        }
        internal static bool GetCachedHookingParents(EntityToken entityToken, out IEnumerable <EntityToken> parentEntityTokens, string userName)
        {
            if (!Enabled || userName == null)
            {
                parentEntityTokens = null;
                return(false);
            }

            CacheKey cacheKey = new CacheKey {
                Username = userName, EntityToken = entityToken, Locale = Data.LocalizationScopeManager.CurrentLocalizationScope
            };

            CacheEntry cacheEntry;

            if (_hookingCache.TryGetValue(cacheKey, out cacheEntry))
            {
                PerformanceCounterFacade.EntityTokenParentCacheHitIncrement();
                parentEntityTokens = cacheEntry.ParentEntityTokens;
                return(true);
            }

            PerformanceCounterFacade.EntityTokenParentCacheMissIncrement();
            parentEntityTokens = null;
            return(false);
        }
Пример #4
0
        private static IEnumerable <Element> GetChildren(ElementHandle elementHandle, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            if (elementHandle == null)
            {
                throw new ArgumentNullException("elementHandle");
            }

            IPerformanceCounterToken performanceToken = PerformanceCounterFacade.BeginElementCreation();

            IEnumerable <Element> children;

            if (ElementProviderRegistry.ElementProviderNames.Contains(elementHandle.ProviderName))
            {
                if ((useForeign == false) || (ElementProviderPluginFacade.IsLocaleAwareElementProvider(elementHandle.ProviderName) == false))
                {
                    children = ElementProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
                else
                {
                    children = ElementProviderPluginFacade.GetForeignChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
            }
            else if (ElementAttachingProviderRegistry.ElementAttachingProviderNames.Contains(elementHandle.ProviderName))
            {
                children = ElementAttachingProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, elementHandle.Piggyback).Evaluate();
            }
            else
            {
                throw new InvalidOperationException(string.Format("No element provider named '{0}' found", elementHandle.ProviderName));
            }

            foreach (Element element in children)
            {
                if (element.VisualData.HasChildren == false)
                {
                    element.VisualData.HasChildren = ElementAttachingProviderFacade.HaveCustomChildElements(element.ElementHandle.EntityToken, element.ElementHandle.Piggyback);
                }
            }

            children = ElementAttachingProviderFacade.AttachElements(elementHandle.EntityToken, elementHandle.Piggyback, children).Evaluate();

            int totalElementCount = children.Count();

            ElementActionProviderFacade.AddActions(children, elementHandle.ProviderName);

            if (performSecurityCheck)
            {
                children = children.FilterActions().Evaluate();
            }

            PerformanceCounterFacade.EndElementCreation(performanceToken, children.Count(), totalElementCount);

            return(children);
        }
Пример #5
0
        private static IEnumerable <Element> GetChildren(ElementHandle elementHandle, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            Verify.ArgumentNotNull(elementHandle, nameof(elementHandle));

            var performanceToken = PerformanceCounterFacade.BeginElementCreation();

            var children = GetChildrenFromProvider(elementHandle, searchToken, useForeign).Evaluate();

            var originalChildren = children;

            children = ElementAttachingProviderFacade.AttachElements(elementHandle.EntityToken, elementHandle.Piggyback, children).Evaluate();

            int totalElementCount = children.Count;

            if (performSecurityCheck)
            {
                children = children.FilterElements().Evaluate();
            }

            // Evaluating HasChildren for not attached elements
            foreach (Element element in originalChildren)
            {
                if (children.Contains(element) && !element.VisualData.HasChildren)
                {
                    element.VisualData.HasChildren = ElementAttachingProviderFacade.HaveCustomChildElements(element.ElementHandle.EntityToken, element.ElementHandle.Piggyback);
                }
            }

            ElementActionProviderFacade.AddActions(children, elementHandle.ProviderName);

            if (performSecurityCheck)
            {
                children = children.FilterActions().Evaluate();
            }

            PerformanceCounterFacade.EndElementCreation(performanceToken, children.Count, totalElementCount);

            return(children);
        }