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); } } } }