예제 #1
0
        private ReturnCode AttachMarshalerDelegates(IntPtr ts, DatabaseMarshaler marshaler)
        {
            Gapi._TypeSupport typeSupport = null;
            IntPtr            tsPtr       = IntPtr.Zero;
            ReturnCode        result      = ReturnCode.Ok;

            typeSupport = Gapi.TypeSupport.Claim(ts, out tsPtr, ref result);
            if (result == ReturnCode.Ok)
            {
                typeSupport.copy_in = marshaler.CopyInDelegate;

                // HACK: This is a Mono workaround. Currently you cannot marshal a delegate
                // to a function pointer if the parameters include an "object" type. So we
                // will pass a fake delegate, and then internally use the real copyOut, this
                // may give better performance anyways, since we won't have to convert the
                // IntPtr to a Delegate for every ReaderCopy invocation.
                typeSupport.copy_out = marshaler.CopyOutDelegate;

                typeSupport.reader_copy = marshaler.ReaderCopyDelegate;
                Gapi.TypeSupport.Release(typeSupport, tsPtr);
            }

            return(result);
        }
예제 #2
0
 public static IntPtr Release(_TypeSupport typeSupport, IntPtr tsPtr)
 {
     Marshal.StructureToPtr(typeSupport, tsPtr, false);
     return(Gapi.Object.Release(tsPtr));
 }
예제 #3
0
 public static IntPtr Release(_TypeSupport typeSupport, IntPtr tsPtr)
 {
     Marshal.StructureToPtr(typeSupport, tsPtr, false);
     return Gapi.Object.Release(tsPtr);
 }