Skip to content

Commit 4d86b53

Browse files
authored
Add function for pipeline input for autorest cmdlets (#22497)
1 parent 06dd4ea commit 4d86b53

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Storage/Storage.Management/Models/PSStorageAccount.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
using Microsoft.WindowsAzure.Commands.Common.Attributes;
2323
using StorageModels = Microsoft.Azure.Management.Storage.Models;
2424
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
25+
using Newtonsoft.Json.Serialization;
26+
using Newtonsoft.Json;
2527

2628
namespace Microsoft.Azure.Commands.Management.Storage.Models
2729
{
@@ -193,6 +195,26 @@ public override string ToString()
193195
// Allow listing storage contents through piping
194196
return null;
195197
}
198+
199+
/// <summary>
200+
/// Function used by piping PSStorageAccount to autorest based cmdlets
201+
/// </summary>
202+
/// <returns></returns>
203+
public string ToJsonString()
204+
{
205+
DefaultContractResolver contractResolver = new DefaultContractResolver
206+
{
207+
NamingStrategy = new CamelCaseNamingStrategy()
208+
};
209+
PSStorageAccount result = MemberwiseClone() as PSStorageAccount;
210+
result.Context = null;
211+
212+
return JsonConvert.SerializeObject(result, new JsonSerializerSettings
213+
{
214+
ContractResolver = contractResolver,
215+
Formatting = Formatting.Indented,
216+
});
217+
}
196218
}
197219

198220
public class PSCustomDomain

0 commit comments

Comments
 (0)