Forum Discussion

Lagencie's avatar
Lagencie
Frequent Contributor
6 years ago

Create a generic List from C# dll in python script

Using my C# dll in TestComplete as CLR Bridge and want to create a python script routine where I initialize the settings.SpecificValue with a List of SpecificValueClass Objects. Does someone know how...
  • Lagencie's avatar
    Lagencie
    6 years ago

     

    typeListOf = dotNET.System.Type.GetType("System.Collections.Generic.List`1")
    objType = dotNET.namespace.SpecificValueClass.zctor().GetType()
    paramTypes = dotNET.System.Array.CreateInstance(dotNET.System.Type.GetType("System.Type"), 1)
    paramTypes.SetValue(objType, 0)
    typeListOfString = typeListOf.MakeGenericType(paramTypes)
    
    newValue = dotNET.namespace.WattPeakValues.zctor()
    
    newValue.ID = 1
    settings.SpecificValue.Add(newValue)

     

     

    Got it to work! You have to programm the part that usually C# makes for you with the <T> ... little confusing but it works now