ITypeConverter.cs 596 B

12345678910111213141516171819
  1. using System.Diagnostics.CodeAnalysis;
  2. namespace Jint.Runtime.Interop;
  3. /// <summary>
  4. /// Handles conversions between CLR types.
  5. /// </summary>
  6. public interface ITypeConverter
  7. {
  8. /// <summary>
  9. /// Converts value to to type. Throws exception if cannot be done.
  10. /// </summary>
  11. object? Convert(object? value, Type type, IFormatProvider formatProvider);
  12. /// <summary>
  13. /// Converts value to to type. Returns false if cannot be done.
  14. /// </summary>
  15. bool TryConvert(object? value, Type type, IFormatProvider formatProvider, [NotNullWhen(true)] out object? converted);
  16. }