コード例 #1
0
        // Called by the runtime to execute the abstract instance function
        internal static unsafe void *CallComputeVtables(ComWrappersScenario scenario, ComWrappers?comWrappersImpl, object obj, CreateComInterfaceFlags flags, out int count)
        {
            ComWrappers?impl = null;

            switch (scenario)
            {
            case ComWrappersScenario.Instance:
                impl = comWrappersImpl;
                break;

            case ComWrappersScenario.TrackerSupportGlobalInstance:
                impl = s_globalInstanceForTrackerSupport;
                break;

            case ComWrappersScenario.MarshallingGlobalInstance:
                impl = s_globalInstanceForMarshalling;
                break;
            }

            if (impl is null)
            {
                count = -1;
                return(null);
            }

            return(impl.ComputeVtables(obj, flags, out count));
        }
コード例 #2
0
        // Called by the runtime to execute the abstract instance function.
        internal static object?CallCreateObject(ComWrappersScenario scenario, ComWrappers?comWrappersImpl, IntPtr externalComObject, CreateObjectFlags flags)
        {
            ComWrappers?impl = null;

            switch (scenario)
            {
            case ComWrappersScenario.Instance:
                impl = comWrappersImpl;
                break;

            case ComWrappersScenario.TrackerSupportGlobalInstance:
                impl = s_globalInstanceForTrackerSupport;
                break;

            case ComWrappersScenario.MarshallingGlobalInstance:
                impl = s_globalInstanceForMarshalling;
                break;
            }

            if (impl == null)
            {
                return(null);
            }

            return(impl.CreateObject(externalComObject, flags));
        }
コード例 #3
0
        /// <summary>
        /// Create a COM representation of the supplied object that can be passed to a non-managed environment.
        /// </summary>
        /// <param name="impl">The <see cref="ComWrappers" /> implementation to use when creating the COM representation.</param>
        /// <param name="instance">The managed object to expose outside the .NET runtime.</param>
        /// <param name="flags">Flags used to configure the generated interface.</param>
        /// <param name="retValue">The generated COM interface that can be passed outside the .NET runtime or IntPtr.Zero if it could not be created.</param>
        /// <returns>Returns <c>true</c> if a COM representation could be created, <c>false</c> otherwise</returns>
        /// <remarks>
        /// If <paramref name="impl" /> is <c>null</c>, the global instance (if registered) will be used.
        /// </remarks>
        private static bool TryGetOrCreateComInterfaceForObjectInternal(ComWrappers?impl, object instance, CreateComInterfaceFlags flags, out IntPtr retValue)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            return(TryGetOrCreateComInterfaceForObjectInternal(ObjectHandleOnStack.Create(ref impl), ObjectHandleOnStack.Create(ref instance), flags, out retValue));
        }
コード例 #4
0
        // Call to execute the abstract instance function
        internal static object?CallCreateObject(ComWrappers?comWrappersImpl, IntPtr externalComObject, CreateObjectFlags flags)
        {
            ComWrappers?impl = comWrappersImpl ?? s_globalInstance;

            if (impl == null)
            {
                return(null);
            }

            return(impl.CreateObject(externalComObject, flags));
        }
コード例 #5
0
        /// <summary>
        /// Get the currently registered managed object or creates a new managed object and registers it.
        /// </summary>
        /// <param name="impl">The <see cref="ComWrappers" /> implementation to use when creating the managed object.</param>
        /// <param name="externalComObject">Object to import for usage into the .NET runtime.</param>
        /// <param name="flags">Flags used to describe the external object.</param>
        /// <param name="wrapperMaybe">The <see cref="object"/> to be used as the wrapper for the external object.</param>
        /// <param name="retValue">The managed object associated with the supplied external COM object or <c>null</c> if it could not be created.</param>
        /// <returns>Returns <c>true</c> if a managed object could be retrieved/created, <c>false</c> otherwise</returns>
        /// <remarks>
        /// If <paramref name="impl" /> is <c>null</c>, the global instance (if registered) will be used.
        /// </remarks>
        private static bool TryGetOrCreateObjectForComInstanceInternal(ComWrappers?impl, IntPtr externalComObject, CreateObjectFlags flags, object?wrapperMaybe, out object?retValue)
        {
            if (externalComObject == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(externalComObject));
            }

            object?wrapperMaybeLocal = wrapperMaybe;

            retValue = null;
            return(TryGetOrCreateObjectForComInstanceInternal(ObjectHandleOnStack.Create(ref impl), externalComObject, flags, ObjectHandleOnStack.Create(ref wrapperMaybeLocal), ObjectHandleOnStack.Create(ref retValue)));
        }
コード例 #6
0
        // Call to execute the abstract instance function
        internal static unsafe void *CallComputeVtables(ComWrappers?comWrappersImpl, object obj, CreateComInterfaceFlags flags, out int count)
        {
            ComWrappers?impl = comWrappersImpl ?? s_globalInstance;

            if (impl is null)
            {
                count = -1;
                return(null);
            }

            return(impl.ComputeVtables(obj, flags, out count));
        }
コード例 #7
0
 // Call to execute the virtual instance function
 internal static void CallReleaseObjects(ComWrappers?comWrappersImpl, IEnumerable objects)
 => (comWrappersImpl ?? s_globalInstanceForTrackerSupport !).ReleaseObjects(objects);
コード例 #8
0
ファイル: ComWrappers.cs プロジェクト: winhoals/runtime
 // Call to execute the abstract instance function
 internal static object?CallCreateObject(ComWrappers?comWrappersImpl, IntPtr externalComObject, CreateObjectFlags flags)
 => (comWrappersImpl ?? s_globalInstance !).CreateObject(externalComObject, flags);
コード例 #9
0
ファイル: ComWrappers.cs プロジェクト: winhoals/runtime
 // Call to execute the abstract instance function
 internal static unsafe void *CallComputeVtables(ComWrappers?comWrappersImpl, object obj, CreateComInterfaceFlags flags, out int count)
 => (comWrappersImpl ?? s_globalInstance !).ComputeVtables(obj, flags, out count);