64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public members surfaced by commentchecker — resolves 5,847 of 5,869 issues (99.6%) across three /fixdocs passes.
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System.Collections;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Client.UI.Helpers;
|
|
|
|
/// <summary>
|
|
/// Formats OPC UA values for display, with array support.
|
|
/// </summary>
|
|
internal static class ValueFormatter
|
|
{
|
|
/// <summary>Formats an OPC UA value for display, handling arrays and enumerables specially.</summary>
|
|
/// <param name="value">The value to format, or null.</param>
|
|
/// <returns>A string representation of the value suitable for display.</returns>
|
|
public static string Format(object? value)
|
|
{
|
|
if (value is null) return "(null)";
|
|
if (value is Array array) return FormatArray(array);
|
|
if (value is IEnumerable enumerable and not string) return FormatEnumerable(enumerable);
|
|
return value.ToString() ?? "(null)";
|
|
}
|
|
|
|
private static string FormatArray(Array array)
|
|
{
|
|
var elements = new string[array.Length];
|
|
for (var i = 0; i < array.Length; i++)
|
|
elements[i] = array.GetValue(i)?.ToString() ?? "null";
|
|
return $"[{string.Join(",", elements)}]";
|
|
}
|
|
|
|
private static string FormatEnumerable(IEnumerable enumerable)
|
|
{
|
|
var items = new List<string>();
|
|
foreach (var item in enumerable)
|
|
items.Add(item?.ToString() ?? "null");
|
|
return $"[{string.Join(",", items)}]";
|
|
}
|
|
}
|