Esempio n. 1
0
        public static void EmitModuleScopeProperties(ScopeData scopeData, ExpressionEmitter expressionEmitter)
        {
            switch (scopeData.RequestedScope)
            {
            case ResourceScopeType.TenantScope:
                expressionEmitter.EmitProperty("scope", new JTokenExpression("/"));
                return;

            case ResourceScopeType.ManagementGroupScope:
                if (scopeData.ManagementGroupNameProperty != null)
                {
                    expressionEmitter.EmitProperty("scope", () => expressionEmitter.EmitManagementGroupScope(scopeData.ManagementGroupNameProperty));
                }
                return;

            case ResourceScopeType.SubscriptionScope:
            case ResourceScopeType.ResourceGroupScope:
                if (scopeData.SubscriptionIdProperty != null)
                {
                    expressionEmitter.EmitProperty("subscriptionId", scopeData.SubscriptionIdProperty);
                }
                if (scopeData.ResourceGroupProperty != null)
                {
                    expressionEmitter.EmitProperty("resourceGroup", scopeData.ResourceGroupProperty);
                }
                return;

            default:
                throw new NotImplementedException($"Cannot format resourceId for scope {scopeData.RequestedScope}");
            }
        }