Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added source/.DS_Store
Binary file not shown.
35 changes: 17 additions & 18 deletions source/Server.Extensibility/HostServices/Model/PackageReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public class PackageReference : IId, INamed
/// </summary>
/// <param name="name">The package-reference name.</param>
/// <param name="packageId">The package ID or a variable-expression</param>
/// <param name="feedIdOrName">The feed ID or a variable-expression</param>
/// <param name="feedId">The feed ID or a variable-expression</param>
/// <param name="acquisitionLocation">The location the package should be acquired</param>
public PackageReference(string? name, string packageId, FeedIdOrName feedIdOrName, PackageAcquisitionLocation acquisitionLocation)
: this(name, packageId, feedIdOrName, acquisitionLocation.ToString())
public PackageReference(string? name, string packageId, FeedId feedId, PackageAcquisitionLocation acquisitionLocation)
: this(name, packageId, feedId, acquisitionLocation.ToString())
{
}

Expand All @@ -40,14 +40,14 @@ public PackageReference(string? name, string packageId, FeedIdOrName feedIdOrNam
/// </summary>
/// <param name="name">The package-reference name.</param>
/// <param name="packageId">The package ID or a variable-expression</param>
/// <param name="feedIdOrName">The feed ID or a variable-expression</param>
/// <param name="feedId">The feed ID or a variable-expression</param>
/// <param name="acquisitionLocation">The location the package should be acquired.
/// May be one <see cref="PackageAcquisitionLocation" /> or a variable-expression.</param>
public PackageReference(string? name, string packageId, FeedIdOrName feedIdOrName, string acquisitionLocation)
public PackageReference(string? name, string packageId, FeedId feedId, string acquisitionLocation)
: this(null,
name,
packageId,
feedIdOrName,
feedId,
acquisitionLocation)
{
}
Expand All @@ -59,39 +59,39 @@ public PackageReference(string? name, string packageId, FeedIdOrName feedIdOrNam
public PackageReference(string? id,
string? name,
string packageId,
FeedIdOrName feedIdOrName,
FeedId feedId,
string acquisitionLocation)
: this()
{
if (!string.IsNullOrEmpty(id)) Id = id;

PackageId = packageId;
FeedIdOrName = feedIdOrName;
FeedId = feedId;
AcquisitionLocation = acquisitionLocation;
Name = name ?? string.Empty;
}

/// <summary>
/// Constructs a primary package (an un-named package reference)
/// </summary>
public PackageReference(string packageId, FeedIdOrName feedIdOrName, PackageAcquisitionLocation acquisitionLocation)
: this(null, packageId, feedIdOrName, acquisitionLocation)
public PackageReference(string packageId, FeedId feedId, PackageAcquisitionLocation acquisitionLocation)
: this(null, packageId, feedId, acquisitionLocation)
{
}

/// <summary>
/// Constructs a primary package (an un-named package reference)
/// </summary>
public PackageReference(string packageId, FeedIdOrName feedIdOrName, string acquisitionLocation)
: this(null, packageId, feedIdOrName, acquisitionLocation)
public PackageReference(string packageId, FeedId feedId, string acquisitionLocation)
: this(null, packageId, feedId, acquisitionLocation)
{
}

/// <summary>
/// Constructs a primary package (an un-named package reference)
/// </summary>
public PackageReference(string packageId, FeedIdOrName feedIdOrName)
: this(packageId, feedIdOrName, PackageAcquisitionLocation.Server)
public PackageReference(string packageId, FeedId feedId)
: this(packageId, feedId, PackageAcquisitionLocation.Server)
{
}

Expand All @@ -110,7 +110,7 @@ public PackageReference()
{
Id = Guid.NewGuid().ToString();
Properties = new Dictionary<string, string>();
FeedIdOrName = "feeds-builtin".ToFeedIdOrName();
FeedId = "feeds-builtin".ToFeedId();
}

public string Id { get; }
Expand All @@ -132,9 +132,8 @@ public PackageReference()
/// <summary>
/// Feed ID, name or a variable-expression
/// </summary>
[JsonProperty("FeedId")] // This is named FeedId for backward-compatibility as we don't yet want to change the underlying database JSON/schema.
[OclName("feed")]
public FeedIdOrName FeedIdOrName { get; set; }
public FeedId FeedId { get; set; }

/// <summary>
/// The package-acquisition location.
Expand All @@ -160,7 +159,7 @@ public PackageReference Clone()
return new PackageReference(Id,
Name,
PackageId,
FeedIdOrName,
FeedId,
AcquisitionLocation)
{
Properties = new Dictionary<string, string>(Properties),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,5 @@ public IResult<PackageReference> TryGetById(string id)
{
return idMap.ContainsKey(id) ? (IResult<PackageReference>)Result<PackageReference>.Success(idMap[id]) : Result<PackageReference>.Failed("Id not found");
}

public IResult<PackageReference> TryGetByIdOrName(string idOrName)
{
var result = TryGetById(idOrName);
if (result is Result<PackageReference>)
return result;

result = TryGetByName(idOrName);
return result;
}
}
}