update
This commit is contained in:
@@ -1,12 +1,46 @@
|
||||
namespace RobotApp.VDA5050;
|
||||
|
||||
public static class VDA5050Topic
|
||||
public enum VDA5050Topic
|
||||
{
|
||||
public const string Connection = "connection";
|
||||
public const string Order = "order";
|
||||
public const string InstantActions = "instantActions";
|
||||
public const string State = "state";
|
||||
public const string Visualization = "visualization";
|
||||
public const string Factsheet = "factsheet";
|
||||
public const string FactsheetExtend = "factsheetExtend"; // custom by TungNV
|
||||
CONNECTION,
|
||||
ORDER,
|
||||
INSTANTACTIONS,
|
||||
STATE,
|
||||
VISUALIZATION,
|
||||
FACTSHEET
|
||||
}
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
private static readonly Dictionary<VDA5050Topic, string> TopicToStringMap = new()
|
||||
{
|
||||
{ VDA5050Topic.CONNECTION, "connection" },
|
||||
{ VDA5050Topic.ORDER, "order" },
|
||||
{ VDA5050Topic.INSTANTACTIONS, "instantActions" },
|
||||
{ VDA5050Topic.STATE, "state" },
|
||||
{ VDA5050Topic.VISUALIZATION, "visualization" },
|
||||
{ VDA5050Topic.FACTSHEET, "factsheet" }
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, VDA5050Topic> StringToTopicMap = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "connection", VDA5050Topic.CONNECTION },
|
||||
{ "order", VDA5050Topic.ORDER },
|
||||
{ "instantActions", VDA5050Topic.INSTANTACTIONS },
|
||||
{ "state", VDA5050Topic.STATE },
|
||||
{ "visualization", VDA5050Topic.VISUALIZATION },
|
||||
{ "factsheet", VDA5050Topic.FACTSHEET }
|
||||
};
|
||||
|
||||
public static string ToTopicString(this VDA5050Topic type)
|
||||
{
|
||||
if (TopicToStringMap.TryGetValue(type, out var value)) return value;
|
||||
throw new ArgumentException($"Invalid VDA5050Topic: {type}");
|
||||
}
|
||||
|
||||
public static VDA5050Topic ToTopic(string value)
|
||||
{
|
||||
if (StringToTopicMap.TryGetValue(value, out var result)) return result;
|
||||
throw new ArgumentException($"No VDA5050Topic with string value '{value}' found.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user