forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIPyObjectDecoder.cs
More file actions
22 lines (20 loc) · 792 Bytes
/
IPyObjectDecoder.cs
File metadata and controls
22 lines (20 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
namespace Python.Runtime;
using System;
/// <summary>
/// Defines <see cref="PyObject"/> conversion to CLR types (unmarshalling)
/// </summary>
public interface IPyObjectDecoder
{
/// <summary>
/// Checks if this decoder can decode from <paramref name="objectType"/> to <paramref name="targetType"/>
/// </summary>
bool CanDecode(PyType objectType, Type targetType);
/// <summary>
/// Attempts do decode <paramref name="pyObj"/> into a variable of specified type
/// </summary>
/// <typeparam name="T">CLR type to decode into</typeparam>
/// <param name="pyObj">Object to decode</param>
/// <param name="value">The variable, that will receive decoding result</param>
/// <returns></returns>
bool TryDecode<T>(PyObject pyObj, out T? value);
}