
import clr
import sys
import os
import System
from System import AppDomain

def list_interfaces():
    dll_dir = os.path.join(os.getcwd(), "libs")
    sys.path.append(dll_dir)
    clr.AddReference("rapiplus")
    
    assembly = None
    for a in AppDomain.CurrentDomain.GetAssemblies():
        if "rapiplus" in a.FullName.lower():
            assembly = a
            break
    if not assembly: return
    
    results = []
    for t in assembly.GetTypes():
        if t.IsInterface:
            results.append(f"Interface: {t.FullName}")
            for m in t.GetMethods():
                params = [f"{p.ParameterType.Name} {p.Name}" for p in m.GetParameters()]
                results.append(f"  Method: {m.Name}({', '.join(params)})")
        
    with open("interfaces.txt", "w") as f:
        f.write("\n".join(results))
    print("Done. Results in interfaces.txt")

if __name__ == "__main__":
    list_interfaces()
