private void ValidateInternal() { InstallationSpec spec; OkButton.Enabled = TryParseFields(out spec); Result = spec; }
/// <exception cref="UnauthorizedAccessException">The caller does not have the required permission. </exception> /// <exception cref="DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception> /// <exception cref="IOException">The storage directory specified by <paramref name="spec" /> is a file.-or-The network name is not known.</exception> /// <exception cref="ArgumentNullException"><paramref name="path" /> is null. </exception> /// <exception cref="ArgumentException"><paramref name="path" /> is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the <see cref="M:System.IO.Path.GetInvalidPathChars" /> method.-or-<paramref name="path" /> is prefixed with, or contains, only a colon character (:).</exception> /// <exception cref="NotSupportedException"><paramref name="path" /> contains a colon character (:) that is not part of a drive label ("C:\").</exception> /// <exception cref="PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters. </exception> public async Task <Installation> CreateStandaloneInstallation(InstallationSpec spec) { var gamePath = Path.Combine(_standaloneInstallationsDirectory, spec.ToString()); Directory.CreateDirectory(gamePath); return(new Installation(spec, gamePath)); }
/// <exception cref="InvalidOperationException">The form being shown is already visible.-or- The form being shown is disabled.-or- The form being shown is not a top-level window.-or- The form being shown as a dialog box is already a modal form.-or-The current process is not running in user interactive mode (for more information, see <see cref="P:System.Windows.Forms.SystemInformation.UserInteractive" />).</exception> public DialogResult ShowDialog() { _form.ShowDialog(); SpecResult = _form.Result; return(_form.Result == null ? DialogResult.Cancel : DialogResult.OK); }
/// <exception cref="ArgumentNullException"><paramref name="spec"/> is <see langword="null" />.</exception> public GameArchiveSpec(InstallationSpec spec, OperatingSystem os) { if (spec == null) { throw new ArgumentNullException("spec"); } Version = spec.Version; Architecture = spec.Architecture; BuildConfiguration = spec.BuildConfiguration; OperatingSystem = os; }
private async Task LoadInstallation(InstallationSpec spec) { if (spec == null) { return; } Installation model; using (await _lock.LockAsync()) model = await _factorio.GetStandaloneInstallation(spec); Installation.Model = model; }
/// <exception cref="UnauthorizedAccessException">The caller does not have the required permission. </exception> /// <exception cref="DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive). </exception> /// <exception cref="IOException">The storage directory specified by <paramref name="spec" /> is a file.-or-The network name is not known.</exception> public async Task <Installation> GetStandaloneInstallation(InstallationSpec spec) { using (await _lock.LockAsync()) { Installation install; if (_installations.TryGetValue(spec, out install)) { return(install); } install = await _installationFactory.CreateStandaloneInstallation(spec); _installations.Add(spec, install); return(install); } }
/// <exception cref="ArgumentNullException"><paramref name="spec"/> or <paramref name="storageDirectory"/> is <see langword="null" />.</exception> internal Installation(InstallationSpec spec, string storageDirectory) { if (spec == null) { throw new ArgumentNullException("spec"); } if (storageDirectory == null) { throw new ArgumentNullException("storageDirectory"); } Spec = spec; _storageDirectory = storageDirectory; _modPackShortcut = ShortcutFile.New(Path.Combine(storageDirectory, "mods")); _savesShortcut = ShortcutFile.New(Path.Combine(storageDirectory, "saves")); _configShortcut = ShortcutFile.New(Path.Combine(storageDirectory, "config")); }
private bool TryParseFields(out InstallationSpec spec) { spec = null; try { var versionStr = string.Format( "{0}.{1}.{2}", VersionMajor.Text, VersionMinor.Text, VersionRevision.Text); var version = VersionNumber.Parse(versionStr); CpuArchitecture cpu; if (CpuArchitecture.SelectedItem as string == "64 Bit") { cpu = Lib.Models.CpuArchitecture.X64; } else if (CpuArchitecture.SelectedItem as string == "32 Bit") { cpu = Lib.Models.CpuArchitecture.X86; } else { return(false); } BuildConfiguration build; if (!Enum.TryParse(BuildConfiguration.SelectedItem as string, out build)) { return(false); } spec = new InstallationSpec(version, cpu, build); return(true); } catch (FormatException) { return(false); } catch (ArgumentException) { return(false); } }
/// <exception cref="DirectoryNotFoundException"><paramref name="path" /> is invalid, such as referring to an unmapped drive. </exception> /// <exception cref="IOException"><paramref name="path" /> is a file name.</exception> /// <exception cref="SecurityException">The caller does not have the required permission. </exception> /// <exception cref="UnauthorizedAccessException">The caller does not have the required permission.</exception> /// <exception cref="PathTooLongException">The specified path, file name, or combined exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.</exception> public IEnumerable <InstallationSpec> EnumerateInstallations() { var installs = new List <InstallationSpec>(); foreach (var dir in Directory.EnumerateDirectories(_installationsDirectory)) { var dirName = Path.GetFileName(dir); try { installs.Add(InstallationSpec.Parse(dirName)); } catch (FormatException) { // :( Could be some random folder created by the user that doesn't follow the naming convention. } } return(installs); }
private string OpenArchiveDialogImpl(InstallationSpec spec) { var os = OperatingSystemEx.CurrentOS; var archiveSpec = new GameArchiveSpec(spec, os); var archiveExtension = GameArchiveSpec.GetArchiveExtension(os); var zipDialog = new OpenFileDialog { AutoUpgradeEnabled = true, CheckFileExists = true, DefaultExt = archiveExtension, SupportMultiDottedExtensions = true, Filter = string.Format("Archive Files (*{0}) | *{0}", archiveExtension) }; if (zipDialog.ShowDialog() != DialogResult.OK) { return(null); } return(zipDialog.FileName); }