diff --git a/PropertyRetrieval/ItemTypes/ElementTypes.cs b/PropertyRetrieval/ItemTypes/ElementTypes.cs new file mode 100644 index 0000000..f880175 --- /dev/null +++ b/PropertyRetrieval/ItemTypes/ElementTypes.cs @@ -0,0 +1,39 @@ +namespace PropertyRetrieval.ItemTypes +{ + using System; + using System.Collections.Generic; + using System.Linq; + using PropertyRetrieval.DTO; + using Skyline.DataMiner.Net; + using Skyline.DataMiner.Net.Messages; + + internal class ElementTypes : BaseItemTypes + { + private readonly IConnection _connection; + + public ElementTypes(IConnection connection) : base(connection, "Element") + { + _connection = connection; + } + + protected override IEnumerable GetItemInfoFromServer() + { + var elementPropertyValues = _connection.HandleMessage(new GetInfoMessage { Type = InfoType.ElementInfo }); + List items = new List(); + + foreach (var elemenMessage in elementPropertyValues) + { + var elementInfo = (ElementInfoEventMessage)elemenMessage; + + items.Add(new ItemInfo + { + Id = Convert.ToString(elementInfo.ElementID), + Name = elementInfo.Name, + PropertyNameAndValues = elementInfo.Properties.Select(x=> new KeyValuePair(x.Name, x.Value)), + }); + } + + return items; + } + } +} diff --git a/PropertyRetrieval/PropertyRetrieval.projitems b/PropertyRetrieval/PropertyRetrieval.projitems index 48b7903..2ef8b15 100644 --- a/PropertyRetrieval/PropertyRetrieval.projitems +++ b/PropertyRetrieval/PropertyRetrieval.projitems @@ -14,6 +14,7 @@ +