Skip to content

Commit

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

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<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 @@ -14,6 +14,7 @@
<Compile Include="$(MSBuildThisFileDirectory)DTO\PropertyConfigInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DTO\PropertyUsage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\BaseItemTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\ElementTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\IitemTypes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\ItemTypeHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ItemTypes\ViewTypes.cs" />
Expand Down

0 comments on commit 6707657

Please sign in to comment.