forked from pythonnet/pythonnet
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathDynamicClassLookUpObject.cs
More file actions
34 lines (31 loc) · 1.04 KB
/
DynamicClassLookUpObject.cs
File metadata and controls
34 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
namespace Python.Runtime
{
/// <summary>
/// Implements a Python type for managed DynamicClass objects that support look up (dictionaries),
/// that is, they implement ContainsKey().
/// This type is essentially the same as a ClassObject, except that it provides
/// sequence semantics to support natural dictionary usage (__contains__ and __len__)
/// from Python.
/// </summary>
internal class DynamicClassLookUpObject : DynamicClassObject
{
internal DynamicClassLookUpObject(Type tp) : base(tp)
{
}
/// <summary>
/// Implements __len__ for dictionary types.
/// </summary>
public static int mp_length(BorrowedReference ob)
{
return LookUpObject.mp_length(ob);
}
/// <summary>
/// Implements __contains__ for dictionary types.
/// </summary>
public static int sq_contains(BorrowedReference ob, BorrowedReference v)
{
return LookUpObject.sq_contains(ob, v);
}
}
}