src/Kingdom.OrTools.Sat.Parameters.Core/Implementation/ParameterValueRenderingOptions.cs
/// <summary>
/// Rendering an <see cref="Enum"/> <paramref name="value"/> is a bit of a special case,
/// but it is not that special of a case given a bit of introspection exposed by the
/// Parameters API.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
Rendering an   is a bit of a special case,
but it is not that special of a case given a bit of introspection exposed by the
Parameters API.
Rendering an is a bit of a special case but it is not that special of a case given a bit of introspection exposed by the Parameters API .
private static string RenderEnumParameterValue(object value)
        {
            var valueType = value.GetType();
            if (!valueType.IsEnum)
            {
                throw new InvalidOperationException($"Unexpected enum type `{valueType.FullName}´.");
            }
            var defaultRendering = $"{value}";
            var fi = valueType.GetField(defaultRendering);
            return fi.GetCustomAttribute<ParameterMemberNameAttribute>()?.MemberName ?? defaultRendering;
        }
private static string RenderEnumParameterValue ( object value ) { var valueType = value . GetType ( ) ; if ( ! valueType . IsEnum ) { throw new InvalidOperationException ( $" Unexpected enum type ` { valueType . FullName } ´." ) ; } var defaultRendering = $" { value } " ; var fi = valueType . GetField ( defaultRendering ) ; return fi . GetCustomAttribute < ParameterMemberNameAttribute > ( ) ? . MemberName ?? defaultRendering ; }
Rendering an   is a bit of a special case,
but it is not that special of a case given a bit of introspection exposed by the
Parameters API.
Rendering an is a bit of a special case but it is not that special of a case given a bit of introspection exposed by the Parameters API .
// TODO: TBD: ditto test case comments... FieldName and not MemberName ...
None
value
object
None