// プロパティから値を取得しようとしたときに呼ばれる public override bool TryGetMember(GetMemberBinder binder, out object result) { Py.IncRef(_pyObject); result = _pyObject[binder.Name]; return(true); }
// プロパティに値を設定しようとしたときに呼ばれる public override bool TrySetMember(SetMemberBinder binder, object value) { Py.IncRef(_pyObject); if (value is int[] intArray) { _pyObject[binder.Name] = (PyArray <int>)intArray; } else if (value is float[] floatArray) { _pyObject[binder.Name] = (PyArray <float>)floatArray; } else if (value is double[] doubleArray) { _pyObject[binder.Name] = (PyArray <double>)doubleArray; } else if (value is PyArray <float> floatPyArray) { _pyObject[binder.Name] = floatPyArray; } else if (value is PyArray <double> doublePyArray) { _pyObject[binder.Name] = doublePyArray; } else if (value is PyArray <int> intPyArray) { _pyObject[binder.Name] = intPyArray; } else { _pyObject[binder.Name] = (PyObject)value; } return(true); }