forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc0fb77
commit 7832679
Showing
13 changed files
with
134 additions
and
7 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
15 changes: 15 additions & 0 deletions
15
experiments/Azure.Experiments/Azure.Experiments/DependencyLocation.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,15 @@ | ||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public sealed class DependencyLocation | ||
{ | ||
public string Location { get; } | ||
|
||
public bool IsCommon { get; } | ||
|
||
public DependencyLocation(string location, bool isCommon) | ||
{ | ||
Location = location; | ||
IsCommon = isCommon; | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
experiments/Azure.Experiments/Azure.Experiments/DependencyLocationExtensions.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,38 @@ | ||
using System; | ||
|
||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public static class DependencyLocationExtensions | ||
{ | ||
public static DependencyLocation Best(this DependencyLocation a, DependencyLocation b) | ||
{ | ||
if (a == null) | ||
{ | ||
return b; | ||
} | ||
if (b == null) | ||
{ | ||
return a; | ||
} | ||
|
||
// a != null | ||
// b != null | ||
if (!a.IsCommon) | ||
{ | ||
return b; | ||
} | ||
if (!b.IsCommon) | ||
{ | ||
return a; | ||
} | ||
|
||
// a.IsCommon == true | ||
// b.IsCommon == true | ||
if (a.Location != b.Location) | ||
{ | ||
throw new Exception("dependent resources have different locations"); | ||
} | ||
return a; | ||
} | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
experiments/Azure.Experiments/Azure.Experiments/Network/NetworkParameters.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,20 @@ | ||
using Microsoft.Azure.Management.Network.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Azure.Experiments.Network | ||
{ | ||
public abstract class NetworkParameters<T> : ResourceParameters<T> | ||
where T : Resource | ||
{ | ||
public NetworkParameters( | ||
string name, | ||
ResourceGroupParameters resourceGroup, | ||
IEnumerable<Parameters> dependencies) | ||
: base(name, resourceGroup, dependencies) | ||
{ | ||
} | ||
|
||
public sealed override string GetLocation(T value) | ||
=> value.Location; | ||
} | ||
} |
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
17 changes: 15 additions & 2 deletions
17
experiments/Azure.Experiments/Azure.Experiments/ResourceGroupParameters.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 |
---|---|---|
@@ -1,9 +1,22 @@ | ||
namespace Microsoft.Azure.Experiments | ||
using Microsoft.Azure.Management.ResourceManager; | ||
using Microsoft.Azure.Management.ResourceManager.Models; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public sealed class ResourceGroupParameters : Parameters | ||
public sealed class ResourceGroupParameters : Parameters<ResourceGroup> | ||
{ | ||
public ResourceGroupParameters(string name) : base(name, NoDependencies) | ||
{ | ||
} | ||
|
||
public override bool HasCommonLocation => false; | ||
|
||
public override string GetLocation(ResourceGroup value) | ||
=> value.Location; | ||
|
||
protected override Task<ResourceGroup> GetAsync( | ||
Context context, IGetParameters getParameters) | ||
=> context.CreateResource().ResourceGroups.GetAsync(Name); | ||
} | ||
} |
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