public IntPtr MarshalManagedToNative(object managedObj) { #if RECURSIVE_WRAPPING managedObj = NativeToManagedWrapper.GetInterface(ManagedToNativeWrapper.GetInterface((IStream)managedObj), true); #endif return(ManagedToNativeWrapper.GetInterface((IStream)managedObj)); }
public object MarshalNativeToManaged(IntPtr pNativeData) { #if RECURSIVE_WRAPPING pNativeData = ManagedToNativeWrapper.GetInterface(NativeToManagedWrapper.GetInterface(pNativeData, true)); #endif return(NativeToManagedWrapper.GetInterface(pNativeData, false)); }
private static int Release(IntPtr @this) { #if MAP_EX_TO_HR try { #endif ManagedToNativeWrapper thisObject = GetObject(@this); lock (thisObject) { if ((thisObject.refCount != 0) && (--thisObject.refCount == 0)) { thisObject.Dispose(); } return(thisObject.refCount); } #if MAP_EX_TO_HR } catch { return(0); } #endif }
internal static IStream GetInterface(IntPtr comInterface, bool outParam) { IStream managedInterface; if (comInterface == IntPtr.Zero) { return(null); } #if !RECURSIVE_WRAPPING else if ((managedInterface = ManagedToNativeWrapper.GetUnderlyingInterface(comInterface, outParam)) == null) #endif managedInterface = (IStream) new NativeToManagedWrapper(comInterface, outParam); return(managedInterface); }
private static int Clone(IntPtr @this, out IntPtr ppstm) { ppstm = IntPtr.Zero; #if MAP_EX_TO_HR try { #endif IStream newInterface; GetObject(@this).managedInterface.Clone(out newInterface); ppstm = ManagedToNativeWrapper.GetInterface(newInterface); return(S_OK); #if MAP_EX_TO_HR } catch (Exception e) { return(GetHRForException(e)); } #endif }
private static int AddRef(IntPtr @this) { #if MAP_EX_TO_HR try { #endif ManagedToNativeWrapper thisObject = GetObject(@this); lock (thisObject) { return(++thisObject.refCount); } #if MAP_EX_TO_HR } catch { return(0); } #endif }
public void CleanUpNativeData(IntPtr pNativeData) { ManagedToNativeWrapper.ReleaseInterface(pNativeData); }