/// <summary> /// Determines the results of the specified contexts. /// </summary> /// <param name="service">The service.</param> /// <param name="contexts">The contexts.</param> /// <returns> /// A set of Decision indicating the results of the query. /// </returns> public static async Task<IDictionary<string, bool>> CheckAsync(this IDecisionService service, IEnumerable<DecisionContext> contexts) { return await Task.Run(() => { var tasks = new Dictionary<string, Task<bool>>(); foreach (var context in contexts) { // Create the task before adding so the service applies defaults to the context. var result = service.CheckAsync(context); tasks.Add(context.Id, result); } Task.WaitAll(tasks.Values.ToArray()); return tasks.ToDictionary(a => a.Key, a => a.Value.Result); }); }
/// <summary> /// The Check Static IP operation retrieves the details for the /// availability of static IP addresses for the given virtual network. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IStaticIPOperations. /// </param> /// <param name='virtualNetworkName'> /// The name of the virtual network. /// </param> /// <param name='ipAddress'> /// The address of the static IP. /// </param> /// <returns> /// A response that indicates the availability of a static IP address, /// and if not, provide a list of suggestions. /// </returns> public static NetworkStaticIPAvailabilityResponse Check(this IStaticIPOperations operations, string virtualNetworkName, string ipAddress) { try { return operations.CheckAsync(virtualNetworkName, ipAddress).Result; } catch (AggregateException ex) { if (ex.InnerExceptions.Count > 1) { throw; } else { throw ex.InnerException; } } }
/// <summary> /// The Check Static IP operation retrieves the details for the /// availability of static IP addresses for the given virtual network. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.Network.IStaticIPOperations. /// </param> /// <param name='networkName'> /// Required. The name of the virtual network. /// </param> /// <param name='ipAddress'> /// Required. The address of the static IP. /// </param> /// <returns> /// A response that indicates the availability of a static IP address, /// and if not, provides a list of suggestions. /// </returns> public static Task<NetworkStaticIPAvailabilityResponse> CheckAsync(this IStaticIPOperations operations, string networkName, string ipAddress) { return operations.CheckAsync(networkName, ipAddress, CancellationToken.None); }
/// <summary> /// Determines the results of the specified contexts. /// </summary> /// <param name="service">The service.</param> /// <param name="contexts">The contexts.</param> /// <returns> /// A Decision indicating the result of the query. /// </returns> public static IDictionary<string, bool> Check(this IDecisionService service, IEnumerable<DecisionContext> contexts) { return Task.Run(() => service.CheckAsync(contexts)).Result; }
/// <summary> /// Determines the result of the specified context. /// </summary> /// <param name="service">The service.</param> /// <param name="context">The context.</param> /// <returns> /// A Decision indicating the result of the query. /// </returns> public static bool Check(this IDecisionService service, DecisionContext context) { return Task.Run(() => service.CheckAsync(context)).Result; }