/// <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) { ResultDescriptor descriptor; // Check also SharpDX registered result descriptors lock (LockDescriptor) { if (RegisteredDescriptorProvider.Count > 0) { foreach (var type in RegisteredDescriptorProvider) { AddDescriptorsFromType(type); } RegisteredDescriptorProvider.Clear(); } if (!Descriptors.TryGetValue(result, out descriptor)) { descriptor = new ResultDescriptor(result, UnknownText, UnknownText, UnknownText); } // If description is null, than we try to add description from Win32 GetDescriptionFromResultCode // Or we use unknown description if (descriptor.Description == null) { // Check if a Win32 description exist var description = GetDescriptionFromResultCode(result.Code); descriptor.Description = description ?? UnknownText; } } return(descriptor); }
/// <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) { ResultDescriptor descriptor; if (!Descriptors.TryGetValue(result, out descriptor)) { descriptor = new ResultDescriptor(result, UnknownText, UnknownText, UnknownText); } 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 (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.Result.Equals(this.Result)); }
public SharpGenException(ResultDescriptor descriptor, string message, Exception?innerException = null, params object[] args) : this(descriptor.Result, descriptor, string.Format(CultureInfo.InvariantCulture, message, args), innerException) { }
public SharpGenException(ResultDescriptor descriptor, string?message = null, Exception?innerException = null) : this(descriptor.Result, descriptor, message ?? descriptor.ToString(), innerException) { }
public SharpGenException(Result result, Exception?innerException = null) : this(ResultDescriptor.Find(result), innerException : innerException) { }
/// <summary> /// Initializes a new instance of the <see cref="T:SharpDX.SharpDXException"/> class. /// </summary> /// <param name="result">The error result code.</param> /// <param name="message">The message describing the exception.</param> /// <param name="args">formatting arguments</param> public SharpGenException(Result result, string message, params object[] args) : base(string.Format(CultureInfo.InvariantCulture, message, args)) { this.descriptor = ResultDescriptor.Find(result); HResult = (int)result; }
/// <summary> /// Initializes a new instance of the <see cref="T:SharpDX.SharpDXException"/> class. /// </summary> /// <param name="result">The error result code.</param> /// <param name="message">The message describing the exception.</param> public SharpGenException(Result result, string message) : base(message) { this.descriptor = ResultDescriptor.Find(result); HResult = (int)result; }
/// <summary> /// Initializes a new instance of the <see cref="T:SharpDX.SharpDXException"/> class. /// </summary> /// <param name="descriptor">The result descriptor.</param> public SharpGenException(ResultDescriptor descriptor) : base(descriptor.ToString()) { this.descriptor = descriptor; HResult = (int)descriptor.Result; }
/// <summary> /// Initializes a new instance of the <see cref = "T:SharpDX.SharpDXException" /> class. /// </summary> /// <param name = "result">The result code that caused this exception.</param> public SharpGenException(Result result) : this(ResultDescriptor.Find(result)) { HResult = (int)result; }
/// <summary> /// Initializes a new instance of the <see cref = "T:SharpDX.SharpDXException" /> class. /// </summary> public SharpGenException() : base("A SharpDX exception occurred.") { this.descriptor = ResultDescriptor.Find(Result.Fail); HResult = (int)Result.Fail; }
/// <summary> /// Initializes a new instance of the <see cref = "T:SharpDX.SharpDXException" /> class. /// </summary> /// <param name = "message">The message describing the exception.</param> /// <param name = "innerException">The exception that caused this exception.</param> /// <param name="args">formatting arguments</param> public SharpGenException(string message, Exception innerException, params object[] args) : base(string.Format(CultureInfo.InvariantCulture, message, args), innerException) { this.descriptor = ResultDescriptor.Find(Result.Fail); HResult = (int)Result.Fail; }