/// <summary> /// Creates an activity that sends an HTTP Request /// </summary> /// <param name="setup">Sets the properties of the SendHttpRequest activity</param> /// <returns>The <see cref="IActivityBuilder"/> with the <see cref="Http.SendHttpRequest"/> activity built onto it.</returns> /// <inheritdoc cref="BuilderExtensions.Then{T}(IBuilder, Action{ISetupActivity{T}}?, Action{IActivityBuilder}?, int, string?)"/> public static IActivityBuilder SendHttpRequest( this IActivityBuilder builder, Action <ISetupActivity <SendHttpRequest> > setup, Action <IActivityBuilder>?activity = default, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string?sourceFile = default) => builder.Then(setup, activity, lineNumber, sourceFile);
public static IActivityBuilder AddMigrationAndUpdateDatabaseWorkflow(this IActivityBuilder builder) { return(builder .Then <FileFinderStep>( step => { step.SearchFileName = new LiteralExpression("*.EntityFrameworkCore.DbMigrations.csproj"); step.ResultVariableName = new LiteralExpression("MigrationProjectFile"); } ) .Then <FileFinderStep>( step => { step.SearchFileName = new LiteralExpression("*.Web.csproj"); step.ResultVariableName = new LiteralExpression <string>("WebProjectFile"); } ) /* Add migration */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>("`dotnet ef migrations add Added${EntityInfo.Name} -p \"${MigrationProjectFile}\" -s \"${WebProjectFile}\"`") ) /* Update database */ .Then <RunCommandStep>( step => step.Command = new JavaScriptExpression <string>("`dotnet ef database update -p \"${MigrationProjectFile}\" -s \"${WebProjectFile}\"`") ) ); }
public static IActivityBuilder AddEfCoreConfigurationWorkflow(this IActivityBuilder builder) { return(builder /* Add entity property to DbContext */ .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}DbContext.cs`"); }) .Then <TextGenerationStep>(step => { step.TemplateName = "DbContext_Property"; }) .Then <DbContextStep>() .Then <FileModifierStep>() /* Add entity configuration to DbContextModelCreatingExtensions */ .Then <TextGenerationStep>(step => { step.TemplateName = "DbContextModelCreatingExtensions_Using"; step.GeneratedTextKey = new LiteralExpression("ModelingUsingText"); }) .Then <TextGenerationStep>(step => { step.TemplateName = "DbContextModelCreatingExtensions_EntityConfig"; step.GeneratedTextKey = new LiteralExpression("EntityConfigText"); }) .Then <FileFinderStep>( step => step.SearchFileName = new LiteralExpression("*DbContextModelCreatingExtensions.cs") ) .Then <DbContextModelCreatingExtensionsStep>() .Then <FileModifierStep>() ); }
public static IActivityBuilder AddEfCoreConfigurationWorkflow(this IActivityBuilder builder) { return(builder /* Add entity property to DbContext class*/ .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}DbContext.cs`"); }) .Then <DbContextClassStep>() .Then <FileModifierStep>() .IfElse( step => step.ConditionExpression = new JavaScriptExpression <bool>("ProjectInfo.TemplateType == 1"), ifElse => { // For module, we also need to modify the IDbContext interface */ ifElse .When(OutcomeNames.True) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("`I${ProjectInfo.Name}DbContext.cs`"); }) .Then <DbContextInterfaceStep>() .Then <FileModifierStep>() .Then("DbContextModel") ; ifElse .When(OutcomeNames.False) .Then("DbContextModel") ; } ) /* Add entity configuration to DbContextModelCreatingExtensions */ .Then <FileFinderStep>( step => step.SearchFileName = new LiteralExpression("*DbContextModelCreatingExtensions.cs") ).WithName("DbContextModel") .Then <DbContextModelCreatingExtensionsStep>() .Then <FileModifierStep>() ); }
public static IActivityBuilder AddTestGenerationWorkflow(this IActivityBuilder builder) { return(builder /* Generate test files */ .Then <TemplateGroupGenerationStep>( step => { step.GroupName = "Test"; } ) ); }
public static IActivityBuilder InitRequiredVariable(this IActivityBuilder builder) { var appDir = AppDomain.CurrentDomain.BaseDirectory; return(builder.Then <SetVariable>(step => { step.VariableName = "TemplateDirectory"; step.ValueExpression = new LiteralExpression(Path.Combine(appDir, "Templates")); })); }
public static IActivityBuilder SetStartupDirectoryVariable(this IActivityBuilder builder, string directory) { string startupDirectory = GetStartupDirectory(directory); return(builder.Then <SetVariable>(step => { step.VariableName = "StartupDirectory"; step.ValueExpression = new LiteralExpression(startupDirectory); })); }
public static IActivityBuilder AddOverwriteWorkflow(this IActivityBuilder builder) { return(builder .Then <SetVariable>( step => { step.VariableName = CommandConsts.OverwriteVariableName; step.ValueExpression = new JavaScriptExpression <bool>($"!{CommandConsts.OptionVariableName}.{nameof(GenerateCommandOption.NoOverwrite)}"); }) ); }
public static IActivityBuilder AddServiceGenerationWorkflow(this IActivityBuilder builder) { return(builder /* Generate dto, service interface and class files */ .Then <TemplateGroupGenerationStep>( step => { step.GroupName = "Service"; } ) /* Add mapping */ .Then <FileFinderStep>(step => step.SearchFileName = new LiteralExpression("*ApplicationAutoMapperProfile.cs")) .Then <ApplicationAutoMapperProfileStep>() .Then <FileModifierStep>() ); }
public static IActivityBuilder AddUiRazorPagesGenerationWorkflow(this IActivityBuilder builder) { return(builder /* Generate razor pages ui files*/ .Then <TemplateGroupGenerationStep>( step => { step.GroupName = "UIRazor"; } ) /* Add menu */ .Then <FileFinderStep>( step => step.SearchFileName = new LiteralExpression("*MenuContributor.cs") ) .Then <MenuContributorStep>() .Then <FileModifierStep>() /* Add mapping */ .Then <FileFinderStep>( step => step.SearchFileName = new LiteralExpression <string>("*WebAutoMapperProfile.cs") ) .Then <WebAutoMapperProfileStep>() .Then <FileModifierStep>() /* Add localization */ .Then <TextGenerationStep>( step => { step.TemplateName = "Localization"; } ) .Then <MultiFileFinderStep>( step => { step.SearchFileName = new LiteralExpression("*.json"); step.BaseDirectory = new JavaScriptExpression <string>(@"`${BaseDirectory}\\src\\${ProjectInfo.FullName}.Domain.Shared\\Localization`"); } ) .Then <ForEach>( x => { x.CollectionExpression = new JavaScriptExpression <IList <object> >(MultiFileFinderStep.DefaultFileParameterName); }, branch => branch.When(OutcomeNames.Iterate) .Then <LocalizationJsonModificationCreatorStep>( step => { step.TargetFile = new JavaScriptExpression <string>("CurrentValue"); step.LocalizationJson = new JavaScriptExpression <string>(TextGenerationStep.DefaultGeneratedTextParameterName); } ) .Then(branch) ) ); }
public static IActivityBuilder AddEntityUsingGenerationWorkflow(this IActivityBuilder builder, string name) { return(builder .Then <TextGenerationStep>( step => { step.TemplateName = "UsingEntityNamespace"; step.GeneratedTextKey = new LiteralExpression("EntityUsingText"); } ).WithName(name) .Then <TextGenerationStep>( step => { step.TemplateName = "UsingEntityDtoNamespace"; step.GeneratedTextKey = new LiteralExpression("EntityDtoUsingText"); } ) ); }
public static IActivityBuilder AddServiceGenerationWorkflow(this IActivityBuilder builder, string name) { return(builder /* Generate dto, service interface and class files */ .Then <GroupGenerationStep>( step => { step.GroupName = "Service"; step.TargetDirectory = new JavaScriptExpression <string>(VariableNames.AspNetCoreDir); } ).WithName(name) /* Generate permissions */ .IfElse( ifElse => ifElse.ConditionExpression = new JavaScriptExpression <bool>("Option.SkipPermissions"), ifElse => { ifElse .When(OutcomeNames.True) .Then(ActivityNames.AutoMapper) ; ifElse .When(OutcomeNames.False) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}Permissions.cs`"); }) .Then <PermissionsStep>() .Then <FileModifierStep>() .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}PermissionDefinitionProvider.cs`"); }) .Then <PermissionDefinitionProviderStep>() .Then <FileModifierStep>() .Then(ActivityNames.AutoMapper) ; } ) /* Add mapping */ .Then <FileFinderStep>(step => step.SearchFileName = new JavaScriptExpression <string>("`${ProjectInfo.Name}ApplicationAutoMapperProfile.cs`")).WithName(ActivityNames.AutoMapper) .Then <ApplicationAutoMapperProfileStep>() .Then <FileModifierStep>() ); }
public static IActivityBuilder AddConfigureMigrationProjectsWorkflow(this IActivityBuilder builder, string nextActivityName) { return(builder .Then <IfElse>( ifElse => ifElse.ConditionExpression = new JavaScriptExpression <bool>($"{CommandConsts.OptionVariableName}.{nameof(CrudCommandOption.MigrationProjectName)} == null"), ifElse => { ifElse .When(OutcomeNames.True) // No migration project name provided .Then <SetVariable>( step => { step.VariableName = AppMigrationProjectName; step.ValueExpression = new LiteralExpression("*.EntityFrameworkCore.DbMigrations.csproj"); }) .Then <SetVariable>( step => { step.VariableName = ModuleMigrationProjectName; step.ValueExpression = new LiteralExpression("*.HttpApi.Host.csproj"); }) .Then(ActivityNames.SearchFiles) ; ifElse .When(OutcomeNames.False) .Then <SetVariable>( step => { step.VariableName = AppMigrationProjectName; step.ValueExpression = new JavaScriptExpression <string>($"{CommandConsts.OptionVariableName}.{nameof(CrudCommandOption.MigrationProjectName)}"); }) .Then <SetVariable>( step => { step.VariableName = ModuleMigrationProjectName; step.ValueExpression = new JavaScriptExpression <string>($"{CommandConsts.OptionVariableName}.{nameof(CrudCommandOption.MigrationProjectName)}"); }) .Then(ActivityNames.SearchFiles) ; } ) .Then <IfElse>( ifElse => ifElse.ConditionExpression = new JavaScriptExpression <bool> ($"ProjectInfo.TemplateType == {TemplateType.Application:D}"), ifElse => { // Application ifElse .When(OutcomeNames.True) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>(AppMigrationProjectName); step.ResultVariableName = new LiteralExpression(MigrationProjectFile); } ) .Then <IfElse>( ie => ie.ConditionExpression = new JavaScriptExpression <bool> ($"ProjectInfo.UiFramework == {UiFramework.RazorPages:D}"), ie => { ie.When(OutcomeNames.True) .Then <FileFinderStep>( step => { step.SearchFileName = new LiteralExpression("*.Web.csproj"); step.ResultVariableName = new LiteralExpression <string>(StartupProjectFile); }) .Then(nextActivityName) ; }) .Then <IfElse>( ie => ie.ConditionExpression = new JavaScriptExpression <bool> ($"ProjectInfo.UiFramework == {UiFramework.None:D}"), ie => { ie.When(OutcomeNames.True) .Then <FileFinderStep>( step => { step.SearchFileName = new LiteralExpression("*.DbMigrator.csproj"); step.ResultVariableName = new LiteralExpression <string>(StartupProjectFile); }) .Then(nextActivityName) ; }); // Module ifElse .When(OutcomeNames.False) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>(ModuleMigrationProjectName); step.ResultVariableName = new LiteralExpression(MigrationProjectFile); } ) .Then <FileFinderStep>( step => { step.SearchFileName = new JavaScriptExpression <string>(ModuleMigrationProjectName); // For module, the startup project is same with the migration project step.ResultVariableName = new LiteralExpression <string>(StartupProjectFile); } ) .Then(nextActivityName) ; } ).WithName(ActivityNames.SearchFiles) ); }
public static IActivityBuilder WatchDirectory(this IActivityBuilder builder, Action <ISetupActivity <WatchDirectory> > setup, [CallerLineNumber] int lineNumber = default, [CallerFilePath] string?sourceFile = default) => builder.Then(setup, null, lineNumber, sourceFile);
public static IActivityBuilder Fork(this IActivityBuilder activityBuilder, Action <Fork> setup = null, Action <IActivityBuilder> branch = null, string name = default) { return(activityBuilder.Then(setup, branch, name)); }