Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }