forked from Infinite-Blue-1042/V-Term
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cs
34 lines (32 loc) · 1.09 KB
/
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using Resource = Microsoft.Azure.PowerShell.Cmdlets.DataBox.Resources.Resource;
namespace Microsoft.Azure.Commands.DataBox.Common
{
public class ResourceIdHandler
{
public static string GetResourceGroupName(string resourceId)
{
var splits = resourceId.Split(new[] { '/' });
for(int i = 0;i<splits.Length; i++)
{
if (splits[i].Equals("resourceGroups", StringComparison.CurrentCultureIgnoreCase))
{
return splits[i + 1];
}
}
throw new Exception(Resource.InvalidResourceId);
}
public static string GetResourceName(string resourceId)
{
var splits = resourceId.Split(new[] { '/' });
for (int i = 0; i < splits.Length; i++)
{
if (splits[i].Equals("providers", StringComparison.CurrentCultureIgnoreCase))
{
return splits[i + 3];
}
}
throw new Exception(Resource.InvalidResourceId);
}
}
}