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

def search_all():
    dll_dir = os.path.join(os.getcwd(), "libs")
    sys.path.append(dll_dir)
    
    # すべてのDLLをロード
    for f in os.listdir(dll_dir):
        if f.endswith(".dll"):
            try:
                clr.AddReference(f)
                print(f"Loaded: {f}")
            except:
                pass
    
    assembly_rapi = None
    for a in AppDomain.CurrentDomain.GetAssemblies():
        if "rapiplus" in a.FullName.lower():
            assembly_rapi = a
            break
            
    if not assembly_rapi:
        print("rapiplus not found")
        return
        
    t_base = assembly_rapi.GetType("com.omnesys.rapi.AdmCallbacks")
    if not t_base:
        print("AdmCallbacks not found in rapiplus")
        return
        
    print(f"Searching for classes derived from {t_base.FullName}...")
    
    for a in AppDomain.CurrentDomain.GetAssemblies():
        try:
            for t in a.GetTypes():
                if t.IsSubclassOf(t_base) and not t.IsAbstract:
                    print(f"FOUND CONCRETE: {t.FullName} in {a.GetName().Name}")
                elif t.FullName == t_base.FullName and t != t_base:
                    print(f"WARNING: Multiple types named {t.FullName} found!")
        except:
             pass

if __name__ == "__main__":
    search_all()
