Skip to content

Commit

Permalink
Policy => Strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Nov 15, 2017
1 parent 29af582 commit e37b2a4
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
<Compile Include="IClient.cs" />
<Compile Include="IResourceConfig.cs" />
<Compile Include="IResourceConfigVisitor.cs" />
<Compile Include="IResourcePolicy.cs" />
<Compile Include="IResourceStrategy.cs" />
<Compile Include="IState.cs" />
<Compile Include="NestedResourceConfig.cs" />
<Compile Include="NestedResourcePolicy.cs" />
<Compile Include="NestedResourceStrategy.cs" />
<Compile Include="TargetState.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceConfig.cs" />
<Compile Include="ResourcePolicy.cs" />
<Compile Include="ResourceStrategy.cs" />
<Compile Include="State.cs" />
<Compile Include="StateLocation.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Microsoft.Azure.Commands.Common.Strategies
{
public interface IResourcePolicy
public interface IResourceStrategy
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ namespace Microsoft.Azure.Commands.Common.Strategies
public static class NestedResourceConfig
{
public static NestedResourceConfig<Model, ParentModel> CreateConfig<Model, ParentModel>(
this NestedResourcePolicy<Model, ParentModel> policy,
this NestedResourceStrategy<Model, ParentModel> strategy,
IResourceConfig<ParentModel> parent,
string name,
Func<Model> create)
where Model : class
where ParentModel : class
=> new NestedResourceConfig<Model, ParentModel>(policy, parent, name, create);
=> new NestedResourceConfig<Model, ParentModel>(strategy, parent, name, create);
}

public sealed class NestedResourceConfig<Model, ParentModel> : IResourceConfig<Model>
where Model : class
where ParentModel : class
{
public NestedResourcePolicy<Model, ParentModel> Policy { get; }
public NestedResourceStrategy<Model, ParentModel> Policy { get; }

public string Name { get; }

Expand All @@ -29,7 +29,7 @@ public sealed class NestedResourceConfig<Model, ParentModel> : IResourceConfig<M
public Func<Model> CreateModel { get; }

public NestedResourceConfig(
NestedResourcePolicy<Model, ParentModel> policy,
NestedResourceStrategy<Model, ParentModel> policy,
IResourceConfig<ParentModel> parent,
string name,
Func<Model> createModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

namespace Microsoft.Azure.Commands.Common.Strategies
{
public sealed class NestedResourcePolicy<Model, ParentModel> : IResourcePolicy
public sealed class NestedResourceStrategy<Model, ParentModel> : IResourceStrategy
{
public Func<string, IEnumerable<string>> GetId { get; }

public Func<ParentModel, string, Model> Get { get; }

public Action<ParentModel, string, Model> Set { get; }

public NestedResourcePolicy(
public NestedResourceStrategy(
Func<string, IEnumerable<string>> getId,
Func<ParentModel, string, Model> get,
Action<ParentModel, string, Model> set)
Expand All @@ -22,15 +22,15 @@ public NestedResourcePolicy(
}
}

public static class NestedResourcePolicy
public static class NestedResourceStraegy
{
public static NestedResourcePolicy<Model, ParentModel> Create<Model, ParentModel>(
public static NestedResourceStrategy<Model, ParentModel> Create<Model, ParentModel>(
string header,
Func<ParentModel, string, Model> get,
Action<ParentModel, string, Model> set)
where Model : class
where ParentModel : class
=> new NestedResourcePolicy<Model, ParentModel>(
=> new NestedResourceStrategy<Model, ParentModel>(
name => new[] { header, name},
get,
set);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Azure.Commands.Common.Strategies
public sealed class ResourceConfig<Model> : IResourceConfig<Model>
where Model : class
{
public ResourcePolicy<Model> Policy { get; }
public ResourceStrategy<Model> Policy { get; }

public string ResourceGroupName { get; }

Expand All @@ -19,7 +19,7 @@ public sealed class ResourceConfig<Model> : IResourceConfig<Model>
public IEnumerable<IResourceConfig> Dependencies { get; }

public ResourceConfig(
ResourcePolicy<Model> policy,
ResourceStrategy<Model> policy,
string resourceGroupName,
string name,
Func<string, Model> createModel,
Expand Down Expand Up @@ -49,7 +49,7 @@ public IEnumerable<string> GetId(string subscription)
public static class ResourceConfig
{
public static ResourceConfig<Model> CreateConfig<Model>(
this ResourcePolicy<Model> policy,
this ResourceStrategy<Model> policy,
string resourceGroupName,
string name,
Func<string, Model> createModel = null,
Expand All @@ -63,7 +63,7 @@ public static ResourceConfig<Model> CreateConfig<Model>(
dependencies.EmptyIfNull());

public static ResourceConfig<Model> CreateConfig<Model>(
this ResourcePolicy<Model> policy,
this ResourceStrategy<Model> policy,
ResourceConfig<ResourceGroup> resourceGroup,
string name,
Func<string, Model> createModel = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@

namespace Microsoft.Azure.Commands.Common.Strategies
{
public sealed class ResourcePolicy<Config> : IResourcePolicy
public sealed class ResourceStrategy<Model> : IResourceStrategy
{
public Func<string, IEnumerable<string>> GetId { get; }

public Func<GetAsyncParams<IClient>, Task<Config>> GetAsync { get; }
public Func<GetAsyncParams<IClient>, Task<Model>> GetAsync { get; }

public Func<CreateOrUpdateAsyncParams<IClient, Config>, Task<Config>> CreateOrUpdateAsync { get; }
public Func<CreateOrUpdateAsyncParams<IClient, Model>, Task<Model>> CreateOrUpdateAsync { get; }

public Func<Config, string> GetLocation { get; }
public Func<Model, string> GetLocation { get; }

public Action<Config, string> SetLocation { get; }
public Action<Model, string> SetLocation { get; }

public ResourcePolicy(
public ResourceStrategy(
Func<string, IEnumerable<string>> getId,
Func<GetAsyncParams<IClient>, Task<Config>> getAsync,
Func<CreateOrUpdateAsyncParams<IClient, Config>, Task<Config>> createOrUpdateAsync,
Func<Config, string> getLocation,
Action<Config, string> setLocation)
Func<GetAsyncParams<IClient>, Task<Model>> getAsync,
Func<CreateOrUpdateAsyncParams<IClient, Model>, Task<Model>> createOrUpdateAsync,
Func<Model, string> getLocation,
Action<Model, string> setLocation)
{
GetId = getId;
GetAsync = getAsync;
Expand All @@ -32,19 +32,19 @@ public ResourcePolicy(
}
}

public static class ResourcePolicy
public static class ResourceStrategy
{
public static ResourcePolicy<Config> Create<Config, Client, Operations>(
public static ResourceStrategy<Model> Create<Model, Client, Operations>(
Func<string, IEnumerable<string>> getId,
Func<Client, Operations> getOperations,
Func<GetAsyncParams<Operations>, Task<Config>> getAsync,
Func<CreateOrUpdateAsyncParams<Operations, Config>, Task<Config>> createOrUpdateAsync,
Func<Config, string> getLocation,
Action<Config, string> setLocation)
Func<GetAsyncParams<Operations>, Task<Model>> getAsync,
Func<CreateOrUpdateAsyncParams<Operations, Model>, Task<Model>> createOrUpdateAsync,
Func<Model, string> getLocation,
Action<Model, string> setLocation)
where Client : class, IDisposable
{
Func<IClient, Operations> toOperations = client => getOperations(client.GetClient<Client>());
return new ResourcePolicy<Config>(
return new ResourceStrategy<Model>(
getId,
p => getAsync(GetAsyncParams.Create(
toOperations(p.Operations), p.ResourceGroupName, p.Name, p.CancellationToken)),
Expand All @@ -54,13 +54,13 @@ public static ResourcePolicy<Config> Create<Config, Client, Operations>(
setLocation);
}

public static ResourcePolicy<Config> Create<Config, Client, Operations>(
public static ResourceStrategy<Model> Create<Model, Client, Operations>(
IEnumerable<string> headers,
Func<Client, Operations> getOperations,
Func<GetAsyncParams<Operations>, Task<Config>> getAsync,
Func<CreateOrUpdateAsyncParams<Operations, Config>, Task<Config>> createOrUpdateAsync,
Func<Config, string> getLocation,
Action<Config, string> setLocation)
Func<GetAsyncParams<Operations>, Task<Model>> getAsync,
Func<CreateOrUpdateAsyncParams<Operations, Model>, Task<Model>> createOrUpdateAsync,
Func<Model, string> getLocation,
Action<Model, string> setLocation)
where Client : class, IDisposable
=> Create(
name => new[] { "providers" }.Concat(headers).Concat(new[] { name }),
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Compute/AzureRM.Compute.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CLRVersion = '4.0'
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '3.3.1'; })

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
RequiredAssemblies = @('Microsoft.Azure.Commands.Common.Strategies')

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
Expand Down

0 comments on commit e37b2a4

Please sign in to comment.