public DBusInterfaceVTable(DBusInterfaceMethodCallFunc method_call, DBusInterfaceGetPropertyFunc get_property, DBusInterfaceSetPropertyFunc set_property) { this.method_call = method_call; this.get_property = get_property; this.set_property = set_property; native_cbs.method_call = OnMethodCall; native_cbs.get_property = OnGetProperty; native_cbs.set_property = OnSetProperty; handle = Marshaller.StructureToPtrAlloc(native_cbs); }
IntPtr AllocNativeElement(object element) { if (element_type == null) { if (element is IWrapper) { return((element as IWrapper).Handle); } else { return((IntPtr)GCHandle.Alloc(element)); } } else { if (element_type == typeof(string)) { return(Marshaller.StringToPtrGStrdup(element as string)); } else if (element_type == typeof(FilenameString)) { return(Marshaller.StringToFilenamePtr(element as string)); } else if (element_type == typeof(IntPtr)) { return((IntPtr)GCHandle.Alloc(element)); } else if (typeof(IWrapper).IsAssignableFrom(element_type)) { return((element as IWrapper).Handle); } else if (element_type == typeof(int)) { return(new IntPtr((int)element)); } else if (element_type.IsValueType) { return(Marshaller.StructureToPtrAlloc(element)); } } return(IntPtr.Zero); }