/// <summary>
        /// Constructs a <c>DeleteRetentionPolicy</c> object from an XML element.
        /// </summary>
        /// <param name="element">the XML element</param>
        /// <returns>A <c>DeleteRetentionPolicy</c> object containing the properties in the element</returns>
        internal static DeleteRetentionPolicy ReadDeleteRetentionPolicyFromXml(XElement element)
        {
            if (element == null)
            {
                return(null);
            }

            DeleteRetentionPolicy deleteRetentionPolicy = new DeleteRetentionPolicy()
            {
                Enabled       = false,
                RetentionDays = null
            };

            deleteRetentionPolicy.Enabled = bool.Parse(element.Element(EnabledName).Value);

            if (deleteRetentionPolicy.Enabled)
            {
                deleteRetentionPolicy.RetentionDays = int.Parse(element.Element(DaysName).Value, CultureInfo.InvariantCulture);
            }

            return(deleteRetentionPolicy);
        }
        /// <summary>
        /// Generates XML representing the given delete retention policy.
        /// </summary>
        /// <param name="deleteRetentionPolicy">The DeleteRetentionPolicy properties.</param>
        /// <returns>An XML logging element.</returns>
        private static XElement GenerateDeleteRetentionPolicyXml(DeleteRetentionPolicy deleteRetentionPolicy)
        {
            CommonUtility.AssertNotNull("deleteRetentionPolicy", deleteRetentionPolicy);

            bool     enabled = deleteRetentionPolicy.Enabled;
            XElement xml     = new XElement(DeleteRetentionPolicyName, new XElement(EnabledName, enabled));

            if (!enabled)
            {
                return(xml);
            }

            if (!deleteRetentionPolicy.RetentionDays.HasValue || deleteRetentionPolicy.RetentionDays.Value < 1 ||
                deleteRetentionPolicy.RetentionDays > Constants.MaximumAllowedRetentionDays)
            {
                throw new ArgumentException(SR.InvalidDeleteRetentionDaysValue);
            }

            xml.Add(new XElement(DaysName, (int)deleteRetentionPolicy.RetentionDays));

            return(xml);
        }
 /// <summary>
 /// Initializes a new instance of the ServiceProperties class.
 /// </summary>
 public ServiceProperties(LoggingProperties logging, MetricsProperties hourMetrics, MetricsProperties minuteMetrics, CorsProperties cors, DeleteRetentionPolicy deleteRetentionPolicy, StaticWebsiteProperties staticWebsite = null)
 {
     this.Logging               = logging;
     this.HourMetrics           = hourMetrics;
     this.MinuteMetrics         = minuteMetrics;
     this.Cors                  = cors;
     this.DeleteRetentionPolicy = deleteRetentionPolicy;
     this.StaticWebsite         = staticWebsite;
 }
 /// <summary>
 /// Initializes a new instance of the ServiceProperties class.
 /// </summary>
 public ServiceProperties(LoggingProperties logging = null, MetricsProperties hourMetrics = null, MetricsProperties minuteMetrics = null, CorsProperties cors = null, DeleteRetentionPolicy deleteRetentionPolicy = null)
     : this(logging, hourMetrics, minuteMetrics, cors, deleteRetentionPolicy, staticWebsite : null)
 {
 }