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
ccb9d0e
commit a4aeca6
Showing
10 changed files
with
121 additions
and
16 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
experiments/Azure.Experiments/Azure.Experiments/ChildResourceConfig.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,42 @@ | ||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public interface IChildResourceConfig | ||
{ | ||
} | ||
|
||
public interface IChildResourceConfig<Info> : IChildResourceConfig | ||
{ | ||
} | ||
|
||
public static class ChildResourceConfig | ||
{ | ||
public static ChildResourceConfig<Info, ParentInfo> CreateConfig<Info, ParentInfo>( | ||
this ChildResourcePolicy<Info, ParentInfo> policy, | ||
ResourceConfig<ParentInfo> parent, | ||
string name) | ||
where Info : class | ||
where ParentInfo : class | ||
=> new ChildResourceConfig<Info, ParentInfo>(policy, parent, name); | ||
} | ||
|
||
public sealed class ChildResourceConfig<Info, ParentInfo> : IChildResourceConfig<Info> | ||
where Info : class | ||
where ParentInfo : class | ||
{ | ||
public ChildResourcePolicy<Info, ParentInfo> Policy { get; } | ||
|
||
public ResourceConfig<ParentInfo> Parent { get; } | ||
|
||
public string Name { get; } | ||
|
||
public ChildResourceConfig( | ||
ChildResourcePolicy<Info, ParentInfo> policy, | ||
ResourceConfig<ParentInfo> parent, | ||
string name) | ||
{ | ||
Policy = policy; | ||
Parent = parent; | ||
Name = name; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
experiments/Azure.Experiments/Azure.Experiments/ChildResourcePolicy.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,30 @@ | ||
using System; | ||
|
||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public static class ChildResourcePolicy | ||
{ | ||
public static ChildResourcePolicy<Info, ParentInfo> Create<Info, ParentInfo>( | ||
Func<ParentInfo, string, Info> get, | ||
Action<ParentInfo, Info> set) | ||
where Info : class | ||
where ParentInfo : class | ||
=> new ChildResourcePolicy<Info, ParentInfo>(get, set); | ||
} | ||
|
||
public sealed class ChildResourcePolicy<Info, ParentInfo> | ||
where Info : class | ||
where ParentInfo : class | ||
{ | ||
public Func<ParentInfo, string, Info> Get { get; } | ||
|
||
public Action<ParentInfo, Info> Set { get; } | ||
|
||
public ChildResourcePolicy( | ||
Func<ParentInfo, string, Info> get, Action<ParentInfo, Info> set) | ||
{ | ||
Get = get; | ||
Set = set; | ||
} | ||
} | ||
} |
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: 17 additions & 0 deletions
17
experiments/Azure.Experiments/Azure.Experiments/Network/SubnetPolicy.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,17 @@ | ||
using Microsoft.Azure.Management.Network.Models; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Azure.Experiments.Network | ||
{ | ||
public static class SubnetPolicy | ||
{ | ||
public static ChildResourcePolicy<Subnet, VirtualNetwork> Policy { get; } | ||
= ChildResourcePolicy.Create<Subnet, VirtualNetwork>( | ||
(p, name) => p.Subnets.FirstOrDefault(s => s.Name == name), | ||
(p, subnet) => p.Subnets = p.Subnets.Concat(new[] { subnet }).ToArray()); | ||
|
||
public static ChildResourceConfig<Subnet, VirtualNetwork> CreateSubnetConfig( | ||
ResourceConfig<VirtualNetwork> virtualNetwork, string name) | ||
=> Policy.CreateConfig(virtualNetwork, 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
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