public NativeMethods(UnmanagedLibrary library) { this.faiss_Index_add = GetMethodDelegate <Delegates.faiss_Index_add_delegate>(library); this.faiss_Index_add_with_ids = GetMethodDelegate <Delegates.faiss_Index_add_with_ids_delegate>(library); this.faiss_Index_ntotal = GetMethodDelegate <Delegates.faiss_Index_ntotal_delegate>(library); this.faiss_Index_is_trained = GetMethodDelegate <Delegates.faiss_Index_is_trained_delegate>(library); this.faiss_Index_free = GetMethodDelegate <Delegates.faiss_Index_free_delegate>(library); this.faiss_Index_search = GetMethodDelegate <Delegates.faiss_Index_search_delegate>(library); this.faiss_IndexFlat_new = GetMethodDelegate <Delegates.faiss_IndexFlat_new_delegate>(library); this.faiss_IndexFlat_new_with = GetMethodDelegate <Delegates.faiss_IndexFlat_new_with_delegate>(library); this.faiss_IndexFlat_free = GetMethodDelegate <Delegates.faiss_IndexFlat_free_delegate>(library); this.faiss_IndexFlatL2_new = GetMethodDelegate <Delegates.faiss_IndexFlatL2_new_delegate>(library); this.faiss_IndexFlatL2_new_with = GetMethodDelegate <Delegates.faiss_IndexFlatL2_new_with_delegate>(library); this.faiss_IndexIDMap_new = GetMethodDelegate <Delegates.faiss_IndexIDMap_new_delegate>(library); }
private static T GetMethodDelegate <T>(UnmanagedLibrary library) where T : class { var methodName = RemoveStringSuffix(typeof(T).Name, "_delegate"); return(library.GetNativeMethodDelegate <T>(methodName)); }