예제 #1
0
파일: Extensions.cs 프로젝트: lulzzz/aika
        /// <summary>
        /// Converts an Elasticsearch <see cref="TagDocument"/> into the equivalent <see cref="TagSettings"/> object.
        /// </summary>
        /// <param name="tag">The Elasticsearch tag document.</param>
        /// <returns>
        /// An equivalent <see cref="TagSettings"/> object.
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="tag"/> is <see langword="null"/>.</exception>
        public static TagSettings ToTagSettings(this TagDocument tag)
        {
            if (tag == null)
            {
                throw new ArgumentNullException(nameof(tag));
            }

            return(new TagSettings()
            {
                Name = tag.Name,
                Description = tag.Description,
                Units = tag.Units,
                DataType = tag.DataType,
                StateSet = tag.StateSet,
                ExceptionFilterSettings = new TagValueFilterSettingsUpdate()
                {
                    IsEnabled = tag.ExceptionFilter.IsEnabled,
                    LimitType = tag.ExceptionFilter.LimitType,
                    Limit = tag.ExceptionFilter.Limit,
                    WindowSize = tag.ExceptionFilter.WindowSize
                },
                CompressionFilterSettings = new TagValueFilterSettingsUpdate()
                {
                    IsEnabled = tag.CompressionFilter.IsEnabled,
                    LimitType = tag.CompressionFilter.LimitType,
                    Limit = tag.CompressionFilter.Limit,
                    WindowSize = tag.CompressionFilter.WindowSize
                }
            });
        }
예제 #2
0
파일: Extensions.cs 프로젝트: lulzzz/aika
        /// <summary>
        /// Creates a <see cref="TagMetadata"/> from the specified <see cref="TagDocument"/>.
        /// </summary>
        /// <param name="tag">The Elasticsearch tag document.</param>
        /// <returns>
        /// A <see cref="TagMetadata"/> that is populated using the metadata in the tag document.
        /// </returns>
        /// <exception cref="ArgumentNullException"><paramref name="tag"/> is <see langword="null"/>.</exception>
        public static TagMetadata ToTagMetadata(this TagDocument tag)
        {
            if (tag == null)
            {
                throw new ArgumentNullException(nameof(tag));
            }

            return(new TagMetadata(tag.Metadata?.UtcCreatedAt ?? DateTime.MinValue, tag.Metadata?.Creator, tag.Metadata?.UtcLastModifiedAt, tag.Metadata?.LastModifiedBy));
        }