Esempio n. 1
0
        private static CloneResult StartOrCreate(CloneConnectionInfo cloneConnectionInfo)
        {
            var rootFolder = PathProvider.Translate(ServerConstants.SERVER_ROOT_FOLDER);
            var baseFolder = PathProvider.Translate(ServerConstants.SERVER_CLONES_FOLDER).EnsureDirectoryExists();
            var clonePath = Path.Combine(baseFolder, cloneConnectionInfo.GetAsFolderName());
            var cloneFolder = PathProvider.Translate(clonePath);
            var cloneFolderInfo = new DirectoryInfo(cloneFolder);

            if (!cloneFolderInfo.Exists)
            {
                cloneFolder.EnsureDirectoryExists();

                var clonePathFile = Path.Combine(cloneFolder, cloneConnectionInfo.GetAsFileName());
                cloneConnectionInfo.WriteTo(clonePathFile);

                foreach (var file in new DirectoryInfo(rootFolder).GetFiles())
                {
                    if (file.Name != ServerConstants.SERVER_STARTUP_FILE)
                    {
                        var cloneFilePath = Path.Combine(cloneFolder, file.Name);
                        file.CopyTo(cloneFilePath);
                    }
                }
            }

            var command = new Command(ServerConstants.SERVER_STARTUP_EXE, new string[0], CommandType.Vanilla);
            command.Execute(cloneFolder, wait: false);
            return CloneResult.Ok(cloneConnectionInfo);
        }
Esempio n. 2
0
 public CommandResult(Command command)
 {
     this.command = command;
 }
Esempio n. 3
0
 public Session Load(Command command)
 {
     commands.Add(command);
     return this;
 }