Skip to content

Commit 2d8f322

Browse files
committed
Use HashtableExtensions to convert Tags to Dict.
1 parent da09fd5 commit 2d8f322

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/ResourceManager/Compute/Commands.Compute/Commands.Compute.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<Compile Include="Extension\RemoveAzureVMExtensionCommand.cs" />
164164
<Compile Include="Extension\GetAzureVMExtensionCommand.cs" />
165165
<Compile Include="Images\GetAzureVMImageCommand.cs" />
166+
<Compile Include="Models\HashTableExtensions.cs" />
166167
<Compile Include="Models\PSStorageAccount.cs" />
167168
<Compile Include="Extension\VMAccess\GetAzureVMAccessExtension.cs" />
168169
<Compile Include="Extension\VMAccess\RemoveAzureVMAccessExtension.cs" />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Tags.Model;
16+
using System.Collections;
17+
using System.Collections.Generic;
18+
19+
namespace Microsoft.Azure.Commands.Compute.Models
20+
{
21+
public static class HashTableExtension
22+
{
23+
public static Dictionary<string, string> ToDictionary(this Hashtable[] tags)
24+
{
25+
return TagsConversionHelper.CreateTagDictionary(tags, true);
26+
}
27+
}
28+
}

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public override void ExecuteCmdlet()
6060
AvailabilitySetReference = this.VM.AvailabilitySetReference,
6161
Location = !string.IsNullOrEmpty(this.Location) ? this.Location : this.VM.Location,
6262
Name = !string.IsNullOrEmpty(this.Name) ? this.Name : this.VM.Name,
63-
Tags = this.Tags != null ? TagsConversionHelper.CreateTagDictionary(this.Tags, true) : this.VM.Tags
63+
Tags = this.Tags != null ? this.Tags.ToDictionary() : this.VM.Tags
6464
};
6565

6666
var op = this.VirtualMachineClient.CreateOrUpdate(this.ResourceGroupName, parameters);

0 commit comments

Comments
 (0)