/// <summary>
        ///   Finds the specified result descriptor.
        /// </summary>
        /// <param name="result">The result code.</param>
        /// <returns>A descriptor for the specified result.</returns>
        public static ResultDescriptor Find(Result result)
        {
            if (!Descriptors.TryGetValue(result, out ResultDescriptor descriptor))
            {
                descriptor = new ResultDescriptor(result, "Unknown", "Unknown", "Unknown");
            }

            return(descriptor);
        }
        /// <summary>
        ///   Determines whether the specified <see cref="ResultDescriptor"/> is equal to this instance.
        /// </summary>
        /// <param name="other">The <see cref="ResultDescriptor"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="ResultDescriptor"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(ResultDescriptor other)
        {
            if (other is null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other.Result.Equals(Result));
        }
Beispiel #3
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="InteropException"/> class.
 /// </summary>
 /// <param name="message">The message describing the exception.</param>
 /// <param name="innerException">The inner exception that caused this exception.</param>
 public InteropException(Result errorCode, Exception innerException) : base(null, innerException)
 {
     Descriptor = ResultDescriptor.Find(errorCode);
     HResult    = (int)errorCode;
 }
Beispiel #4
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="InteropException"/> class.
 /// </summary>
 /// <param name="message">The message describing the exception.</param>
 /// <param name="innerException">The inner exception that caused this exception.</param>
 public InteropException(string message, Exception innerException) : base(message, innerException)
 {
     Descriptor = Result.Fail;
     HResult    = (int)Result.Fail;
 }
Beispiel #5
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="InteropException"/> class.
 /// </summary>
 /// <param name="errorCode">The result code that caused this exception.</param>
 /// <param name="message">The message describing the exception.</param>
 public InteropException(Result errorCode, string message) : base(message)
 {
     Descriptor = ResultDescriptor.Find(errorCode);
     HResult    = (int)errorCode;
 }
Beispiel #6
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="InteropException"/> class.
 /// </summary>
 /// <param name="descriptor">The result descriptor.</param>
 public InteropException(ResultDescriptor descriptor) : base(descriptor.ToString())
 {
     Descriptor = descriptor;
     HResult    = (int)descriptor.Result;
 }
Beispiel #7
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="InteropException"/> class.
 /// </summary>
 /// <param name="errorCode">The result code that caused this exception.</param>
 public InteropException(Result errorCode) : this(ResultDescriptor.Find(errorCode))
 {
     HResult = (int)errorCode;
 }
Beispiel #8
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="InteropException"/> class.
 /// </summary>
 public InteropException() : base("An Interop exception occurred.")
 {
     Descriptor = Result.Fail;
     HResult    = (int)Result.Fail;
 }