
import clr
import sys
import os
import System

def inspect_plugin_class(dll_path):
    print(f"Inspecting Plugin Class in: {dll_path}")
    
    if not os.path.exists(dll_path):
        print("  File not found.")
        return

    try:
        clr.AddReference(dll_path)
        from com.omnesys.rithmic.plugin import RithmicPlugin
        
        t = RithmicPlugin
        print(f"Type: {t.__name__}")
        print(f"Assembly: {t.__module__}")
        
        print("Methods:")
        # pythonnetで型オブジェクトからメソッド一覧を取得するには dir() が確実だが、
        # 反射的に GetMethods を使う場合は System.Type を経由する必要があるかも
        import System
        clr_type = clr.GetClrType(t)
        for m in clr_type.GetMethods():
            if m.IsPublic:
                params = [f"{p.ParameterType.Name} {p.Name}" for p in m.GetParameters()]
                print(f"  - {m.Name}({', '.join(params)})")
                
    except Exception as e:
        print(f"  Error inspecting class: {e}")

if __name__ == "__main__":
    dll_dir = r"C:\Program Files (x86)\Rithmic\Rithmic Trader Pro"
    sys.path.append(dll_dir)
    target = os.path.join(dll_dir, "RithmicPlugin.dll")
    inspect_plugin_class(target)
