| | 1 | | using System; |
| | 2 | |
|
| | 3 | | namespace SharpHoundCommonLib { |
| | 4 | | public class LdapResult<T> : Result<T> |
| | 5 | | { |
| 29 | 6 | | public string QueryInfo { get; set; } |
| 29 | 7 | | public int ErrorCode { get; set; } |
| | 8 | |
|
| 58 | 9 | | protected LdapResult(T value, bool success, string error, string queryInfo, int errorCode) : base(value, success |
| 29 | 10 | | QueryInfo = queryInfo; |
| 29 | 11 | | ErrorCode = errorCode; |
| 29 | 12 | | } |
| | 13 | |
|
| 16 | 14 | | public new static LdapResult<T> Ok(T value) { |
| 16 | 15 | | return new LdapResult<T>(value, true, string.Empty, null, 0); |
| 16 | 16 | | } |
| | 17 | |
|
| 13 | 18 | | public new static LdapResult<T> Fail() { |
| 13 | 19 | | return new LdapResult<T>(default, false, string.Empty, null, 0); |
| 13 | 20 | | } |
| | 21 | |
|
| 0 | 22 | | public static LdapResult<T> Fail(string message, LdapQueryParameters queryInfo) { |
| 0 | 23 | | return new LdapResult<T>(default, false, message, queryInfo.GetQueryInfo(), 0); |
| 0 | 24 | | } |
| | 25 | |
|
| 0 | 26 | | public static LdapResult<T> Fail(string message, LdapQueryParameters queryInfo, int errorCode) { |
| 0 | 27 | | return new LdapResult<T>(default, false, message, queryInfo.GetQueryInfo(), errorCode); |
| 0 | 28 | | } |
| | 29 | | } |
| | 30 | | } |