I'm trying to access .Net(C#) enums in IronPython, lets say we have
Test.dll
// Contains Several Enums
enum TestType{..}
enum TestQuality{..}
....
....
enum TestStatus{..}
//Similarly Multiple functions
public void StartTest(TestType testType, TestQuality testQuality){..}
....
....
public TestStatus GetTestStatus(){..}
and now if I try to call the above functions, I need to choose the appropriate enum parameters and so far what I did is this,
Iron Python [vs2012]
import clr
clr.AddReference('Test.dll')
from TestDll import *
test = Test()
# Initiate Enums
enumTestType = TestType
enumTestQuality = TestQuality
....
....
enumTestStatus = TestStatus
#Call Functions
test.StartTest(enumTestType.Basic, enumTestQuality.High)
....
....
# goes on
now the above IronPython code works fine, the only odd bit here is that I need to initiate all the enums(Intellisence doesnt work here) before I use them with the functions, this will become more difficult when there are more enums to use. whereas in C# environment(vs2012) we dont have to initiate but we can use them straight away when calling functions.
Is there a better way of dealing this in IronPython?
Please correct me if I'm wrong, thanks!
Assuming the enums are contained within your
Test
class you can either use them fully qualifiedor by importing
If the enums are in the same namespace as the
Test
class they should be usable without additional imports: