Sdl.Web.Common.Models.ModelTypeRegistry.GetViewModelType C# (CSharp) Method

GetViewModelType() public static method

Get the View Model Type for a given View.
public static GetViewModelType ( MvcData viewData ) : Type
viewData MvcData The data for the View.
return System.Type
        public static Type GetViewModelType(MvcData viewData)
        {
            Type modelType;
            MvcData bareMvcData = new MvcData
            {
                AreaName = viewData.AreaName,
                ControllerName = viewData.ControllerName,
                ViewName = viewData.ViewName
            };
            if (!_viewToModelTypeMapping.TryGetValue(bareMvcData, out modelType))
            {
                throw new DxaException(
                    string.Format("No View Model registered for View '{0}'. Check that you have registered this View in the '{1}' area registration.", viewData, viewData.AreaName)
                    );
            }
            return modelType;
        }