Ejemplo n.º 1
0
 private static int GetTrustLevel(IntPtr thisPtr, IntPtr trustLevel)
 {
     try
     {
         InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
         IInspectable      callback = (IInspectable)shadow.Callback;
         // Write full trust
         Marshal.WriteInt32(trustLevel, (int)TrustLevel.FullTrust);
     }
     catch (Exception exception)
     {
         return((int)Result.GetResultFromException(exception));
     }
     return(Result.Ok.Code);
 }
Ejemplo n.º 2
0
            private static unsafe int GetRuntimeClassName(IntPtr thisPtr, IntPtr *className)
            {
                try
                {
                    InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
                    IInspectable      callback = (IInspectable)shadow.Callback;
                    // Use the name of the callback class

                    string name = callback.GetType().FullName;
                    Win32.WinRTStrings.WindowsCreateString(name, (uint)name.Length, out IntPtr str);
                    *className = str;
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }
Ejemplo n.º 3
0
            private static unsafe int GetIids(IntPtr thisPtr, int *iidCount, IntPtr *iids)
            {
                try
                {
                    InspectableShadow shadow   = ToShadow <InspectableShadow>(thisPtr);
                    IInspectable      callback = (IInspectable)shadow.Callback;

                    ShadowContainer container = callback.Shadow;

                    int countGuids = container.Guids.Length;

                    // Copy GUIDs deduced from Callback
                    iids = (IntPtr *)Marshal.AllocCoTaskMem(IntPtr.Size * countGuids);
                    *iidCount = countGuids;

                    MemoryHelpers.CopyMemory((IntPtr)iids, new ReadOnlySpan <IntPtr>(container.Guids));
                }
                catch (Exception exception)
                {
                    return((int)Result.GetResultFromException(exception));
                }
                return(Result.Ok.Code);
            }