diff --git a/PropertyRetrieval/ItemTypes/ServiceTypes.cs b/PropertyRetrieval/ItemTypes/ServiceTypes.cs new file mode 100644 index 0000000..686f1bc --- /dev/null +++ b/PropertyRetrieval/ItemTypes/ServiceTypes.cs @@ -0,0 +1,40 @@ +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 ServiceTypes : BaseItemTypes + { + private readonly IConnection _connection; + + public ServiceTypes(IConnection connection) : base(connection, "Service") + { + _connection = connection; + } + + protected override IEnumerable GetItemInfoFromServer() + { + var servicePropertyValues = _connection.HandleMessage(new GetInfoMessage { Type = InfoType.ServiceInfo }); + + List items = new List(); + + foreach (var serviceMessage in servicePropertyValues) + { + var serviceInfo = (ServiceInfoEventMessage)serviceMessage; + + items.Add(new ItemInfo + { + Id = Convert.ToString(serviceInfo.ID), + Name = serviceInfo.Name, + PropertyNameAndValues = serviceInfo.Properties.Select(x => new KeyValuePair(x.Name, x.Value)), + }); + } + + return items; + } + } +} diff --git a/PropertyRetrieval/PropertyRetrieval.projitems b/PropertyRetrieval/PropertyRetrieval.projitems index 2ef8b15..42f795f 100644 --- a/PropertyRetrieval/PropertyRetrieval.projitems +++ b/PropertyRetrieval/PropertyRetrieval.projitems @@ -17,6 +17,7 @@ + \ No newline at end of file