using RobotNet.MapShares.Property; using RobotNet.Script.Expressions; namespace RobotNet.MapShares; public static class MapManagerExtensions { public static Script.Expressions.ElementProperties GetElementProperties(bool isOpen, string content) { var dbool = new Dictionary(); var ddouble = new Dictionary(); var dint = new Dictionary(); var dstr = new Dictionary(); var elementProperties = System.Text.Json.JsonSerializer.Deserialize(content, JsonOptionExtends.Read) ?? []; foreach (var ep in elementProperties) { if(ep.Type == "System.Boolean" || ep.Type == "Boolean") { dbool.Add(ep.Name, bool.Parse(ep.DefaultValue)); } else if(ep.Type == "System.Double" || ep.Type == "Double") { ddouble.Add(ep.Name, double.Parse(ep.DefaultValue)); } else if(ep.Type == "System.Int" || ep.Type == "Int") { dint.Add(ep.Name, int.Parse(ep.DefaultValue)); } else if(ep.Type == "System.String" || ep.Type == "String") { dstr.Add(ep.Name, ep.DefaultValue); } else { throw new InvalidOperationException($"Unsupported property type: {ep.Type}"); } } return new ElementProperties(isOpen, dbool, ddouble, dint, dstr); } }