From a8f5db9489daa146407fd608e08ac1a26a93bd55 Mon Sep 17 00:00:00 2001 From: SnGmng <38666407+SnGmng@users.noreply.github.com> Date: Fri, 18 Oct 2019 19:23:02 +0200 Subject: [PATCH 1/3] add dictionary conversion --- src/runtime/converter.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/runtime/converter.cs b/src/runtime/converter.cs index e7e047419..82ff0733d 100644 --- a/src/runtime/converter.cs +++ b/src/runtime/converter.cs @@ -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. From ea4425c40f1f4e4a3cd2872de21857eca7c8df5a Mon Sep 17 00:00:00 2001 From: SnGmng <38666407+SnGmng@users.noreply.github.com> Date: Fri, 18 Oct 2019 19:32:24 +0200 Subject: [PATCH 2/3] Update AUTHORS.md --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 9253c7e55..679f24bb2 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -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)) From 6b430964d117eae254523c0f05e151c71d2d23da Mon Sep 17 00:00:00 2001 From: SnGmng <38666407+SnGmng@users.noreply.github.com> Date: Fri, 18 Oct 2019 19:45:43 +0200 Subject: [PATCH 3/3] Add Dictionary to PyDict conversion to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e24a46904..5eabfe74e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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