From bc0bfb1534ef4539e63cd96598006edd53712f4b Mon Sep 17 00:00:00 2001 From: "Denis Kuzmin [ GitHub/3F ]" Date: Thu, 9 Jul 2020 21:02:14 +0300 Subject: [PATCH] Draft of IPackagesConfig & IPackageInfo --- MvsSln/Projects/IPackageInfo.cs | 51 ++++++++ MvsSln/Projects/IPackagesConfig.cs | 179 +++++++++++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 MvsSln/Projects/IPackageInfo.cs create mode 100644 MvsSln/Projects/IPackagesConfig.cs diff --git a/MvsSln/Projects/IPackageInfo.cs b/MvsSln/Projects/IPackageInfo.cs new file mode 100644 index 0000000..c4bf21a --- /dev/null +++ b/MvsSln/Projects/IPackageInfo.cs @@ -0,0 +1,51 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013-2020 Denis Kuzmin < x-3F@outlook.com > GitHub/3F + * Copyright (c) MvsSln contributors: https://github.com/3F/MvsSln/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. +*/ + +using System.Collections.Generic; + +namespace net.r_eg.MvsSln.Projects +{ + public interface IPackageInfo + { + /// + /// Package id. + /// + string Id { get; } + + /// + /// Package version. + /// + string Version { get; } + + /// + /// Some related package meta information. + /// Eg.: + /// * targetFramework="net472" + /// * output="vsSolutionBuildEvent" + /// ... + /// + IDictionary Meta { get; } + } +} \ No newline at end of file diff --git a/MvsSln/Projects/IPackagesConfig.cs b/MvsSln/Projects/IPackagesConfig.cs new file mode 100644 index 0000000..cc932fd --- /dev/null +++ b/MvsSln/Projects/IPackagesConfig.cs @@ -0,0 +1,179 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2013-2020 Denis Kuzmin < x-3F@outlook.com > GitHub/3F + * Copyright (c) MvsSln contributors: https://github.com/3F/MvsSln/graphs/contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. +*/ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Security; + +namespace net.r_eg.MvsSln.Projects +{ + public interface IPackagesConfig + { + /// + /// Use auto-commit for each adding/updating/removing. + /// + bool AutoCommit { get; set; } + + /// + /// Flag of the new created storage. + /// + bool IsNew { get; } + + /// + /// Get all packages from storage. + /// + IEnumerable GetPackages(); + + /// + /// Get specific package by its id. + /// + /// Package id. Eg. "Conari"; "7z.Libs"; "regXwild"; "MvsSln"; "vsSolutionBuildEvent"; ... + /// + IPackageInfo GetPackage(string id); + + /// + /// Commit changes made by adding/updating/removing. + /// + void Commit(); + + /// + /// Roll back changes made by adding/updating/removing. + /// + void Rollback(); + + /// + /// Load existing storage or create a new one for any failure. + /// Use for other behavior. + /// Use to check the actual state. + /// + /// Path to storage. + /// Chain on itself. + IPackagesConfig LoadOrNew(string path); + + /// + /// Load existing storage. Will throw related exceptions for any failure. + /// Use for other behavior. + /// + /// Path to storage. + /// Chain on itself. + /// + /// + /// + /// + /// + IPackagesConfig Load(string path); + + /// + /// Add package by using instance. + /// Package cannot be added if the same is already exists in active storage. + /// + /// True, if the package has been successfully added. + bool AddPackage(IPackageInfo package); + + /// + /// Add package or Update an existing by using instance. + /// + /// True, if the package has been added. False, if the package has been updated. + bool AddOrUpdatePackage(IPackageInfo package); + + /// + /// Update an existing package by using instance. + /// + /// True, if the package has been successfully updated. False, if the package does not exist. + bool UpdatePackage(IPackageInfo package); + + /// + /// Add package. + /// Package cannot be added if the same is already exists in active storage. + /// + /// + /// + /// information for `targetFramework` + /// True, if the package has been successfully added. + bool AddPackage(string id, string version, string targetFramework); + + /// + /// Add package or Update an existing. + /// + /// + /// + /// information for `targetFramework` + /// True, if the package has been added. False, if the package has been updated. + bool AddOrUpdatePackage(string id, string version, string targetFramework); + + /// + /// Update an existing package. + /// + /// + /// + /// information for `targetFramework` + /// True, if the package has been successfully updated. False, if the package does not exist. + bool UpdatePackage(string id, string version, string targetFramework); + + /// + /// Add GetNuTool compatible package. + /// https://github.com/3F/GetNuTool + /// + /// + /// + /// information for `output` https://github.com/3F/GetNuTool#format-of-packages-list + /// True, if the package has been successfully added. + bool AddGetNuToolPackage(string id, string version, string output = null); + + /// + /// Add GetNuTool compatible package or Update an existing. + /// https://github.com/3F/GetNuTool + /// + /// + /// + /// information for `output` https://github.com/3F/GetNuTool#format-of-packages-list + /// True, if the package has been added. False, if the package has been updated. + bool AddOrUpdateGetNuToolPackage(string id, string version, string output = null); + + /// + /// Update an existing GetNuTool compatible package. + /// https://github.com/3F/GetNuTool + /// + /// + /// + /// information for `output` https://github.com/3F/GetNuTool#format-of-packages-list + /// True, if the package has been successfully updated. False, if the package does not exist. + bool UpdateGetNuToolPackage(string id, string version, string output = null); + + /// + /// Remove package by using instance. + /// + /// True, if it was successfully deleted. False, if it does not exist. + bool RemovePackage(IPackageInfo pkg); + + /// + /// Remove package. + /// + /// + /// True, if it was successfully deleted. False, if it does not exist. + bool RemovePackage(string id); + } +} \ No newline at end of file