Sdl.Web.Mvc/Configuration/BaseAreaRegistration.cs
/// <summary>
/// Registers a View Model and associated View.
/// </summary>
/// <param name="viewName">The name of the View to register.</param>
/// <param name="modelType">The View Model Type to associate with the View. Must be a subclass of Type <see cref="ViewModel"/>.</param>
/// <param name="controllerName">The Controller name. If not specified (or <c>null</c>), the Controller name is inferred from the <see cref="modelType"/>: either "Entity", "Region" or "Page".</param>
Registers a View Model and associated View.
Registers a View Model and associated View .
protected void RegisterViewModel(string viewName, Type modelType, string controllerName = null)
        {
            if (string.IsNullOrEmpty(controllerName))
            {
                if (typeof(EntityModel).IsAssignableFrom(modelType))
                {
                    controllerName = "Entity";
                }
                else if (typeof(RegionModel).IsAssignableFrom(modelType))
                {
                    controllerName = "Region";
                }
                else
                {
                    controllerName = "Page";
                }
            }
            MvcData mvcData = new MvcData { AreaName = AreaName, ControllerName = controllerName, ViewName = viewName };
            ModelTypeRegistry.RegisterViewModel(mvcData, modelType);
        }
protected void RegisterViewModel ( string viewName , Type modelType , string controllerName = null ) { if ( string . IsNullOrEmpty ( controllerName ) ) { if ( typeof ( EntityModel ) . IsAssignableFrom ( modelType ) ) { controllerName = " " ; } else if ( typeof ( RegionModel ) . IsAssignableFrom ( modelType ) ) { controllerName = " " ; } else { controllerName = " " ; } } MvcData mvcData = new MvcData { AreaName = AreaName , ControllerName = controllerName , ViewName = viewName } ; ModelTypeRegistry . RegisterViewModel ( mvcData , modelType ) ; }
Registers a View Model and associated View.
Registers a View Model and associated View .
viewName
string
The name of the View to register.
The name of the View to register .
modelType
Type
The View Model Type to associate with the View. Must be a subclass of Type .
The View Model Type to associate with the View . Must be a subclass of Type .
controllerName
string
The Controller name. If not specified (or null: either "Entity", "Region" or "Page".
The Controller name . If not specified ( or null : either " Entity " " Region " or " Page " .