Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Think of a mechanism for different resolution of conversion conflicts #15

Open
Konard opened this issue Aug 13, 2019 · 0 comments
Open

Comments

@Konard
Copy link
Member

Konard commented Aug 13, 2019

Based on:

Converters/To.cs

Lines 12 to 18 in 8c59403

/// Возможно нужно несколько разных способов разрешения конфликта.
/// ExceptionConflictReation (выбрасывает исключение, если обнаружен конфликт, не предпринимая никаких действий)
/// > Max: Max (если число больше его максимального размера в этом размере, то берём максимальное)
/// > Max: 0 (если число больше его максимального размера в этом размере, то берём обнуляем)
/// и т.п. (например определённые пользователем)
///
/// Текущая логика алгоритма "Closest value"

If a source type value is greater than the target type's MaxValue it is called a conversion conflict.

The current way to resolve it is to use target type's MaxValue as the closest matching value.

There different ways to resolve the same conflict:

  • Throw an exception.
  • Reset value to default.
  • System.Convert logic.
  • Use of explicit IConvertible interface implementations, for example Int64.IConvertible.ToInt32
  • Other user-defined behavior.
Konard added a commit that referenced this issue Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant