Ejemplo n.º 1
0
        public IntPtr MarshalManagedToNative(object managedObj)
        {
#if RECURSIVE_WRAPPING
            managedObj = NativeToManagedWrapper.GetInterface(ManagedToNativeWrapper.GetInterface((IStream)managedObj), true);
#endif
            return(ManagedToNativeWrapper.GetInterface((IStream)managedObj));
        }
Ejemplo n.º 2
0
        public object MarshalNativeToManaged(IntPtr pNativeData)
        {
#if RECURSIVE_WRAPPING
            pNativeData = ManagedToNativeWrapper.GetInterface(NativeToManagedWrapper.GetInterface(pNativeData, true));
#endif
            return(NativeToManagedWrapper.GetInterface(pNativeData, false));
        }
Ejemplo n.º 3
0
            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
            }
Ejemplo n.º 4
0
            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);
            }
Ejemplo n.º 5
0
            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
            }
Ejemplo n.º 6
0
            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
            }
Ejemplo n.º 7
0
 public void CleanUpNativeData(IntPtr pNativeData)
 {
     ManagedToNativeWrapper.ReleaseInterface(pNativeData);
 }