-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for specifying column variants in a ColumnConfiguration (#…
…379) * Add support for specifying column variants in a ColumnConfiguration * Consolidate ctors * Fix typo * Refactor upgrade logic * Rename namespace to Latest * Add typecast to while loop * Remove cycle check * Add check to PreviousPrebuiltConfigurationBase
- Loading branch information
Showing
17 changed files
with
335 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Microsoft.Performance.SDK.Runtime/DTO/PreviousPrebuiltConfigurationBase`1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Microsoft.Performance.SDK.Runtime.DTO; | ||
|
||
[DataContract] | ||
internal abstract class PreviousPrebuiltConfigurationBase<TNext> | ||
: PrebuiltConfigurationsBase, | ||
ISupportUpgrade<PrebuiltConfigurationsBase> | ||
where TNext : PrebuiltConfigurationsBase | ||
{ | ||
public PrebuiltConfigurationsBase Upgrade() | ||
{ | ||
var next = UpgradeToNext(); | ||
if (next.Version <= this.Version) | ||
{ | ||
throw new InvalidOperationException( | ||
$"Cannot upgrade to a version less than or equal to the current version. Current version: {this.Version}, Next version: {next.Version}"); | ||
} | ||
|
||
return next; | ||
} | ||
|
||
/// <summary> | ||
/// Upgrade the current configuration to the next version. The version number | ||
/// of the returned configuration MUST be greater than this instance's version number. | ||
/// </summary> | ||
/// <returns> | ||
/// The upgraded configuration. | ||
/// </returns> | ||
protected abstract TNext UpgradeToNext(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Microsoft.Performance.SDK.Runtime/DTO/V1_0/ColumnConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Runtime.Serialization; | ||
|
||
namespace Microsoft.Performance.SDK.Runtime.DTO.V1_0 | ||
{ | ||
[DataContract] | ||
internal class ColumnConfiguration | ||
: ISupportUpgrade<Latest.ColumnConfiguration> | ||
{ | ||
/// <summary> | ||
/// Metadata describing the column. | ||
/// </summary> | ||
[DataMember] | ||
public ColumnMetadata Metadata { get; set; } | ||
|
||
/// <summary> | ||
/// UI hints for displaying the column. | ||
/// </summary> | ||
[DataMember] | ||
public UIHints DisplayHints { get; set; } | ||
|
||
public Latest.ColumnConfiguration Upgrade() | ||
{ | ||
return new Latest.ColumnConfiguration() | ||
{ | ||
Metadata = this.Metadata, | ||
VariantGuid = null, | ||
DisplayHints = this.DisplayHints, | ||
}; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Microsoft.Performance.SDK.Runtime/DTO/V1_0/PrebuiltConfigurations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Linq; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Microsoft.Performance.SDK.Runtime.DTO.V1_0 | ||
{ | ||
[DataContract] | ||
internal class PrebuiltConfigurations | ||
: PreviousPrebuiltConfigurationBase<Latest.PrebuiltConfigurations> | ||
{ | ||
internal static readonly double DTOVersion = 1.0; | ||
|
||
public PrebuiltConfigurations() | ||
{ | ||
this.Version = DTOVersion; | ||
} | ||
|
||
[DataMember(Order = 2)] | ||
public TableConfigurations[] Tables { get; set; } | ||
|
||
protected override Latest.PrebuiltConfigurations UpgradeToNext() | ||
{ | ||
return new Latest.PrebuiltConfigurations() | ||
{ | ||
Tables = this.Tables.Select(configs => configs.Upgrade()).ToArray() | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.