first commit -push
This commit is contained in:
42
RobotNet.MapShares/Property/ElementProperty.cs
Normal file
42
RobotNet.MapShares/Property/ElementProperty.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace RobotNet.MapShares.Property;
|
||||
|
||||
#nullable disable
|
||||
|
||||
public class ElementProperty
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string DefaultValue { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
private static readonly Dictionary<string, Type> TypeMap = new()
|
||||
{
|
||||
{ "Boolean", typeof(bool) },
|
||||
{ "Double", typeof(double) },
|
||||
{ "Int", typeof(int) },
|
||||
{ "String", typeof(string) },
|
||||
{ "System.Boolean", typeof(bool) },
|
||||
{ "System.Double", typeof(double) },
|
||||
{ "System.Int", typeof(int) },
|
||||
{ "System.String", typeof(string) },
|
||||
};
|
||||
|
||||
public static string GetPropertyTypeName(Type type)
|
||||
{
|
||||
return TypeMap.FirstOrDefault(kv => kv.Value == type).Key ?? "Unknown";
|
||||
}
|
||||
|
||||
public static readonly Type[] PropertyTypes = [
|
||||
typeof(bool),
|
||||
typeof(double),
|
||||
typeof(int),
|
||||
typeof(string),
|
||||
];
|
||||
|
||||
public Type GetPropertyType()
|
||||
{
|
||||
return TypeMap.TryGetValue(Type ?? string.Empty, out var type) ? type : typeof(object);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user