public ControllerScaffolder(ScaffolderArgs args, string controllerTypeArgument)
        {
            var defaultNamespace = args.ParentFolder.Combine("file.cs");

            DefaultArgs.Add(
                new CommandLineArg("--controllerNamespace", args.Project.GetDefaultNamespace(defaultNamespace))
                );

            if (controllerTypeArgument != null)
            {
                DefaultArgs.Add(new CommandLineArg(controllerTypeArgument));
            }
        }
Esempio n. 2
0
        public void ApiControllerWithActionsScaffolder()
        {
            var args = new ScaffolderArgs();

            args.ParentFolder = "/MyProject/Controllers";
            using var project = CreateProject();
            args.Project      = project;
            var scaffolder = new ApiControllerWithActionsScaffolder(args);

            args.Scaffolder = scaffolder;
            var wizard          = CreateWizard(args, project);
            var commandLineArgs = wizard.GetArguments(args);

            commandLineArgs = Regex.Replace(commandLineArgs, @"\s+", " ").TrimEnd();
            Assert.AreEqual(@"aspnet-codegenerator --project ""ProjectName.csproj"" controller -name --no-build -outDir ""/MyProject/Controllers"" --controllerNamespace ProjectName --restWithNoViews --readWriteActions", commandLineArgs);
        }
Esempio n. 3
0
        public void RazorPageScaffolder()
        {
            var args = new ScaffolderArgs();

            args.ParentFolder = "/MyProject/Pages";
            using var project = CreateProject();
            args.Project      = project;
            var scaffolder = new RazorPageScaffolder(args);

            args.Scaffolder = scaffolder;
            scaffolder.GetField("Name of the Razor Page:").SelectedValue = "PageName";
            var wizard          = CreateWizard(args, project);
            var commandLineArgs = wizard.GetArguments(args);

            commandLineArgs = Regex.Replace(commandLineArgs, @"\s+", " ");
            Assert.AreEqual(@"aspnet-codegenerator --project ""ProjectName.csproj"" razorpage PageName Empty --referenceScriptLibraries --no-build -outDir ""/MyProject/Pages"" --namespaceName ProjectName", commandLineArgs);
        }
Esempio n. 4
0
        public void EmptyMvcControllerScaffolder()
        {
            var args = new ScaffolderArgs();

            args.ParentFolder = "/MyProject/Controllers";
            using var project = CreateProject();
            args.Project      = project;
            var scaffolder = new EmptyMvcControllerScaffolder(args);

            args.Scaffolder = scaffolder;
            scaffolder.GetField("Controller name:").SelectedValue = "ControllerName";
            var wizard          = CreateWizard(args, project);
            var commandLineArgs = wizard.GetArguments(args);

            commandLineArgs = Regex.Replace(commandLineArgs, @"\s+", " ");
            Assert.AreEqual(@"aspnet-codegenerator --project ""ProjectName.csproj"" controller -name ControllerName --no-build -outDir ""/MyProject/Controllers"" --controllerNamespace ProjectName", commandLineArgs);
        }
Esempio n. 5
0
        public void ApiControllerEntityFrameworkScaffolder()
        {
            var args = new ScaffolderArgs();

            args.ParentFolder = "/MyProject/Controllers";
            using var project = CreateProject();
            args.Project      = project;
            var scaffolder = new ApiControllerEntityFrameworkScaffolder(args);

            args.Scaffolder = scaffolder;
            scaffolder.GetField("Model class to use:").SelectedValue     = "ModelClass";
            scaffolder.GetField("DbContext class to use:").SelectedValue = "DataContext";
            var wizard          = CreateWizard(args, project);
            var commandLineArgs = wizard.GetArguments(args);

            commandLineArgs = Regex.Replace(commandLineArgs, @"\s+", " ").TrimEnd();
            Assert.AreEqual(@"aspnet-codegenerator --project ""ProjectName.csproj"" controller --model ModelClass --dataContext DataContext -name --no-build -outDir ""/MyProject/Controllers"" --controllerNamespace ProjectName", commandLineArgs);
        }
Esempio n. 6
0
        public void RazorPageEntityFrameworkCrudScaffolder()
        {
            var args = new ScaffolderArgs();

            args.ParentFolder = "/MyProject/Pages";
            using var project = CreateProject();
            args.Project      = project;
            var scaffolder = new RazorPageEntityFrameworkCrudScaffolder(args);

            args.Scaffolder = scaffolder;
            // no name field
            scaffolder.GetField("Model class to use:").SelectedValue     = "ModelClass";
            scaffolder.GetField("DbContext class to use:").SelectedValue = "DataContext";
            var wizard          = CreateWizard(args, project);
            var commandLineArgs = wizard.GetArguments(args);

            commandLineArgs = Regex.Replace(commandLineArgs, @"\s+", " ");
            Assert.AreEqual(@"aspnet-codegenerator --project ""ProjectName.csproj"" razorpage --model ModelClass --dataContext DataContext --referenceScriptLibraries --no-build -outDir ""/MyProject/Pages"" --namespaceName ProjectName", commandLineArgs);
        }
        public void Scaffold()
        {
            var project = IdeApp.ProjectOperations.CurrentSelectedProject as DotNetProject;

            if (project == null)
            {
                return;
            }

            var    folder       = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder;
            string parentFolder = folder?.Path ?? project.BaseDirectory;

            Xwt.Toolkit.NativeEngine.Invoke(() => {
                var args          = new ScaffolderArgs();
                var selectionPage = new ScaffolderTemplateSelectPage(args);

                var w   = new ScaffolderWizard(project, parentFolder, selectionPage, args);
                var res = w.RunWizard();
            });
        }
Esempio n. 8
0
        static ScaffolderWizard CreateWizard(ScaffolderArgs args, DotNetProject project)
        {
            var selectPage = new ScaffolderTemplateSelectPage(args);

            return(new ScaffolderWizard(project, args.ParentFolder, selectPage, args));
        }
 public ControllerScaffolder(ScaffolderArgs args) : this(args, null)
 {
 }