protected override void OnModelCreated(ControllerScaffolderModel model)
 {
     base.OnModelCreated(model);
     model.ControllerName        = null;
     model.IsAsyncSupported      = true;
     model.IsModelClassSupported = true;
 }
示例#2
0
        protected sealed override ControllerScaffolderModel CreateModel()
        {
            ControllerScaffolderModel model = new ControllerScaffolderModel(Context);

            model.ControllerName = model.GetGeneratedName(MvcProjectUtil.ControllerName, model.CodeFileExtension);
            OnModelCreated(model);
            return(model);
        }
示例#3
0
        public MvcDataContextViewModel(ControllerScaffolderModel model) : base(model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            Model           = model;
            DataContextName = model.DataContextName;
        }
 protected virtual void OnModelCreated(ControllerScaffolderModel model)
 {
     model.ControllerName            = null;
     model.IsModelClassSupported     = true;
     model.IsDataContextSupported    = false;
     model.IsViewFolderRequired      = true;
     model.IsViewGenerationSupported = true;
     model.IsViewGenerationSelected  = true;
     model.IsAsyncSupported          = true;
 }
示例#5
0
        public MvcDataContextViewModel(ControllerScaffolderModel model)
            : base(model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            Model = model;
            DataContextName = model.DataContextName;
        }
示例#6
0
        public void RecordControllerTelemetryOptions(CodeGenerationContext context, ControllerScaffolderModel model)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            WebApiControllerScaffolderOptions webApiControllerScaffolderOption = WebApiControllerScaffolderOptions.CreatedController;

            if (model.IsAsyncSelected)
            {
                webApiControllerScaffolderOption |= WebApiControllerScaffolderOptions.IsAsyncSelected;
            }
            context.AddTelemetryData("WebApiControllerScaffolderOptions", (uint)webApiControllerScaffolderOption);
        }
        public ControllerScaffolderViewModel(ControllerScaffolderModel model)
            : base(model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            Model = model;

            ControllerName  = model.ControllerName;
            IsAsyncSelected = model.IsAsyncSelected;
            SetValidationMessage(Model.ValidateControllerName(ControllerName), "ControllerName");

            IsViewGenerationSupported = Model.IsViewGenerationSupported;
            if (IsViewGenerationSupported)
            {
                IsViewGenerationSelected           = Model.IsViewGenerationSelected;
                IsLayoutPageSelected               = Model.IsLayoutPageSelected;
                IsReferenceScriptLibrariesSelected = Model.IsReferenceScriptLibrariesSelected;
                LayoutPageFile = model.LayoutPageFile;
            }

            DataContextTypesInternal = new ObservableCollection <ModelType>();
            ModelTypesInternal       = new ObservableCollection <ModelType>();

            // The CustomSort here will ensure that the <Add new> item stays at the top. Custom Sort
            // is mutually exclusive with the use of SortDescriptions.
            DataContextTypes            = new ListCollectionView(DataContextTypesInternal);
            DataContextTypes.CustomSort = new DataContextModelTypeComparer();

            ModelTypes = CollectionViewSource.GetDefaultView(ModelTypesInternal);
            ModelTypes.SortDescriptions.Add(new SortDescription("ShortTypeName", ListSortDirection.Ascending));

            IsModelClassSupported  = Model.IsModelClassSupported;
            IsDataContextSupported = Model.IsDataContextSupported;

            if (Model.IsModelClassSupported)
            {
                foreach (ModelType modelType in Model.ModelTypes)
                {
                    ModelTypesInternal.Add(modelType);
                }

                SetValidationMessage(Model.ValidateModelType(null), "ModelType");
            }

            if (Model.IsDataContextSupported)
            {
                foreach (ModelType modelType in Model.DataContextTypes)
                {
                    DataContextTypesInternal.Add(modelType);
                }

                if (model.DataContextType != null)
                {
                    // We have a saved datacontext selection
                    DataContextType     = Model.DataContextType;
                    DataContextTypeName = DataContextType.DisplayName;
                }

                SetValidationMessage(Model.ValidateDataContextType(DataContextType), "DataContextType");
            }

            AddNewDataContextCommand = new RelayCommand(AddNewDataContext);
            SelectLayoutCommand      = new RelayCommand(SelectLayout);

            AsyncInformationIcon = GetInformationIcon();
        }
 protected override object CreateViewModel(ControllerScaffolderModel model)
 {
     throw new NotImplementedException();
 }
示例#9
0
 protected virtual void OnModelCreated(ControllerScaffolderModel model)
 {
     // intentionally empty
 }
示例#10
0
 protected override object CreateViewModel(ControllerScaffolderModel model)
 {
     return(new ControllerScaffolderViewModel(model));
 }
 protected override void OnModelCreated(ControllerScaffolderModel model)
 {
     base.OnModelCreated(model);
     model.IsViewFolderRequired = true;
 }
示例#12
0
 public void RecordControllerTelemetryOptions(CodeGenerationContext context, ControllerScaffolderModel model)
 {
 }
示例#13
0
        public ControllerScaffolderViewModel(ControllerScaffolderModel model)
            : base(model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            Model = model;

            ControllerName = model.ControllerName;
            IsAsyncSelected = model.IsAsyncSelected;
            SetValidationMessage(Model.ValidateControllerName(ControllerName), "ControllerName");

            IsViewGenerationSupported = Model.IsViewGenerationSupported;
            if (IsViewGenerationSupported)
            {
                IsViewGenerationSelected = Model.IsViewGenerationSelected;
                IsLayoutPageSelected = Model.IsLayoutPageSelected;
                IsReferenceScriptLibrariesSelected = Model.IsReferenceScriptLibrariesSelected;
                LayoutPageFile = model.LayoutPageFile;
            }

            DataContextTypesInternal = new ObservableCollection<ModelType>();
            ModelTypesInternal = new ObservableCollection<ModelType>();

            // The CustomSort here will ensure that the <Add new> item stays at the top. Custom Sort
            // is mutually exclusive with the use of SortDescriptions.
            DataContextTypes = new ListCollectionView(DataContextTypesInternal);
            DataContextTypes.CustomSort = new DataContextModelTypeComparer();

            ModelTypes = CollectionViewSource.GetDefaultView(ModelTypesInternal);
            ModelTypes.SortDescriptions.Add(new SortDescription("ShortTypeName", ListSortDirection.Ascending));

            IsModelClassSupported = Model.IsModelClassSupported;
            IsDataContextSupported = Model.IsDataContextSupported;

            if (Model.IsModelClassSupported)
            {
                foreach (ModelType modelType in Model.ModelTypes)
                {
                    ModelTypesInternal.Add(modelType);
                }

                SetValidationMessage(Model.ValidateModelType(null), "ModelType");
            }

            if (Model.IsDataContextSupported)
            {
                foreach (ModelType modelType in Model.DataContextTypes)
                {
                    DataContextTypesInternal.Add(modelType);
                }

                if (model.DataContextType != null)
                {
                    // We have a saved datacontext selection
                    DataContextType = Model.DataContextType;
                    DataContextTypeName = DataContextType.DisplayName;
                }

                SetValidationMessage(Model.ValidateDataContextType(DataContextType), "DataContextType");
            }

            AddNewDataContextCommand = new RelayCommand(AddNewDataContext);
            SelectLayoutCommand = new RelayCommand(SelectLayout);

            AsyncInformationIcon = GetInformationIcon();
        }