Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用C#代码(不是python)将静态类(或静态方法)导入IronPython(或DLR)?_C#_Static_Ironpython_Dynamic Language Runtime - Fatal编程技术网

如何使用C#代码(不是python)将静态类(或静态方法)导入IronPython(或DLR)?

如何使用C#代码(不是python)将静态类(或静态方法)导入IronPython(或DLR)?,c#,static,ironpython,dynamic-language-runtime,C#,Static,Ironpython,Dynamic Language Runtime,scope.SetVariable(“数学”,类型为(System.math) 或者我需要创建模块吗?您可以执行以下操作: SetVariable(“math”,dynamicchelpers.GetPythonTypeFromType(typeof(System.math)) DynamicHelpers位于IronPython.Runtime.Types.中,您知道如何创建具有父作用域的ScripScope吗?无法做到这一点-虽然作用域具有父属性ScriptScope,但不要公开此属性。作用

scope.SetVariable(“数学”,类型为(System.math)

或者我需要创建模块吗?

您可以执行以下操作:

SetVariable(“math”,dynamicchelpers.GetPythonTypeFromType(typeof(System.math))


DynamicHelpers位于IronPython.Runtime.Types.

中,您知道如何创建具有父作用域的ScripScope吗?无法做到这一点-虽然作用域具有父属性ScriptScope,但不要公开此属性。作用域上的父属性也将消失。如果要链接查找,您应该创建一个ScriptScope,其中包含您自己的自定义IAttributesCollection,它知道如何在父作用域中查找。谢谢。我发现我可以使用scope(scope parent,IAttributesCollection dictionary)创建一个具有父作用域的作用域,HostingHelpers可以从作用域创建一个ScriptScope。