Example #1
0
        private static T LoadInteropType <T>(IntPtr library, NetNativeLibLoader.Loader.IPlatformLoader loader)
            where T : new()
        {
            var result = new T();

            LoadDelegates(result, library, loader);
            return(result);
        }
Example #2
0
 private static void LoadDelegates(object o, IntPtr library, NetNativeLibLoader.Loader.IPlatformLoader loader)
 {
     foreach (var property in o.GetType().GetProperties())
     {
         var entryName = property.GetCustomAttributes().OfType <NativeSymbolAttribute>().First().Entrypoint;
         var symbol    = loader.LoadSymbol(library, entryName);
         property.SetValue(o, Marshal.GetDelegateForFunctionPointer(symbol, property.PropertyType));
     }
 }