private static IEnumerable <(FunctionOverload functionOverload, ResourceScopeType allowedScopes)> GetScopeFunctions() { // Depending on the scope of the Bicep file, different sets of function overloads are invalid - for example, you can't use 'resourceGroup()' inside a tenant-level deployment // Also note that some of these functions and overloads ("GetRestrictedXYZ") have not yet been implemented in full in the ARM JSON. For these, we simply // return an empty object type (so that dot property access doesn't work), and generate as an ARM expression "json({})" if anyone tries to access the object value. // This list should be kept in-sync with ScopeHelper.CanConvertToArmJson(). var allScopes = ResourceScopeType.TenantScope | ResourceScopeType.ManagementGroupScope | ResourceScopeType.SubscriptionScope | ResourceScopeType.ResourceGroupScope; yield return(FunctionOverload.CreateFixed("tenant", GetRestrictedTenantReturnValue), allScopes); yield return(FunctionOverload.CreateFixed("managementGroup", GetRestrictedManagementGroupReturnValue), ResourceScopeType.ManagementGroupScope); yield return(FunctionOverload.CreateFixed("managementGroup", GetRestrictedManagementGroupReturnValue, LanguageConstants.String), ResourceScopeType.TenantScope | ResourceScopeType.ManagementGroupScope); yield return(FunctionOverload.CreateFixed("subscription", GetSubscriptionReturnValue), ResourceScopeType.SubscriptionScope | ResourceScopeType.ResourceGroupScope); yield return(FunctionOverload.CreateFixed("subscription", GetRestrictedSubscriptionReturnValue, LanguageConstants.String), allScopes); yield return(FunctionOverload.CreateFixed("resourceGroup", GetResourceGroupReturnValue), ResourceScopeType.ResourceGroupScope); yield return(FunctionOverload.CreateFixed("resourceGroup", GetRestrictedResourceGroupReturnValue, LanguageConstants.String), ResourceScopeType.SubscriptionScope | ResourceScopeType.ResourceGroupScope); yield return(FunctionOverload.CreateFixed("resourceGroup", GetRestrictedResourceGroupReturnValue, LanguageConstants.String, LanguageConstants.String), ResourceScopeType.SubscriptionScope | ResourceScopeType.ResourceGroupScope); }
public ArgumentTypeMismatch(FunctionOverload source, int argumentIndex, TypeSymbol argumentType, TypeSymbol parameterType) { this.Source = source; this.ArgumentIndex = argumentIndex; this.ArgumentType = argumentType; this.ParameterType = parameterType; }
public void Deconstruct(out FunctionOverload source, out int argumentIndex, out TypeSymbol argumentType, out TypeSymbol parameterType) { source = this.Source; argumentIndex = this.ArgumentIndex; argumentType = this.ArgumentType; parameterType = this.ParameterType; }
private static IEnumerable <FunctionOverload> GetAzOverloads(ResourceScopeType resourceScope) { foreach (var(functionOverload, allowedScopes) in GetScopeFunctions()) { // we only include it if it's valid at all of the scopes that the template is valid at if (resourceScope == (resourceScope & allowedScopes)) { yield return(functionOverload); } // TODO: add banned function to explain why a given function isn't available } // TODO: Add schema for return type yield return(FunctionOverload.CreateFixed("deployment", LanguageConstants.Object)); // TODO: Add schema for return type yield return(FunctionOverload.CreateFixed("environment", LanguageConstants.Object)); // TODO: This is based on docs. Verify yield return(FunctionOverload.CreateWithVarArgs("resourceId", LanguageConstants.String, 2, LanguageConstants.String)); yield return(FunctionOverload.CreateWithVarArgs("subscriptionResourceId", LanguageConstants.String, 2, LanguageConstants.String)); yield return(FunctionOverload.CreateWithVarArgs("tenantResourceId", LanguageConstants.String, 2, LanguageConstants.String)); yield return(FunctionOverload.CreateWithVarArgs("extensionResourceId", LanguageConstants.String, 3, LanguageConstants.String)); // TODO: Not sure about return type yield return(new FunctionOverload("providers", LanguageConstants.Array, 1, 2, Enumerable.Repeat(LanguageConstants.String, 2), null)); // TODO: return type is string[] yield return(new FunctionOverload("pickZones", LanguageConstants.Array, 3, 5, new[] { LanguageConstants.String, LanguageConstants.String, LanguageConstants.String, LanguageConstants.Int, LanguageConstants.Int }, null)); // the use of FunctionPlacementConstraints.Resources prevents use of these functions anywhere where they can't be directly inlined into a resource body yield return(new FunctionOverload("reference", LanguageConstants.Object, 1, 3, Enumerable.Repeat(LanguageConstants.String, 3), null, FunctionFlags.RequiresInlining)); yield return(new FunctionWildcardOverload("list*", LanguageConstants.Any, 2, 3, new[] { LanguageConstants.String, LanguageConstants.String, LanguageConstants.Object }, null, new Regex("^list[a-zA-Z]+"), FunctionFlags.RequiresInlining)); }
public Decorator?TryGetDecorator(FunctionOverload overload) => this.decoratorsByOverloads.TryGetValue(overload, out Decorator? decorator) ? decorator : null;
static void Main(string[] args) { try { /* My First Program in C# */ Console.WriteLine("Hello World"); /* My Second Program in C# */ int num; Console.Write("\nEnter a value of N: "); num = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\nValue of N: {0}\n", num); /* Area of Rectangle Program in C# */ Rectangle rect = new Rectangle(); rect.Acceptdetails(); rect.Display(); /* sizeof in C# */ Console.WriteLine("Size of int: {0} \n", sizeof(int)); object obj; obj = 100; // this is boxing // ast double to int. double d = 5673.74; int i; i = (int)d; // Addition of two numbers int new_i = 75; float new_f = 53.005f; double new_d = 2345.7652; bool new_b = true; Console.WriteLine("Integer value of i: " + new_i.ToString()); Console.WriteLine("Integer value of f: " + new_f.ToString()); Console.WriteLine("Integer value of d: " + new_d.ToString()); Console.WriteLine("Boolean value of b: " + new_b.ToString()); short a; int b; double c; /* Actual initialization */ a = 10; b = 20; c = a + b; Console.WriteLine("\nA = {0}, B = {1}, Addition of A and B = {2}", a, b, c); // Constant declaration const double pi = 3.14159; double r; Console.Write("\nEnter Radius: "); r = Convert.ToDouble(Console.ReadLine()); double areaCircle = pi * r * r; Console.WriteLine("\nValue of Radius: {0}, \tArea: {1}", r, areaCircle); // Function overloading Console.Write("\nEnter value of X: "); int x = Convert.ToInt32(Console.ReadLine()); Console.Write("\nEnter value of Y: "); int y = Convert.ToInt32(Console.ReadLine()); Console.Write("\nEnter value of Z: "); int z = Convert.ToInt32(Console.ReadLine()); FunctionOverload fn = new FunctionOverload(); Console.Write("\nMax between X and Y : {0}", fn.FindMax(x, y)); Console.Write("\n\nMax between X,Y and Z: {0}\n", fn.FindMax(x, y, z)); // Array in C# int[] n = new int[10]; /* n is an array of 10 integers */ int ii, jj; /* initialize elements of array n */ for (ii = 0; ii < 10; ii++) { n[ii] = ii + 100; } /* output each array element's value */ for (jj = 0; jj < 10; jj++) { Console.WriteLine("\nElement[{0}] = {1}", jj, n[jj]); } //from string literal and string concatenation string fname, lname; fname = "Raju"; lname = "Ingalgi"; char[] letters = { 'H', 'e', 'l', 'l', 'o' }; string[] sarray = { "Hello", "From", "Aryan", "Enterprises" }; string fullname = fname + lname; Console.WriteLine("Full Name: {0}", fullname); string greetings = new string(letters); Console.WriteLine("Greetings: {0}", greetings); string message = String.Join(" ", sarray); Console.WriteLine("Message: {0}", message); Console.ReadKey(); Thread th = Thread.CurrentThread; th.Name = "Main Thread"; Console.WriteLine("Thread Namer: " + th.Name); Console.ReadKey(); //formatting method to convert a value DateTime waiting = new DateTime(2018, 07, 22, 17, 58, 0); string chat = String.Format("Message sent at {0:t} on {0:D}", waiting); Console.WriteLine("Message: {0}", chat); StackView stackView = new StackView(); stackView.StackOperation(); QueueView queueView = new QueueView(); queueView.QueueOperation(); BitArrayView bitArrayView = new BitArrayView(); bitArrayView.BitArrayOperations(); // Create delegate instance using anonymous method. NumberChanger nc = delegate(int X) { Console.WriteLine("\nAnonymous Method: {0}", X); }; // Calling the delegate using anonymous method. nc(10); // Instanceing the delegate using the named method. nc = new NumberChanger(AddNum); // Calling the delegate using anonymous method. nc(15); Console.ReadKey(); } catch (Exception Code) { Console.WriteLine("Error Code : {0}", Code); } }