Ejemplo n.º 1
0
        public Project CreateProject()
        {
            var project  = locatorService.Locate <Project>();
            var document = CreateDocument();

            project.Documents.Add(document);
            project.SelectedDocument = document;
            return(project);
        }
Ejemplo n.º 2
0
        public static CommandLineBuilder Configure(this CommandLineBuilder builder, ILocatorService container)
        {
            var project  = new Option <string>("--project", GetDefaultProject);
            var authType = new Option <AuthType>("--auth-type", "Authentication")
            {
                Required = true
            };
            var auth    = new Option <string>("--auth", "Authentication string");
            var profile = new Argument <string>("profile");
            var verbose = new Option <bool>("--verbose", () => false);

            var configureCommand = new Command("configure")
            {
                profile,
                project,
                authType,
                auth,
                verbose
            };

            configureCommand.Handler = CommandHandler.Create <ProfileCreationOptions>(options =>
            {
                var creator = container.Locate <ProfileCreationUnit>(options);
                return(creator.Create());
            });

            var deployCommand = new Command("deploy")
            {
                profile,
                project,
                authType,
                auth,
                new Option <string>("--configuration", () => "Debug", "Build configuration"),
                verbose
            };

            deployCommand.Handler = CommandHandler.Create <DeploymentOptions>(async options =>
            {
                var deploymentRequest = container.Locate <DeploymentUnit>(options);
                var deploy            = await deploymentRequest.Deploy();
                if (deploy.IsFailure)
                {
                    Log.Error($"Deployment failed {deploy.Error}");
                }
            });

            builder.AddCommand(configureCommand);
            builder.AddCommand(deployCommand);
            return(builder);
        }
Ejemplo n.º 3
0
        private bool CreateDatabase(ILocatorService scope)
        {
            var databaseManager = scope.Locate <DatabaseManager>();

            try {
                databaseManager.CreateAndConnectNewDatabase("./db.s3db");
                return(true);
            }
            catch (Exception e) {
                Logger.Log(LogLevel.Error, e);
                return(false);
            }
        }
Ejemplo n.º 4
0
        private async Task <bool> ConnectDatabase(ILocatorService scope, string path)
        {
            var databaseManager = scope.Locate <DatabaseManager>();

            try {
                await databaseManager.Connect(path);

                return(true);
            }
            catch (Exception) {
                return(false);
            }
        }
Ejemplo n.º 5
0
        private object ConvertParam(Type paramType, object value)
        {
            if (paramType == typeof(string))
            {
                if (value == null)
                {
                    throw new InvalidOperationException("Invalid parameters provided");
                }

                return(value);
            }

            return(container.Locate(paramType));
        }