예제 #1
0
        /// <summary>
        /// Manages script separation of concerns convention by loading the different javascript portions of each partial into a context item.
        /// </summary>
        private void RegisterJavaScript(ControllerContext controllerContext, string viewPath)
        {
            Guid?guid = null;
            ExtendedControllerContext extendedContext = GetExtendedControllerContext(controllerContext);

            if (extendedContext != null)
            {
                // When we render the view, we add JavaScript to the provided context, we identify contexts by using Guids.
                guid = extendedContext.Guid;
            }
            StringRenderingController controller = controllerContext.Controller as StringRenderingController;

            if (controller == null)
            {
                throw new InvalidOperationException(Resources.Error.ControllerBaseTypeMismatch);
            }
            if (viewPath.EndsWith(Resources.Constants.JavaScriptViewNamingExtension)) // sanity.
            {
                return;                                                               // prevent StackOverflowException.
            }
            string partial = controller.JavaScriptPartialViewString(viewPath, controller.ViewData.Model);

            if (partial != null)
            {
                IJavaScriptHelper javaScriptHelper = kernel.Resolve <IJavaScriptHelper>();
                javaScriptHelper.Register(viewPath, partial, guid);
            }
        }
예제 #2
0
        /// <summary>
        /// Using a single controller context, renders both HTML and JavaScript for a PartialView, separating its concerns in order to deliver a concise result.
        /// </summary>
        internal SeparationOfConcernsResult ViewSeparationOfConcerns(string viewName, string controller, object model)
        {
            ExtendedControllerContext context  = CloneControllerContext(); // use the same context in order to fetch JavaScript code for the PartialView being rendered.
            IJavaScriptHelper         jsHelper = Common.IoC.IoC.Container.Resolve <IJavaScriptHelper>();
            string html = ViewString(viewName, controller, model, context);
            string js   = jsHelper.Emit(context.Guid).ToHtmlString();

            return(new SeparationOfConcernsResult
            {
                Html = html,
                JavaScript = js
            });
        }
        public SquishItHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection)
        {
            #region Validation
            if (viewContext == null)
            {
                throw new ArgumentNullException("viewContext");
            }
            if (viewDataContainer == null)
            {
                throw new ArgumentNullException("viewDataContainer");
            }
            if (routeCollection == null)
            {
                throw new ArgumentNullException("routeCollection");
            }
            #endregion

            ViewContext = viewContext;
            ViewDataContainer = viewDataContainer;
            RouteCollection = routeCollection;

            Css = new CssHelper();
            JavaScript = new JavaScriptHelper();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WebDriverWaitHelper"/> class.
 /// </summary>
 /// <param name="webDriver">The Selenium webdriver.</param>
 /// <param name="timeoutSettings">Timeout settings.</param>
 /// <param name="javascriptHelper">The Javascript helper.</param>
 public WebDriverWaitHelper(IWebDriver webDriver, TimeoutSettings timeoutSettings, IJavaScriptHelper javascriptHelper)
 {
     this.WebDriver               = webDriver;
     this.TimeoutConfiguration    = timeoutSettings;
     this.WebDriverImplicitWait   = new WebDriverWait(webDriver, TimeSpan.FromSeconds(this.TimeoutConfiguration.ImplicitWait));
     this.WebDriverNavigationWait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(this.TimeoutConfiguration.PageNavigation));
     this.JavascriptHelper        = javascriptHelper;
 }