Skip to content

Commit

Permalink
Addded ServiceTypes class.
Browse files Browse the repository at this point in the history
  • Loading branch information
nejrahosic committed Jul 21, 2023
1 parent 6707657 commit 08857b0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions PropertyRetrieval/ItemTypes/ServiceTypes.cs
Original file line number Diff line number Diff line change
@@ -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<ItemInfo> GetItemInfoFromServer()
{
var servicePropertyValues = _connection.HandleMessage(new GetInfoMessage { Type = InfoType.ServiceInfo });

List<ItemInfo> items = new List<ItemInfo>();

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<string, string>(x.Name, x.Value)),
});
}

return items;
}
}
}
1 change: 1 addition & 0 deletions PropertyRetrieval/PropertyRetrieval.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\ElementTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\IitemTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\ItemTypeHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\ServiceTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\ViewTypes.cs" />
</ItemGroup>
</Project>

0 comments on commit 08857b0

Please sign in to comment.