コード例 #1
0
 public static void ThrowIfFailed(this HResult result, string path = null)
 {
     if (result.Failed())
     {
         throw result.GetException(path);
     }
 }
コード例 #2
0
    public void GetExceptionWithErrorInfo(HResult.Code hrCode)
    {
        HResult   hr       = hrCode;
        Exception expected = Marshal.GetExceptionForHR(hr);
        Exception actual   = hr.GetException(IntPtr.Zero); // Consider actually initializing this.

        if (expected == null)
        {
            Assert.Null(actual);
        }
        else
        {
            Assert.IsType(expected.GetType(), actual);
            Assert.Equal(expected.Message, actual.Message);
        }
    }
コード例 #3
0
    public void GetException(HResult.Code hrCode)
    {
        HResult   hr       = hrCode;
        Exception expected = Marshal.GetExceptionForHR(hr);
        Exception actual   = hr.GetException();

        if (expected == null)
        {
            Assert.Null(actual);
        }
        else
        {
            Assert.IsType(expected.GetType(), actual);
            Assert.Equal(expected.Message, actual.Message);
        }
    }
コード例 #4
0
 public static void Throw(this HResult result, string?path = null) => throw result.GetException(path);
コード例 #5
0
 public static void Throw(this HResult result) => throw result.GetException();
コード例 #6
0
 public static void Throw(this HResult result, string?detail = null) => throw result.GetException(detail);