/// <summary>
        /// Gets the loader from the HttpContextBase
        /// </summary>
        /// <param name="http"></param>
        /// <returns></returns>
        public static DependencyRenderer GetLoader(this HttpContextBase http)
        {
            bool isNew;
            var  instance = DependencyRenderer.TryCreate(http, out isNew);

            return(instance);
        }
        /// <summary>
        /// Gets the loader from the ControllerContext
        /// </summary>
        /// <param name="cc"></param>
        /// <returns></returns>
        public static DependencyRenderer GetLoader(this ControllerContext cc)
        {
            bool isNew;
            var  instance = DependencyRenderer.TryCreate(cc.HttpContext, out isNew);

            return(instance);
        }
        /// <summary>
        /// Gets the loader from the ViewContext
        /// </summary>
        /// <param name="vc"></param>
        /// <returns></returns>
        public static DependencyRenderer GetLoader(this ViewContext vc)
        {
            bool isNew;
            var  instance = DependencyRenderer.TryCreate(vc.HttpContext, out isNew);

            return(instance);
        }
        private void PerformReplacements()
        {
            var output = _writer.ToString();

            //do replacements
            var replaced = DependencyRenderer.GetInstance(_httpContext).ParseHtmlPlaceholders(output);

            //write to original
            _originalWriter.Write(replaced);
        }
        /// <summary>
        /// Checks if a loader already exists, if it does, it returns it, otherwise it will
        /// create a new one in the control specified.
        /// isNew will be true if a loader was created, otherwise false if it already existed.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="isNew"></param>
        /// <returns></returns>
        internal static DependencyRenderer TryCreate(HttpContextBase ctx, out bool isNew)
        {
            if (GetInstance(ctx) == null)
            {
                lock (Locker)
                {
                    //double check
                    if (GetInstance(ctx) == null)
                    {
                        var loader = new DependencyRenderer(ctx);
                        isNew = true;
                        return(loader);
                    }
                }
            }

            isNew = false;
            return(GetInstance(ctx));
        }
Exemple #6
0
        /// <summary>
        /// Checks if a loader already exists, if it does, it returns it, otherwise it will
        /// create a new one in the control specified.
        /// isNew will be true if a loader was created, otherwise false if it already existed.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="isNew"></param>
        /// <returns></returns>
        internal static DependencyRenderer TryCreate(HttpContextBase ctx, out bool isNew)
        {
            if (Instance(ctx) == null)
            {
                lock (Locker)
                {
                    //double check
                    if (Instance(ctx) == null)
                    {
                        var loader = new DependencyRenderer(ctx);
                        isNew = true;
                        return loader;
                    }
                }

            }

            isNew = false;
            return Instance(ctx);
        }
        /// <summary>
        /// Updates the html js/css templates rendered temporarily by the controls into real js/css html tags.
        /// </summary>
        /// <param name="html"></param>
        /// <returns></returns>
        /// <remarks>
        /// This will also validate whether the rogue script handler should run and if so does.
        /// </remarks>
        public string UpdateOutputHtml(string html)
        {
            //first we need to check if this is MVC!
            if (CurrentContext.CurrentHandler is MvcHandler)
            {
                //parse the html output with the renderer
                var r = DependencyRenderer.GetInstance(CurrentContext);
                if (r != null)
                {
                    var output = r.ParseHtmlPlaceholders(html);

                    //get the rogue filter going
                    if (_rogueFileFilter.CanExecute())
                    {
                        output = _rogueFileFilter.UpdateOutputHtml(output);
                    }

                    return(output);
                }
            }
            return(html);
        }