diff --git a/src/ScadaLink.Commons/Types/ValueFormatter.cs b/src/ScadaLink.Commons/Types/ValueFormatter.cs index 58258b4..9e70d4e 100644 --- a/src/ScadaLink.Commons/Types/ValueFormatter.cs +++ b/src/ScadaLink.Commons/Types/ValueFormatter.cs @@ -1,12 +1,10 @@ using System.Collections; -using System.Reflection; namespace ScadaLink.Commons.Types; /// /// Formats attribute values for display. Handles scalar types directly -/// and uses reflection to extract array contents from complex types -/// (e.g., LmxProxy ArrayValue) rather than showing the type name. +/// and converts arrays/collections to comma-separated strings. /// public static class ValueFormatter { @@ -21,15 +19,6 @@ public static class ValueFormatter if (value is string s) return s; if (value is IFormattable) return value.ToString() ?? ""; - // Check if it's an array-like container with typed sub-collections - // (e.g., LmxProxy ArrayValue with BoolValues, Int32Values, etc.) - var type = value.GetType(); - if (type.Namespace?.Contains("LmxProxy") == true || type.Name == "ArrayValue") - { - return FormatArrayContainer(value, type); - } - - // Fallback for IEnumerable (generic collections, arrays) if (value is IEnumerable enumerable) { return string.Join(",", enumerable.Cast().Select(e => e?.ToString() ?? "")); @@ -37,23 +26,4 @@ public static class ValueFormatter return value.ToString() ?? ""; } - - private static string FormatArrayContainer(object container, Type type) - { - // Look for the first non-null property that has a Values list - foreach (var prop in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) - { - var propValue = prop.GetValue(container); - if (propValue is null) continue; - - // Check if this property has a Values sub-property (e.g., BoolArray.Values) - var valuesProp = propValue.GetType().GetProperty("Values"); - if (valuesProp?.GetValue(propValue) is IEnumerable values) - { - return string.Join(",", values.Cast().Select(e => e?.ToString() ?? "")); - } - } - - return ""; - } } diff --git a/src/ScadaLink.DataConnectionLayer/Adapters/LmxProxyDataConnection.cs b/src/ScadaLink.DataConnectionLayer/Adapters/LmxProxyDataConnection.cs index 6cd264b..98b30e1 100644 --- a/src/ScadaLink.DataConnectionLayer/Adapters/LmxProxyDataConnection.cs +++ b/src/ScadaLink.DataConnectionLayer/Adapters/LmxProxyDataConnection.cs @@ -234,8 +234,8 @@ public class LmxProxyDataConnection : IDataConnection /// /// Normalizes a Vtq value for consumption by the rest of the system. - /// Converts LmxProxy ArrayValue objects to comma-separated strings - /// so downstream code doesn't need to know about LmxProxy domain types. + /// Converts .NET arrays (bool[], int[], DateTime[], etc.) to comma-separated + /// display strings so downstream code sees simple string representations. /// private static object? NormalizeValue(object? value) => value switch {