// Copyright (C) Stichting Deltares 2021. All rights reserved. // // This file is part of Riskeer. // // Riskeer is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using Core.Common.Util; using Migration.Scripts.Data.Exceptions; namespace Migration.Scripts.Data { /// /// Class that provides methods for the creating an for a specific version. /// public abstract class CreateScript { private readonly string version; /// /// Creates a new instance of the class. /// /// The version for this . /// Thrown when is empty /// or null. protected CreateScript(string version) { if (string.IsNullOrEmpty(version)) { throw new ArgumentException(@"Version must have a value.", nameof(version)); } this.version = version; } /// /// Creates a new at . /// /// The location to store the . /// A new . /// Thrown when : /// /// is empty or null, /// consists out of only whitespace characters, /// contains an invalid character, /// ends with a directory or path separator (empty file name). /// /// Thrown when creating /// failed. /// Creates the file if it does not exist. public IVersionedFile CreateEmptyVersionedFile(string location) { IOUtils.CreateFileIfNotExists(location); return GetEmptyVersionedFile(location); } /// /// Returns the version was created for. /// /// The version. public string GetVersion() { return version; } /// /// Creates a new at . /// /// The location to store the . /// A new . /// The has been verified in . /// Thrown when creating /// failed. protected abstract IVersionedFile GetEmptyVersionedFile(string location); } }