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
bbd6632
commit 5d3af68
Showing
23 changed files
with
208 additions
and
204 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
27 changes: 27 additions & 0 deletions
27
experiments/Azure.Experiments/Azure.Experiments/GetInfoContext.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,27 @@ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public sealed class GetInfoContext : IGetInfoContext | ||
{ | ||
public Context Context { get; } | ||
|
||
public GetInfoContext(Context context) | ||
{ | ||
Context = context; | ||
} | ||
|
||
public async Task<T> GetOrAdd<T>( | ||
ResourceParameters<T> parameters, Func<Task<T>> get) | ||
where T : class | ||
{ | ||
var result = await Map.GetOrAdd(parameters, async _ => await get()); | ||
return (T)result; | ||
} | ||
|
||
private ConcurrentDictionary<ResourceParameters, Task<object>> Map { get; } | ||
= new ConcurrentDictionary<ResourceParameters, Task<object>>(); | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
experiments/Azure.Experiments/Azure.Experiments/GetParameters.cs
This file was deleted.
Oops, something went wrong.
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
13 changes: 13 additions & 0 deletions
13
experiments/Azure.Experiments/Azure.Experiments/IGetInfoContext.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,13 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public interface IGetInfoContext | ||
{ | ||
Context Context { get; } | ||
|
||
Task<Info> GetOrAdd<Info>(ResourceParameters<Info> parameters, Func<Task<Info>> getOrThrow) | ||
where Info : class; | ||
} | ||
} |
11 changes: 0 additions & 11 deletions
11
experiments/Azure.Experiments/Azure.Experiments/IGetParameters.cs
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
experiments/Azure.Experiments/Azure.Experiments/ManagedResourceParameters.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,25 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Azure.Experiments | ||
{ | ||
/// <summary> | ||
/// Managed resource parameters. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class ManagedResourceParameters<T> : ResourceParameters<T> | ||
where T : class | ||
{ | ||
public abstract ResourceGroupParameters ResourceGroup { get; } | ||
|
||
public abstract IEnumerable<ResourceParameters> ResourceDependencies { get; } | ||
|
||
public sealed override bool HasCommonLocation => true; | ||
|
||
/// <summary> | ||
/// Resource dependencies and a resource group. | ||
/// </summary> | ||
public sealed override IEnumerable<ResourceParameters> Dependencies | ||
=> ResourceDependencies.Concat(new[] { ResourceGroup }); | ||
} | ||
} |
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
14 changes: 10 additions & 4 deletions
14
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
using Microsoft.Azure.Management.Network.Models; | ||
using System.Threading.Tasks; | ||
using Microsoft.Azure.Management.Network.Models; | ||
using Microsoft.Azure.Management.Network; | ||
|
||
namespace Microsoft.Azure.Experiments.Network | ||
{ | ||
public abstract class NetworkParameters<T> : ResourceParameters<T> | ||
public abstract class NetworkParameters<T> : ManagedResourceParameters<T> | ||
where T : Resource | ||
{ | ||
public sealed override string GetLocation(T value) | ||
=> value.Location; | ||
public sealed override string GetLocation(T value) => value.Location; | ||
|
||
protected sealed override Task<T> GetAsync(IGetInfoContext context) | ||
=> GetAsync(context.Context.CreateNetworkManagementClient()); | ||
|
||
protected abstract Task<T> GetAsync(NetworkManagementClient client); | ||
} | ||
} |
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
Oops, something went wrong.