internal static void Validate(ApplicationMetricDescription description, long maximumNodes = 0) { Requires.Argument<string>("Name", description.Name).NotNullOrWhiteSpace(); // This check is needed because managed type is long, and native type is UINT Requires.CheckUInt32ArgumentLimits(description.NodeReservationCapacity, "NodeReservationCapacity"); Requires.CheckUInt32ArgumentLimits(description.MaximumNodeCapacity, "MaximumNodeCapacity"); Requires.CheckUInt32ArgumentLimits(description.TotalApplicationCapacity, "TotalApplicationCapacity"); if (description.NodeReservationCapacity > description.MaximumNodeCapacity) { throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, StringResources.Error_ReservationCapacityGreaterThanMaximumNodeCapacity, description.NodeReservationCapacity, description.MaximumNodeCapacity)); } if (maximumNodes * description.MaximumNodeCapacity > description.TotalApplicationCapacity) { throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, StringResources.Error_MaximumCapacityGreaterThanTotalCapacity, description.MaximumNodeCapacity, maximumNodes, description.TotalApplicationCapacity)); } }
internal static void Validate(ApplicationDescription description) { Requires.Argument <Uri>("ApplicationName", description.ApplicationName).NotNull(); Requires.Argument <string>("ApplicationTypeName", description.ApplicationTypeName).NotNullOrWhiteSpace(); Requires.Argument <string>("ApplicationTypeVersion", description.ApplicationTypeVersion).NotNullOrWhiteSpace(); // This check is needed because managed type is long, and native type is UINT Requires.CheckUInt32ArgumentLimits(description.MaximumNodes, "MaximumNodes"); Requires.CheckUInt32ArgumentLimits(description.MinimumNodes, "MinimumNodes"); if (description.MinimumNodes > description.MaximumNodes) { throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, StringResources.Error_MinimumNodesGreaterThanMaximumNodes, description.MinimumNodes, description.MaximumNodes )); } foreach (var metric in description.Metrics) { ApplicationMetricDescription.Validate(metric, description.MaximumNodes); } }
internal static void Validate(ApplicationUpdateDescription description) { Requires.Argument <Uri>("ApplicationName", description.ApplicationName).NotNull(); if (description.RemoveApplicationCapacity && (description.MinimumNodes.HasValue || description.MaximumNodes.HasValue || description.Metrics != null)) { throw new ArgumentException(StringResources.Error_RemoveApplicationCapacity); } // This check is needed because managed type is long, and native type is UINT if (description.MinimumNodes.HasValue) { Requires.CheckUInt32ArgumentLimits(description.MinimumNodes.Value, "MinimumNodes"); } if (description.MaximumNodes.HasValue) { Requires.CheckUInt32ArgumentLimits(description.MaximumNodes.Value, "MaximumNodes"); } if (description.MinimumNodes.HasValue && description.MaximumNodes.HasValue && (description.MinimumNodes.Value > description.MaximumNodes.Value)) { throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, StringResources.Error_MinimumNodesGreaterThanMaximumNodes, description.MinimumNodes.Value, description.MaximumNodes.Value )); } if (description.Metrics != null) { foreach (var metric in description.Metrics) { if (description.MaximumNodes.HasValue) { ApplicationMetricDescription.Validate(metric, description.MaximumNodes.Value); } else { ApplicationMetricDescription.Validate(metric); } } } }