public dynamic CreateHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) { return new DisplayHelper( _displayManager, _shapeFactory, viewContext, viewDataContainer); }
public ControlLib(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) : base(viewContext, viewDataContainer, routeCollection) { ViewContext = viewContext; ViewData = new ViewDataDictionary(viewDataContainer.ViewData); }
public BaseViewHelper(RequestContext requestContext, ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) { if (requestContext == null) { throw new ArgumentNullException("requestContext"); } if (viewContext == null) { throw new ArgumentNullException("viewContext"); } if (viewDataContainer == null) { throw new ArgumentNullException("viewDataContainer"); } if (routeCollection == null) { throw new ArgumentNullException("routeCollection"); } ViewData = new ViewDataDictionary(viewDataContainer.ViewData); RequestContext = requestContext; ViewContext = viewContext; RouteCollection = routeCollection; }
public HtmlHelper( ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection ) { if (viewContext == null) { throw new ArgumentNullException("viewContext"); } if (viewDataContainer == null) { throw new ArgumentNullException("viewDataContainer"); } if (routeCollection == null) { throw new ArgumentNullException("routeCollection"); } ViewContext = viewContext; ViewDataContainer = viewDataContainer; RouteCollection = routeCollection; ClientValidationRuleFactory = (name, metadata) => ModelValidatorProviders.Providers .GetValidators( metadata ?? ModelMetadata.FromStringExpression(name, ViewData), ViewContext ) .SelectMany(v => v.GetClientValidationRules()); }
/// <summary> /// Indicates whether the views are rendered in reverse order. /// If so, scripts & css should be executed also in reverse order. /// /// We do this for Razor views only, based on the LayoutPath. /// </summary> /// <param name="container"></param> /// <param name="view"></param> /// <param name="viewPath"></param> /// <returns></returns> public static bool RegisterReverseOrder(this IViewDataContainer container, IView view, out string viewPath) { // yeah, I know this is kinda gay, but it's the only way to keep MVC 2 compatible Type razorViewAssignableFrom = new Func <Type>(() => { try { var mvcDll = AppDomain.CurrentDomain.GetAssemblies().Where(t => t.GetName().Name == "System.Web.Mvc"); var compiledView = mvcDll.First().GetType("System.Web.Mvc.RazorView"); if (compiledView.IsAssignableFrom(view.GetType())) { return(compiledView); } return(null); } catch { return(null); } })(); // not a Razor view? Then return false. if (razorViewAssignableFrom == null) { viewPath = null; return(false); } viewPath = container.GetType().Name; return(true); }
protected MVCUIBase(ControlSettingsBase settings, ViewContext context, IViewDataContainer viewDataContainer) : this(settings) { ViewContext = context; ViewDataContainer = viewDataContainer; }
/// <summary> /// Creates a new IViewDataContainer but with a filtered ModelState /// </summary> /// <param name="container"></param> /// <param name="prefix"></param> /// <returns></returns> public static IViewDataContainer FilterContainer(this IViewDataContainer container, string prefix) { var newContainer = new ViewDataContainer(); newContainer.ViewData.ModelState.Merge(container.ViewData.ModelState, prefix); return(newContainer); }
public static Customer CurrentCustomer(this IViewDataContainer pg) { //this will never be null var result = (Customer)pg.ViewData["CurrentCustomer"]; return(result); }
public static HtmlHelper <TModel> CreateMockHtmlHelper <TModel>(TextWriter writer, RouteData routeData) { ViewContext viewContext; IViewDataContainer viewDataContainer = GetViewDataContainer(writer, routeData, out viewContext); return(new HtmlHelper <TModel>(viewContext, viewDataContainer)); }
public BaseViewHelper(RequestContext requestContext, ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) { ViewData = new ViewDataDictionary(viewDataContainer.ViewData); RequestContext = requestContext; ViewContext = viewContext; RouteCollection = routeCollection; }
protected void EnsureViewData() { if (_viewData != null) { return; } IViewDataContainer vdc = GetViewDataContainer(this); if (vdc == null) { throw Mvc.Error.ControlRequiresViewDataProvider(); } ViewDataDictionary vd = vdc.ViewData; if (!String.IsNullOrEmpty(_subDataKey)) { ViewDataDictionary subViewData; vdc.ViewData.SubDataItems.TryGetValue(_subDataKey, out subViewData); vd = new ViewDataDictionary(subViewData); vd.Model = subViewData.Model; } if (!String.IsNullOrEmpty(ViewDataKey)) { ViewDataDictionary vdPart = new ViewDataDictionary(); vdPart.Model = vd[ViewDataKey]; vd = vdPart; } SetViewData(vd); }
protected void EnsureViewData() { if (_viewData != null) { return; } // Get the ViewData for this ViewUserControl, optionally using the specified ViewDataKey IViewDataContainer vdc = GetViewDataContainer(this); if (vdc == null) { throw new InvalidOperationException( String.Format( CultureInfo.CurrentCulture, MvcResources.ViewUserControl_RequiresViewDataProvider, AppRelativeVirtualPath)); } ViewDataDictionary myViewData = vdc.ViewData; // If we have a ViewDataKey, try to extract the ViewData from the dictionary, otherwise // return the container's ViewData. if (!String.IsNullOrEmpty(ViewDataKey)) { object target = myViewData.Eval(ViewDataKey); myViewData = target as ViewDataDictionary ?? new ViewDataDictionary(myViewData) { Model = target }; } SetViewData(myViewData); }
public dynamic CreateHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) { return ClayActivator.CreateInstance<DisplayHelper>( _behaviors, _displayManager, _shapeFactory, viewContext, viewDataContainer); }
public static IEnumerable <IBehaviorMarker> GetBehaviors(this IViewDataContainer view) { var behaviorsContainer = view as IBehaviorsContainer; return(behaviorsContainer == null ? null : behaviorsContainer.Behaviors); }
public dynamic CreateHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) { return(new DisplayHelper( _displayManager, _shapeFactory, viewContext, viewDataContainer)); }
public AjaxHelper( ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection ) : base(viewContext, viewDataContainer, routeCollection) { _viewData = new ViewDataDictionary <TModel>(viewDataContainer.ViewData); }
private static IViewDataContainer CreateViewDataContainer(ViewContext viewContext) { IViewDataContainer container = Substitute.For <IViewDataContainer>(); container.ViewData = viewContext.ViewData; return(container); }
/// <summary> /// Creates a new IViewDataContainer but with a filtered ModelState /// </summary> /// <param name="container"></param> /// <param name="prefix"></param> /// <returns></returns> public static IViewDataContainer FilterContainer(this IViewDataContainer container, string prefix) { var newContainer = new ViewDataContainer(); newContainer.ViewData.ModelState.Merge(container.ViewData.ModelState, prefix); //change the html field name too newContainer.ViewData.TemplateInfo.HtmlFieldPrefix = prefix; return(newContainer); }
internal static HtmlHelper GetHtmlHelper(ViewDataDictionary viewData) { Mock <ViewContext> mockViewContext = new Mock <ViewContext>(); mockViewContext.Expect(c => c.ViewData).Returns(viewData); IViewDataContainer container = GetViewDataContainer(viewData); return(new HtmlHelper(mockViewContext.Object, container)); }
public dynamic CreateHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) { return(ClayActivator.CreateInstance <DisplayHelper>( _behaviors, _displayManager, _shapeFactory, viewContext, viewDataContainer)); }
public VehicleHelperFixture() { this.previousCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; _viewDataContainer = new Mock<IViewDataContainer>().Object; _viewContext = new Mock<ViewContext>().Object; _helper = new HtmlHelper(_viewContext, _viewDataContainer); }
public static HtmlHelper <TModel> GetHtmlHelperWithPath <TModel>(ViewDataDictionary <TModel> viewData, string appPath) { ViewContext viewContext = GetViewContextWithPath(appPath, viewData); Mock <IViewDataContainer> mockContainer = new Mock <IViewDataContainer>(); mockContainer.Expect(c => c.ViewData).Returns(viewData); IViewDataContainer container = mockContainer.Object; return(new HtmlHelper <TModel>(viewContext, container, new RouteCollection())); }
public static Category CurrentCategory(this IViewDataContainer pg) { Category result = new Category(); if (pg.ViewData["CurrentCategory"] != null) { result = (Category)pg.ViewData["CurrentCategory"]; } return(result); }
public DisplayHelper( IDisplayManager displayManager, IShapeFactory shapeFactory, ViewContext viewContext, IViewDataContainer viewDataContainer) { _displayManager = displayManager; _shapeFactory = shapeFactory; ViewContext = viewContext; ViewDataContainer = viewDataContainer; }
public static Product Product(this IViewDataContainer pg) { Product result = null; if (pg.ViewData["SelectedProduct"] != null) { result = (Product)pg.ViewData["SelectedProduct"]; } return(result); }
/// <summary> /// Returns a new IViewContainer based on the current one but supplies a different model to the ViewData /// </summary> /// <param name="container"></param> /// <param name="model"></param> /// <returns></returns> public static IViewDataContainer CopyWithModel(this IViewDataContainer container, object model) { return(new ViewDataContainer { ViewData = new ViewDataDictionary(container.ViewData) { Model = model } }); }
public static IList <Category> Categories(this IViewDataContainer pg) { List <Category> result = new List <Category>(); if (pg.ViewData["Categories"] != null) { result = (List <Category>)pg.ViewData["Categories"]; } return(result); }
internal static HtmlHelper GetHtmlHelper(ViewDataDictionary viewData, string appPath) { ViewContext viewContext = GetViewContext(appPath); Mock <IViewDataContainer> mockContainer = new Mock <IViewDataContainer>(); mockContainer.Expect(c => c.ViewData).Returns(viewData); IViewDataContainer container = mockContainer.Object; return(new HtmlHelper(viewContext, container)); }
public static HtmlHelper GetHtmlHelperWithPath(ViewDataDictionary viewData, string appPath) { ViewContext viewContext = GetViewContextWithPath(appPath, viewData); var mockContainer = new Mock <IViewDataContainer>(); mockContainer.Setup(c => c.ViewData).Returns(viewData); IViewDataContainer container = mockContainer.Object; return(new HtmlHelper(viewContext, container, new RouteCollection())); }
public HtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) : base(viewContext, viewDataContainer) { if (!(viewDataContainer.ViewData is ViewDataDictionary <TModel>)) { throw new ArgumentException( $"{nameof(viewDataContainer)}.ViewData should be an instance of 'ViewDataDictionary<TModel>'.", nameof(viewDataContainer) ); } }
public static PagedList <Product> Products(this IViewDataContainer pg) { PagedList <Product> result = new PagedList <Product>(new List <Product>(), 1, 1, 1); if (pg.ViewData["Products"] != null) { IList <Product> products = (IList <Product>)pg.ViewData["Products"]; result = new PagedList <Product>(products.ToList(), products.Count, 0, 20); } return(result); }
public static SeoHelper GetSeoHelper(this IViewDataContainer viewDataContainer) { if (viewDataContainer == null) { throw new ArgumentNullException(nameof(viewDataContainer)); } var seoHelper = viewDataContainer.ViewData?.GetSeoHelper(); return(seoHelper); }
public static ShippingMethod SelectedShipping(this IViewDataContainer pg) { ShippingMethod result = null; if (pg.ViewData["SelectedShipping"] != null) { result = (ShippingMethod)pg.ViewData["SelectedShipping"]; } return(result); }
public SyncViewAction(IView view, IViewDataContainer viewDataContainer) { if (view == null) { throw new InfrastructureException("The view cannot be null."); } this.view = view; this.viewDataContainer = viewDataContainer; }
/// <summary> /// Generate an HTML input element of type 'checkbox' and set checked from ViewData based on the name provided. /// The checkbox element has an accompanying input element of type 'hidden' to support binding upon form post. /// </summary> /// <param name="view">The view.</param> /// <param name="name">Value of the 'name' attribute of the element. Also used to derive the 'id' attribute.</param> public static CheckBox CheckBox(this IViewDataContainer view, string name) { var checkbox = new CheckBox(name, null, view.GetBehaviors()).Value(true); var chkd = view.ViewData.Eval(name) as bool?; if (chkd.HasValue) { checkbox.Checked(chkd.Value); } return(checkbox); }
public static IList <ShippingMethod> ShippingMethods(this IViewDataContainer pg) { IList <ShippingMethod> result = null; if (pg.ViewData["ShippingMethods"] != null) { result = (IList <ShippingMethod>)pg.ViewData["ShippingMethods"]; } return(result); }
public AjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) { if (viewContext == null) { throw new ArgumentNullException("viewContext"); } if (viewDataContainer == null) { throw new ArgumentNullException("viewDataContainer"); } if (routeCollection == null) { throw new ArgumentNullException("routeCollection"); } ViewContext = viewContext; ViewDataContainer = viewDataContainer; RouteCollection = routeCollection; }
public ResourceRegister(IViewDataContainer container, IResourceManager resourceManager, string resourceType) { var templateControl = container as TemplateControl; if (templateControl != null) { _viewVirtualPath = templateControl.AppRelativeVirtualPath; } else { var webPage = container as WebPageBase; if (webPage != null) { _viewVirtualPath = webPage.VirtualPath; } } ResourceManager = resourceManager; ResourceType = resourceType; }
internal static MvcRenderingContext Build(ViewContext viewContext, IViewDataContainer viewDataContainer, TextWriter writer) { var context = GetFromViewContext(viewContext); if (context != null) return context; MvcRenderingContext parentContext = null; if (viewContext.ParentActionViewContext != null) parentContext = GetFromViewContext(viewContext.ParentActionViewContext); context = new MvcRenderingContext(viewContext, viewDataContainer, writer, parentContext); viewContext.ViewData.Add(ContextKey, context); return context; }
public HtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) { if (viewContext == null) { throw new ArgumentNullException("viewContext"); } if (viewDataContainer == null) { throw new ArgumentNullException("viewDataContainer"); } if (routeCollection == null) { throw new ArgumentNullException("routeCollection"); } ViewContext = viewContext; ViewDataContainer = viewDataContainer; RouteCollection = routeCollection; ClientValidationRuleFactory = (name, metadata) => ModelValidatorProviders.Providers.GetValidators(metadata ?? ModelMetadata.FromStringExpression(name, ViewData), ViewContext).SelectMany(v => v.GetClientValidationRules()); }
public PluginHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) { if (viewContext == null) { throw new ArgumentNullException("viewContext"); } if (viewDataContainer == null) { throw new ArgumentNullException("viewDataContainer"); } if (routeCollection == null) { throw new ArgumentNullException("routeCollection"); } this.ViewContext = viewContext; this.ViewDataContainer = viewDataContainer; this.Model = ViewContext.ViewData.Model as TemplateContentModel; this.RouteCollection = routeCollection; }
public FileRegistrationContext(ControllerContext viewContext, IViewDataContainer viewDataContainer, string tagName, string fileName, string position, string filePathAttributeName, TagRenderMode fileTagRenderMode) : base(viewContext.HttpContext, viewContext.RouteData) { _fileTagRenderMode = fileTagRenderMode; Container = viewDataContainer as TemplateControl; if (Container != null) { ContainerVirtualPath = Container.AppRelativeVirtualPath.Substring( 0, Container.AppRelativeVirtualPath.IndexOf( "/Views", StringComparison.InvariantCultureIgnoreCase ) ); } FileName = fileName; Position = position; FilePathAttributeName = filePathAttributeName; _tagBuilder = new TagBuilder(tagName); }
/// <summary> /// Initialize new instance of class <see cref="ThunderHelper"/>. /// </summary> /// <param name="viewContext"><see cref="ViewContext"/></param> /// <param name="viewDataContainer"><see cref="IViewDataContainer"/></param> /// <param name="routeCollection"><see cref="RouteCollection"/></param> /// <param name="htmlHelper"><see cref="HtmlHelper"/></param> /// <exception cref="ArgumentNullException"></exception> public ThunderHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection, HtmlHelper htmlHelper) { if (viewContext == null) { throw new ArgumentNullException("viewContext"); } if (viewDataContainer == null) { throw new ArgumentNullException("viewDataContainer"); } if (routeCollection == null) { throw new ArgumentNullException("routeCollection"); } ViewContext = viewContext; RouteCollection = routeCollection; Html = htmlHelper; ViewData = new ViewDataDictionary(viewDataContainer.ViewData); }
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(); }
public AjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) : this(viewContext, viewDataContainer, RouteTable.Routes) { }
public SpyHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) : base(viewContext, viewDataContainer) { }
public RubyHtmlHelper(ViewContext context, IViewDataContainer viewDataContainer) : base(context, viewDataContainer) { _helper = new HtmlHelper(context, viewDataContainer); }
public MasonryHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) { ViewContext = viewContext; ViewDataContainer = viewDataContainer; RouteCollection = routeCollection; }
public MasonryHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) : this(viewContext, viewDataContainer, RouteTable.Routes) { }
public HtmlExtensionDuck(ViewContext viewContext, IViewDataContainer container) : this(new HtmlHelper(viewContext, container)) { }
TestableHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) : base(viewContext, viewDataContainer) { }
public RubyAjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, RouteCollection routeCollection) : base(viewContext, viewDataContainer, routeCollection) { _helper = new AjaxHelper(viewContext, viewDataContainer, routeCollection); }
public RubyAjaxHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) : base(viewContext, viewDataContainer) { _helper = new AjaxHelper(viewContext, viewDataContainer); }
protected ScriptRegister(IViewDataContainer container, IResourceManager resourceManager) : base(container, resourceManager, "script") { }
public FluentHtmlHelper(ViewContext viewContext, IViewDataContainer viewDataContainer) : base(viewContext, viewDataContainer, RouteTable.Routes) { Url = new UrlHelper(ViewContext.RequestContext); }
public FileRegistrationContext(ControllerContext viewContext, IViewDataContainer viewDataContainer, string tagName, string fileName, string position) : this(viewContext, viewDataContainer, tagName, fileName, position, _filePathAttributes[tagName], _fileTagRenderModes[tagName]) { }
/// <summary> /// Initialize new instance of class <see cref="ThunderHelper"/>. /// </summary> /// <param name="viewContext"><see cref="ViewContext"/></param> /// <param name="viewDataContainer"><see cref="IViewDataContainer"/></param> /// <param name="htmlHelper"><see cref="HtmlHelper"/></param> public ThunderHelper(ViewContext viewContext, IViewDataContainer viewDataContainer, HtmlHelper htmlHelper) : this(viewContext, viewDataContainer, RouteTable.Routes, htmlHelper) { }
protected virtual MvcRenderingContext ResolveContext(ViewContext viewContext, IViewDataContainer viewDataContainer, TextWriter writer) { return MvcRenderingContext.Build(viewContext, viewDataContainer, writer); }
public BaseViewHelper(RequestContext requestContext, ViewContext viewContext, IViewDataContainer viewDataContainer) : this(requestContext, viewContext, viewDataContainer, RouteTable.Routes) { }