/// <summary> /// Assembles a new <see cref="IEnumerable{T}"/> of <see cref="TTo"/> instances out of the specified /// <paramref name="fromItems"/>. /// </summary> /// <param name="fromItems">The original enumerable.</param> /// <param name="assembleParameters">The assembleParameters of get delegated to the inner instance assembler.</param> /// <returns>The resulting enumerable.</returns> public virtual IEnumerable <TTo> Assemble(IEnumerable <TFrom> fromItems, dynamic assembleParameters = null) { if (fromItems == null) { yield break; } foreach (TFrom fromItem in fromItems) { yield return(_instanceAssembler.Assemble(fromItem, assembleParameters)); } }
/// <summary> /// Assembles a new <see cref="TagDTO"/> instance out of the specified <paramref name="fromItem"/>. /// </summary> /// <param name="fromItem">The original object.</param> /// <param name="assembleParameters">The method does not consider any parameters.</param> /// <returns>The resulting object.</returns> public TagDTO Assemble(Tag fromItem, dynamic assembleParameters = null) { if (fromItem == null) { return(null); } string value = string.Empty; if (fromItem.Value != null) { value = fromItem.Value.ToString(); } var dto = new TagDTO { Children = _tagsAssembler.Assemble(fromItem.Childs).ToList(), Comment = fromItem.MetaData.Comment, Key = fromItem.Name, Name = fromItem.NestedName, Type = GetDotNetType(fromItem), Unit = fromItem.MetaData.UnitForUser, Value = value }; dto.EnumerationMembers = new List <EnumerationMemberDto>(); if (fromItem.MetaData.EnumerationMembers != null) { foreach (var enumerationMember in fromItem.MetaData.EnumerationMembers) { dto.EnumerationMembers.Add(new EnumerationMemberDto { Comment = enumerationMember.Comment, Value = enumerationMember.Value }); } } return(dto); }
private IEnumerable <TagDTO> AssembleTagDtos(IEnumerable <Tag> tags) { return(_tagDtosAssembler.Assemble(tags)); }