public void GenerateViewForController(ControllerScaffolderModel controllerModel, ModelMetadata modelMetadata, string viewName) { if (controllerModel == null) { throw new ArgumentNullException("controllerModel"); } if (modelMetadata == null) { throw new ArgumentNullException("modelMetadata"); } if (string.IsNullOrEmpty(viewName)) { throw new ArgumentException("Template name is invalid.", "viewName"); } base.Model.ViewName = viewName; if (!string.Equals(viewName, MvcViewTemplates.Index, StringComparison.Ordinal)) { base.Model.ViewTemplate = new ViewTemplate(viewName, true); } else { base.Model.ViewTemplate = new ViewTemplate(MvcViewTemplates.List, true); } base.Model.IsPartialViewSelected = false; base.Model.IsOverwritingFiles = true; base.Model.IsReferenceScriptLibrariesSelected = controllerModel.IsReferenceScriptLibrariesSelected; base.Model.IsLayoutPageSelected = controllerModel.IsLayoutPageSelected; base.Model.LayoutPageFile = controllerModel.LayoutPageFile; base.Model.DataContextType = controllerModel.DataContextType; base.Model.ModelType = controllerModel.ModelType; string str = Path.Combine(controllerModel.AreaRelativePath, "Views", controllerModel.ControllerRootName); this.GenerateView(modelMetadata, str); }
public void RecordControllerTelemetryOptions(CodeGenerationContext context, ControllerScaffolderModel model) { if (context == null) { throw new ArgumentNullException("context"); } if (model == null) { throw new ArgumentNullException("model"); } MvcControllerScaffolderOptions mvcControllerScaffolderOption = MvcControllerScaffolderOptions.CreatedController; if (model.IsAsyncSelected) { mvcControllerScaffolderOption |= MvcControllerScaffolderOptions.IsAsyncSelected; } if (model.IsViewGenerationSelected) { mvcControllerScaffolderOption |= MvcControllerScaffolderOptions.CreatedViews; if (model.IsReferenceScriptLibrariesSelected) { mvcControllerScaffolderOption |= MvcControllerScaffolderOptions.IsReferenceScriptLibrariesSelected; } if (model.IsLayoutPageSelected) { mvcControllerScaffolderOption |= MvcControllerScaffolderOptions.IsUseLayoutPageSelected; if (!string.IsNullOrWhiteSpace(model.LayoutPageFile)) { mvcControllerScaffolderOption |= MvcControllerScaffolderOptions.IsLayoutPageSpecified; } } } context.AddTelemetryData("MvcControllerScaffolderOptions", (uint)mvcControllerScaffolderOption); }
protected override void OnModelCreated(ControllerScaffolderModel model) { base.OnModelCreated(model); model.ControllerName = null; model.IsModelClassSupported = true; model.IsDataContextSupported = true; }
protected override ControllerScaffolderModel CreateModel() { ControllerScaffolderModel controllerScaffolderModel = new ControllerScaffolderModel(base.Context); controllerScaffolderModel.ControllerName = controllerScaffolderModel.GetGeneratedName(MvcProjectUtil.ControllerName, controllerScaffolderModel.CodeFileExtension); this.OnModelCreated(controllerScaffolderModel); return(controllerScaffolderModel); }
public MvcDataContextViewModel(ControllerScaffolderModel model) : base(model) { if (model == null) { throw new ArgumentNullException("model"); } this.Model = model; this.DataContextName = model.DataContextName; }
public MvcControllerScaffolderViewModel(ControllerScaffolderModel model) : base(model) { if (model == null) { throw new ArgumentNullException("model"); } this.Model = model; this.ControllerName = model.ControllerName; this.IsAsyncSelected = model.IsAsyncSelected; base.SetValidationMessage(this.Model.ValidateControllerName(this.ControllerName), "ControllerName"); this.IsViewGenerationSupported = this.Model.IsViewGenerationSupported; if (this.IsViewGenerationSupported) { this.IsViewGenerationSelected = this.Model.IsViewGenerationSelected; this.IsLayoutPageSelected = this.Model.IsLayoutPageSelected; this.IsReferenceScriptLibrariesSelected = this.Model.IsReferenceScriptLibrariesSelected; this.LayoutPageFile = model.LayoutPageFile; } this.DataContextTypesInternal = new ObservableCollection <ModelType>(); this.ModelTypesInternal = new ObservableCollection <ModelType>(); this.DataContextTypes = new ListCollectionView(this.DataContextTypesInternal) { CustomSort = new DataContextModelTypeComparer() }; this.ModelTypes = CollectionViewSource.GetDefaultView(this.ModelTypesInternal); this.ModelTypes.SortDescriptions.Add(new SortDescription("ShortTypeName", ListSortDirection.Ascending)); this.IsModelClassSupported = this.Model.IsModelClassSupported; this.IsDataContextSupported = this.Model.IsDataContextSupported; if (this.Model.IsModelClassSupported) { foreach (ModelType modelType in this.Model.ModelTypes) { this.ModelTypesInternal.Add(modelType); } base.SetValidationMessage(this.Model.ValidateModelType(null), "ModelType"); } if (this.Model.IsDataContextSupported) { foreach (ModelType dataContextType in this.Model.DataContextTypes) { this.DataContextTypesInternal.Add(dataContextType); } if (model.DataContextType != null) { this.DataContextType = this.Model.DataContextType; this.DataContextTypeName = this.DataContextType.DisplayName; } base.SetValidationMessage(this.Model.ValidateDataContextType(this.DataContextType), "DataContextType"); } this.AddNewDataContextCommand = new RelayCommand(new Action <object>(this.AddNewDataContext)); this.SelectLayoutCommand = new RelayCommand(new Action <object>(this.SelectLayout)); this.AsyncInformationIcon = MvcControllerScaffolderViewModel.GetInformationIcon(); }
protected override void OnModelCreated(ControllerScaffolderModel model) { base.OnModelCreated(model); model.IsViewFolderRequired = true; }
protected override object CreateViewModel(ControllerScaffolderModel model) { return(new MvcControllerScaffolderViewModel(model)); }
protected virtual void OnModelCreated(ControllerScaffolderModel model) { }