/// <summary>
        /// Initializes a new instance of the <see cref="PolicyConfiguration"/> class
        /// with the specified values.
        /// </summary>
        /// <remarks>
        /// To create scaling policy for one of the predefined policy types, use
        /// one of the following factory methods.
        /// <list type="bullet">
        /// <item><see cref="Capacity"/></item>
        /// <item><see cref="IncrementalChange"/></item>
        /// <item><see cref="PercentageChange"/></item>
        /// <item><see cref="PercentageChangeAtTime"/></item>
        /// </list>
        /// </remarks>
        /// <param name="name">The name of the scaling policy.</param>
        /// <param name="type">The scaling policy type.</param>
        /// <param name="desiredCapacity">The desired capacity of the scaling policy.</param>
        /// <param name="cooldown">The cooldown of the scaling policy.</param>
        /// <param name="change">The incremental change for the scaling policy.</param>
        /// <param name="changePercent">The percentage change for the scaling policy.</param>
        /// <param name="arguments">An object modeling the additional arguments to associate with the scaling policy.</param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="name"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="type"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentException">If <paramref name="name"/> is empty.</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// If <paramref name="desiredCapacity"/> is less than 0.
        /// <para>-or-</para>
        /// <para>If <paramref name="cooldown"/> is less than <see cref="TimeSpan.Zero"/>.</para>
        /// </exception>
        protected PolicyConfiguration(string name, PolicyType type, long?desiredCapacity, TimeSpan?cooldown, long?change, double?changePercent, object arguments)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name cannot be empty");
            }
            if (desiredCapacity < 0)
            {
                throw new ArgumentOutOfRangeException("desiredCapacity");
            }
            if (cooldown < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException("cooldown");
            }

            _name            = name;
            _type            = type;
            _desiredCapacity = desiredCapacity;
            _cooldown        = cooldown != null ? (long?)cooldown.Value.TotalSeconds : null;
            _change          = change;
            _changePercent   = changePercent;
            _args            = arguments != null?JObject.FromObject(arguments) : null;
        }
 /// <inheritdoc/>
 protected override PolicyType FromName(string name)
 {
     return(PolicyType.FromName(name));
 }