Exemplo n.º 1
0
 /// <summary>
 /// Creates a new <see cref="TagDefinitionExtendedDto"/> object from the specified tag definition.
 /// </summary>
 /// <param name="tagDefinition">The tag definition.</param>
 /// <exception cref="ArgumentNullException"><paramref name="tagDefinition"/> is <see langword="null"/>.</exception>
 internal static TagDefinitionExtendedDto ToTagDefinitionExtendedDto(this TagDefinition tagDefinition)
 {
     return(new TagDefinitionExtendedDto()
     {
         Id = tagDefinition.Id,
         Name = tagDefinition.Name,
         Description = tagDefinition.Description,
         Units = tagDefinition.Units,
         DataType = tagDefinition.DataType.ToString(),
         StateSet = tagDefinition.DataType == TagDataType.State
             ? tagDefinition.StateSet
             : null,
         ExceptionFilterSettings = tagDefinition.DataFilter.ExceptionFilter.Settings.ToTagValueFilterSettingsDto(),
         CompressionFilterSettings = tagDefinition.DataFilter.CompressionFilter.Settings.ToTagValueFilterSettingsDto(),
         ChangeHistory = tagDefinition.ChangeHistory.Select(x => new TagChangeHistoryEntryDto()
         {
             Id = x.Id,
             UtcTime = x.UtcTime,
             User = x.User,
             Description = x.Description
         }).ToArray(),
         Properties = new Dictionary <string, object>(tagDefinition.GetProperties()),
         Metadata = new TagMetadataDto()
         {
             Creator = tagDefinition.Metadata.Creator,
             LastModifiedBy = tagDefinition.Metadata.LastModifiedBy,
             UtcCreatedAt = tagDefinition.Metadata.UtcCreatedAt,
             UtcLastModifiedAt = tagDefinition.Metadata.UtcLastModifiedAt
         }
     });
 }