using System; using System.Collections.Generic; using JetBrains.Annotations; using NugetForUnity.PackageSource; using UnityEngine; namespace NugetForUnity.Models { /// /// Represents a NuGet package loaded from a local file. /// [Serializable] internal sealed class NugetPackageLocal : NugetPackageV2Base { [SerializeField] [NotNull] private NugetPackageSourceLocal packageSource; [SerializeField] [NotNull] private List versions = new List(); /// /// Initializes a new instance of the class. /// /// The source this package was downloaded with / provided by. public NugetPackageLocal([NotNull] NugetPackageSourceLocal packageSource) { this.packageSource = packageSource; } /// public override List Versions => versions; /// public override INugetPackageSource PackageSource => packageSource; /// /// Creates a new from the given . /// /// The to use to create the . /// The source this package was downloaded with / provided by. /// The newly created . public static NugetPackageLocal FromNuspec(NuspecFile nuspec, NugetPackageSourceLocal packageSource) { var package = new NugetPackageLocal(packageSource); FillFromNuspec(nuspec, package); return package; } /// /// Loads a from the .nupkg file at the given file-path. /// /// The file-path to the .nupkg file to load. /// The source this package was downloaded with / provided by. /// The loaded from the .nupkg file. public static NugetPackageLocal FromNupkgFile(string nupkgFilePath, NugetPackageSourceLocal packageSource) { var package = FromNuspec(NuspecFile.FromNupkgFile(nupkgFilePath), packageSource); package.DownloadUrl = nupkgFilePath; return package; } /// /// Loads a from the .nuspec file at the given file-path. /// /// The file-path to the .nuspec file to load. /// The source this package was downloaded with / provided by. /// The loaded from the .nuspec file. public static NugetPackageLocal FromNuspecFile(string nuspecFilePath, NugetPackageSourceLocal packageSource) { var package = FromNuspec(NuspecFile.Load(nuspecFilePath), packageSource); package.DownloadUrl = nuspecFilePath; return package; } } }