X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- ([@OneBlue](https://github.com/OneBlue))
- ([@rico-chet](https://github.com/rico-chet))
- ([@rmadsen-ks](https://github.com/rmadsen-ks))
- ([@SnGmng](https://github.com/SnGmng))
- ([@stonebig](https://github.com/stonebig))
- ([@testrunner123](https://github.com/testrunner123))

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
### Added

- Added automatic NuGet package generation in appveyor and local builds
- Added Dictionary to PyDict conversion to the function ToPython()

### Changed

Expand Down
18 changes: 18 additions & 0 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,24 @@ internal static IntPtr ToPython(object value, Type type)
return resultlist.Handle;
}
}
else if (value is IDictionary && !(value is INotifyPropertyChanged) && value.GetType().IsGenericType)
{
using (var resultdict = new PyDict())
{
foreach (DictionaryEntry o in (IDictionary)value)
{
using (var k = new PyObject(ToPython(o.Key, o.Key?.GetType())))
{
using (var v = new PyObject(ToPython(o.Value, o.Value?.GetType())))
{
resultdict.SetItem(k, v);
}
}
}
Runtime.XIncref(resultdict.Handle);
return resultdict.Handle;
}
}

// it the type is a python subclass of a managed type then return the
// underlying python object rather than construct a new wrapper object.
Expand Down
X Tutup