2012-04-07 1 views
0

J'intègre Mono dans une application MacOSX écrite en Objective-c.Incorporation de Mono dans un projet Objective-c: Comment gérer la liste retournée <>

J'accède à un C# lib (DDL), qui contient seulement un tas de méthodes statiques retournant différents types. Jusqu'à présent, je peux être retourné avec succès int, double et chaîne, mais je ne parviens pas à récupérer un tableau retourné ...

Pour exemple, voici comment je récupère un int:

MonoDomain *domain = mono_jit_init("TestDomain"); 

NSBundle* mainBundle = [NSBundle mainBundle]; 
NSString* dll = [mainBundle pathForResource:@"TestLib86" ofType:@"dll"]; 

MonoAssembly* assembly = mono_domain_assembly_open(domain, [dll UTF8String]); 

MonoImage* image = mono_assembly_get_image(assembly); 

// Get INTEGER 

// get a method handle to whatever you like 
const char* descAsString = "MiniLib86.Show:GetInt()"; 
MonoMethodDesc* description = mono_method_desc_new(descAsString,TRUE); 
MonoMethod* method = mono_method_desc_search_in_image(description, image); 

// call it 
void* args[0]; 
MonoObject *result = mono_runtime_invoke(method, NULL, args, NULL);  
int int_result = *(int*)mono_object_unbox (result); 

// See the result in log 
NSLog(@"int result %i", int_result); 

La méthode dans C# qui renvoie une liste ressemble à ceci:

public static List<int> GetListInt() 
{ 
    return new System.Collections.Generic.List<int>{1,2,3,4,5}; 
} 

Toute aide serait vraiment appréciée!

Répondre

0

Jetez un oeil à mono_runtime_invoke_array.

Questions connexes