mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-27 11:24:55 +00:00
58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using PepperDash.Core;
|
|
|
|
namespace PepperDash.Essentials.Core.Web
|
|
{
|
|
public class EssentialsWebApiHelpers
|
|
{
|
|
public static object MapToAssemblyObject(LoadedAssembly assembly)
|
|
{
|
|
return new
|
|
{
|
|
Name = assembly.Name,
|
|
Version = assembly.Version
|
|
};
|
|
}
|
|
|
|
public static object MapToDeviceListObject(IKeyed device)
|
|
{
|
|
return new
|
|
{
|
|
Key = device.Key,
|
|
Name = (device is IKeyName)
|
|
? (device as IKeyName).Name
|
|
: "---"
|
|
};
|
|
}
|
|
|
|
public static object MapJoinToObject(string key, JoinMapBaseAdvanced join)
|
|
{
|
|
var kp = new KeyValuePair<string, JoinMapBaseAdvanced>(key, join);
|
|
|
|
return MapJoinToObject(kp);
|
|
}
|
|
|
|
public static object MapJoinToObject(KeyValuePair<string, JoinMapBaseAdvanced> join)
|
|
{
|
|
return new
|
|
{
|
|
DeviceKey = join.Key,
|
|
Joins = join.Value.Joins.Select(j => MapJoinDataCompleteToObject(j))
|
|
};
|
|
}
|
|
|
|
public static object MapJoinDataCompleteToObject(KeyValuePair<string, JoinDataComplete> joinData)
|
|
{
|
|
return new
|
|
{
|
|
Signal = joinData.Key,
|
|
Description = joinData.Value.Metadata.Description,
|
|
JoinNumber = joinData.Value.JoinNumber,
|
|
JoinSpan = joinData.Value.JoinSpan,
|
|
JoinType = joinData.Value.Metadata.JoinType.ToString(),
|
|
JoinCapabilities = joinData.Value.Metadata.JoinCapabilities.ToString()
|
|
};
|
|
}
|
|
}
|
|
} |