Esempio n. 1
0
        /// <summary>
        /// Generates XML representing the given logging properties.
        /// </summary>
        /// <param name="logging">The logging properties.</param>
        /// <returns>An XML logging element.</returns>
        private static XElement GenerateLoggingXml(LoggingProperties logging)
        {
            if ((LoggingOperations.All & logging.LoggingOperations) != logging.LoggingOperations)
            {
                throw new InvalidOperationException("Invalid logging operations specified.");
            }

            if (string.IsNullOrEmpty(logging.Version))
            {
                throw new InvalidOperationException("The logging version is null or empty.");
            }

            return(new XElement(
                       LoggingName,
                       new XElement(VersionName, logging.Version),
                       new XElement(DeleteName, (logging.LoggingOperations & LoggingOperations.Delete) != 0),
                       new XElement(ReadName, (logging.LoggingOperations & LoggingOperations.Read) != 0),
                       new XElement(WriteName, (logging.LoggingOperations & LoggingOperations.Write) != 0),
                       GenerateRetentionPolicyXml(logging.RetentionDays)));
        }
        /// <summary>
        /// Generates XML representing the given logging properties.
        /// </summary>
        /// <param name="logging">
        /// The logging properties. 
        /// </param>
        /// <returns>
        /// An XML logging element. 
        /// </returns>
        private static XElement GenerateLoggingXml(LoggingProperties logging)
        {
            if ((LoggingOperations.All & logging.LoggingOperations) != logging.LoggingOperations)
            {
                throw new InvalidOperationException("Invalid logging operations specified.");
            }

            if (string.IsNullOrEmpty(logging.Version))
            {
                throw new InvalidOperationException("The logging version is null or empty.");
            }

            return new XElement(
                LoggingName,
                new XElement(VersionName, logging.Version),
                new XElement(DeleteName, (logging.LoggingOperations & LoggingOperations.Delete) != 0),
                new XElement(ReadName, (logging.LoggingOperations & LoggingOperations.Read) != 0),
                new XElement(WriteName, (logging.LoggingOperations & LoggingOperations.Write) != 0),
                GenerateRetentionPolicyXml(logging.RetentionDays));
        }