- Introduced simulation timers in `FlyingStartStopTestOp`. - Added `Simulate` methods in `WaterMetrologyData`, `WaterMetrologyDataC7`, and `WaterMetrologyDataC2`. - Enhanced `SmartCommunicationForm` with textbox resizing logic and initialization code. - Implemented flow rate and volume calculation from optohead telemetry in `SmartReader`. - Added unit tests for Poseidon correction parsing.
30 lines
893 B
C#
30 lines
893 B
C#
using System;
|
|
using System.ComponentModel;
|
|
|
|
namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.implementations
|
|
{
|
|
public static class EnumExtensions
|
|
{
|
|
public static bool TryParseByDescription<TEnum>(string description, out TEnum result)
|
|
where TEnum : struct, Enum
|
|
{
|
|
foreach (var field in typeof(TEnum).GetFields())
|
|
{
|
|
var attribute = Attribute.GetCustomAttribute(field,
|
|
typeof(DescriptionAttribute)) as DescriptionAttribute;
|
|
|
|
if ((attribute != null && attribute.Description == description) ||
|
|
field.Name == description)
|
|
{
|
|
result = (TEnum)field.GetValue(null);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
result = default;
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
} |