mirror of
				https://github.com/JKorf/CryptoExchange.Net
				synced 2025-10-31 02:17:45 +00:00 
			
		
		
		
	Added CallResult without type parameter for calls which don't return anything
This commit is contained in:
		
							parent
							
								
									9da7683291
								
							
						
					
					
						commit
						6d7cbbb436
					
				| @ -1199,6 +1199,40 @@ | |||||||
|             <param name="y"></param> |             <param name="y"></param> | ||||||
|             <returns></returns> |             <returns></returns> | ||||||
|         </member> |         </member> | ||||||
|  |         <member name="T:CryptoExchange.Net.Objects.CallResult"> | ||||||
|  |             <summary> | ||||||
|  |             The result of an operation | ||||||
|  |             </summary> | ||||||
|  |         </member> | ||||||
|  |         <member name="P:CryptoExchange.Net.Objects.CallResult.Error"> | ||||||
|  |             <summary> | ||||||
|  |             An error if the call didn't succeed | ||||||
|  |             </summary> | ||||||
|  |         </member> | ||||||
|  |         <member name="P:CryptoExchange.Net.Objects.CallResult.Success"> | ||||||
|  |             <summary> | ||||||
|  |             Whether the call was successful | ||||||
|  |             </summary> | ||||||
|  |         </member> | ||||||
|  |         <member name="M:CryptoExchange.Net.Objects.CallResult.#ctor(CryptoExchange.Net.Objects.Error)"> | ||||||
|  |             <summary> | ||||||
|  |             ctor | ||||||
|  |             </summary> | ||||||
|  |             <param name="error"></param> | ||||||
|  |         </member> | ||||||
|  |         <member name="M:CryptoExchange.Net.Objects.CallResult.op_Implicit(CryptoExchange.Net.Objects.CallResult)~System.Boolean"> | ||||||
|  |             <summary> | ||||||
|  |             Overwrite bool check so we can use if(callResult) instead of if(callResult.Success) | ||||||
|  |             </summary> | ||||||
|  |             <param name="obj"></param> | ||||||
|  |         </member> | ||||||
|  |         <member name="M:CryptoExchange.Net.Objects.CallResult.CreateErrorResult(CryptoExchange.Net.Objects.Error)"> | ||||||
|  |             <summary> | ||||||
|  |             Create an error result | ||||||
|  |             </summary> | ||||||
|  |             <param name="error"></param> | ||||||
|  |             <returns></returns> | ||||||
|  |         </member> | ||||||
|         <member name="T:CryptoExchange.Net.Objects.CallResult`1"> |         <member name="T:CryptoExchange.Net.Objects.CallResult`1"> | ||||||
|             <summary> |             <summary> | ||||||
|             The result of an operation |             The result of an operation | ||||||
| @ -1210,16 +1244,6 @@ | |||||||
|             The data returned by the call |             The data returned by the call | ||||||
|             </summary> |             </summary> | ||||||
|         </member> |         </member> | ||||||
|         <member name="P:CryptoExchange.Net.Objects.CallResult`1.Error"> |  | ||||||
|             <summary> |  | ||||||
|             An error if the call didn't succeed |  | ||||||
|             </summary> |  | ||||||
|         </member> |  | ||||||
|         <member name="P:CryptoExchange.Net.Objects.CallResult`1.Success"> |  | ||||||
|             <summary> |  | ||||||
|             Whether the call was successful |  | ||||||
|             </summary> |  | ||||||
|         </member> |  | ||||||
|         <member name="M:CryptoExchange.Net.Objects.CallResult`1.#ctor(`0,CryptoExchange.Net.Objects.Error)"> |         <member name="M:CryptoExchange.Net.Objects.CallResult`1.#ctor(`0,CryptoExchange.Net.Objects.Error)"> | ||||||
|             <summary> |             <summary> | ||||||
|             ctor |             ctor | ||||||
| @ -1238,9 +1262,48 @@ | |||||||
|             Whether the call was successful or not. Useful for nullability checking. |             Whether the call was successful or not. Useful for nullability checking. | ||||||
|             </summary> |             </summary> | ||||||
|             <param name="data">The data returned by the call.</param> |             <param name="data">The data returned by the call.</param> | ||||||
|             <param name="error"><see cref="P:CryptoExchange.Net.Objects.CallResult`1.Error"/> on failure.</param> |             <param name="error"><see cref="T:CryptoExchange.Net.Objects.Error"/> on failure.</param> | ||||||
|             <returns><c>true</c> when <see cref="T:CryptoExchange.Net.Objects.CallResult`1"/> succeeded, <c>false</c> otherwise.</returns> |             <returns><c>true</c> when <see cref="T:CryptoExchange.Net.Objects.CallResult`1"/> succeeded, <c>false</c> otherwise.</returns> | ||||||
|         </member> |         </member> | ||||||
|  |         <member name="M:CryptoExchange.Net.Objects.CallResult`1.CreateErrorResult(CryptoExchange.Net.Objects.Error)"> | ||||||
|  |             <summary> | ||||||
|  |             Create an error result | ||||||
|  |             </summary> | ||||||
|  |             <param name="error"></param> | ||||||
|  |             <returns></returns> | ||||||
|  |         </member> | ||||||
|  |         <member name="T:CryptoExchange.Net.Objects.WebCallResult"> | ||||||
|  |             <summary> | ||||||
|  |             The result of a request | ||||||
|  |             </summary> | ||||||
|  |         </member> | ||||||
|  |         <member name="P:CryptoExchange.Net.Objects.WebCallResult.ResponseStatusCode"> | ||||||
|  |             <summary> | ||||||
|  |             The status code of the response. Note that a OK status does not always indicate success, check the Success parameter for this. | ||||||
|  |             </summary> | ||||||
|  |         </member> | ||||||
|  |         <member name="P:CryptoExchange.Net.Objects.WebCallResult.ResponseHeaders"> | ||||||
|  |             <summary> | ||||||
|  |             The response headers | ||||||
|  |             </summary> | ||||||
|  |         </member> | ||||||
|  |         <member name="M:CryptoExchange.Net.Objects.WebCallResult.#ctor(System.Nullable{System.Net.HttpStatusCode},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.Collections.Generic.IEnumerable{System.String}}},CryptoExchange.Net.Objects.Error)"> | ||||||
|  |             <summary> | ||||||
|  |             ctor | ||||||
|  |             </summary> | ||||||
|  |             <param name="code"></param> | ||||||
|  |             <param name="responseHeaders"></param> | ||||||
|  |             <param name="error"></param> | ||||||
|  |         </member> | ||||||
|  |         <member name="M:CryptoExchange.Net.Objects.WebCallResult.CreateErrorResult(System.Nullable{System.Net.HttpStatusCode},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.Collections.Generic.IEnumerable{System.String}}},CryptoExchange.Net.Objects.Error)"> | ||||||
|  |             <summary> | ||||||
|  |             Create an error result | ||||||
|  |             </summary> | ||||||
|  |             <param name="code"></param> | ||||||
|  |             <param name="responseHeaders"></param> | ||||||
|  |             <param name="error"></param> | ||||||
|  |             <returns></returns> | ||||||
|  |         </member> | ||||||
|         <member name="T:CryptoExchange.Net.Objects.WebCallResult`1"> |         <member name="T:CryptoExchange.Net.Objects.WebCallResult`1"> | ||||||
|             <summary> |             <summary> | ||||||
|             The result of a request |             The result of a request | ||||||
| @ -1266,13 +1329,6 @@ | |||||||
|             <param name="data"></param> |             <param name="data"></param> | ||||||
|             <param name="error"></param> |             <param name="error"></param> | ||||||
|         </member> |         </member> | ||||||
|         <member name="M:CryptoExchange.Net.Objects.WebCallResult`1.CreateErrorResult(CryptoExchange.Net.Objects.Error)"> |  | ||||||
|             <summary> |  | ||||||
|             Create an error result |  | ||||||
|             </summary> |  | ||||||
|             <param name="error"></param> |  | ||||||
|             <returns></returns> |  | ||||||
|         </member> |  | ||||||
|         <member name="M:CryptoExchange.Net.Objects.WebCallResult`1.CreateErrorResult(System.Nullable{System.Net.HttpStatusCode},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.Collections.Generic.IEnumerable{System.String}}},CryptoExchange.Net.Objects.Error)"> |         <member name="M:CryptoExchange.Net.Objects.WebCallResult`1.CreateErrorResult(System.Nullable{System.Net.HttpStatusCode},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.Collections.Generic.IEnumerable{System.String}}},CryptoExchange.Net.Objects.Error)"> | ||||||
|             <summary> |             <summary> | ||||||
|             Create an error result |             Create an error result | ||||||
| @ -2994,7 +3050,9 @@ | |||||||
|         <member name="M:CryptoExchange.Net.Sockets.WebsocketFactory.CreateWebsocket(CryptoExchange.Net.Logging.Log,System.String,System.Collections.Generic.IDictionary{System.String,System.String},System.Collections.Generic.IDictionary{System.String,System.String})"> |         <member name="M:CryptoExchange.Net.Sockets.WebsocketFactory.CreateWebsocket(CryptoExchange.Net.Logging.Log,System.String,System.Collections.Generic.IDictionary{System.String,System.String},System.Collections.Generic.IDictionary{System.String,System.String})"> | ||||||
|             <inheritdoc /> |             <inheritdoc /> | ||||||
|         </member> |         </member> | ||||||
|         <member name="T:System.Diagnostics.CodeAnalysis.AllowNullAttribute"> |     </members> | ||||||
|  | </doc> | ||||||
|  | System.Diagnostics.CodeAnalysis.AllowNullAttribute"> | ||||||
|             <summary> |             <summary> | ||||||
|                 Specifies that <see langword="null"/> is allowed as an input even if the |                 Specifies that <see langword="null"/> is allowed as an input even if the | ||||||
|                 corresponding type disallows it. |                 corresponding type disallows it. | ||||||
|  | |||||||
| @ -7,13 +7,8 @@ namespace CryptoExchange.Net.Objects | |||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// The result of an operation |     /// The result of an operation | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     /// <typeparam name="T"></typeparam> |     public class CallResult | ||||||
|     public class CallResult<T> |  | ||||||
|     { |     { | ||||||
|         /// <summary> |  | ||||||
|         /// The data returned by the call |  | ||||||
|         /// </summary> |  | ||||||
|         public T Data { get; internal set; } |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// An error if the call didn't succeed |         /// An error if the call didn't succeed | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @ -23,15 +18,54 @@ namespace CryptoExchange.Net.Objects | |||||||
|         /// </summary> |         /// </summary> | ||||||
|         public bool Success => Error == null; |         public bool Success => Error == null; | ||||||
| 
 | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// ctor | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="error"></param> | ||||||
|  |         public CallResult(Error? error) | ||||||
|  |         { | ||||||
|  |             Error = error; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// Overwrite bool check so we can use if(callResult) instead of if(callResult.Success) | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="obj"></param> | ||||||
|  |         public static implicit operator bool(CallResult obj) | ||||||
|  |         { | ||||||
|  |             return obj?.Success == true; | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         /// Create an error result | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="error"></param> | ||||||
|  |         /// <returns></returns> | ||||||
|  |         public static WebCallResult CreateErrorResult(Error error) | ||||||
|  |         { | ||||||
|  |             return new WebCallResult(null, null, error); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /// <summary> | ||||||
|  |     /// The result of an operation | ||||||
|  |     /// </summary> | ||||||
|  |     /// <typeparam name="T"></typeparam> | ||||||
|  |     public class CallResult<T>: CallResult | ||||||
|  |     { | ||||||
|  |         /// <summary> | ||||||
|  |         /// The data returned by the call | ||||||
|  |         /// </summary> | ||||||
|  |         public T Data { get; internal set; } | ||||||
|  | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// ctor |         /// ctor | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="data"></param> |         /// <param name="data"></param> | ||||||
|         /// <param name="error"></param> |         /// <param name="error"></param> | ||||||
|         public CallResult([AllowNull]T data, Error? error) |         public CallResult([AllowNull]T data, Error? error): base(error) | ||||||
|         { |         { | ||||||
|             Data = data; |             Data = data; | ||||||
|             Error = error; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
| @ -66,6 +100,58 @@ namespace CryptoExchange.Net.Objects | |||||||
|                 return false; |                 return false; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// Create an error result | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="error"></param> | ||||||
|  |         /// <returns></returns> | ||||||
|  |         public new static WebCallResult<T> CreateErrorResult(Error error) | ||||||
|  |         { | ||||||
|  |             return new WebCallResult<T>(null, null, default, error); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     /// <summary> | ||||||
|  |     /// The result of a request | ||||||
|  |     /// </summary> | ||||||
|  |     public class WebCallResult : CallResult | ||||||
|  |     { | ||||||
|  |         /// <summary> | ||||||
|  |         /// The status code of the response. Note that a OK status does not always indicate success, check the Success parameter for this. | ||||||
|  |         /// </summary> | ||||||
|  |         public HttpStatusCode? ResponseStatusCode { get; set; } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// The response headers | ||||||
|  |         /// </summary> | ||||||
|  |         public IEnumerable<KeyValuePair<string, IEnumerable<string>>>? ResponseHeaders { get; set; } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// ctor | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="code"></param> | ||||||
|  |         /// <param name="responseHeaders"></param> | ||||||
|  |         /// <param name="error"></param> | ||||||
|  |         public WebCallResult( | ||||||
|  |             HttpStatusCode? code, | ||||||
|  |             IEnumerable<KeyValuePair<string, IEnumerable<string>>>? responseHeaders, Error? error) : base(error) | ||||||
|  |         { | ||||||
|  |             ResponseHeaders = responseHeaders; | ||||||
|  |             ResponseStatusCode = code; | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// Create an error result | ||||||
|  |         /// </summary> | ||||||
|  |         /// <param name="code"></param> | ||||||
|  |         /// <param name="responseHeaders"></param> | ||||||
|  |         /// <param name="error"></param> | ||||||
|  |         /// <returns></returns> | ||||||
|  |         public static WebCallResult CreateErrorResult(HttpStatusCode? code, IEnumerable<KeyValuePair<string, IEnumerable<string>>>? responseHeaders, Error error) | ||||||
|  |         { | ||||||
|  |             return new WebCallResult(code, responseHeaders, error); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// <summary> |     /// <summary> | ||||||
| @ -83,7 +169,7 @@ namespace CryptoExchange.Net.Objects | |||||||
|         /// The response headers |         /// The response headers | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         public IEnumerable<KeyValuePair<string, IEnumerable<string>>>? ResponseHeaders { get; set; } |         public IEnumerable<KeyValuePair<string, IEnumerable<string>>>? ResponseHeaders { get; set; } | ||||||
| 
 |          | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// ctor |         /// ctor | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @ -95,18 +181,8 @@ namespace CryptoExchange.Net.Objects | |||||||
|             HttpStatusCode? code,  |             HttpStatusCode? code,  | ||||||
|             IEnumerable<KeyValuePair<string, IEnumerable<string>>>? responseHeaders, [AllowNull] T data, Error? error): base(data, error) |             IEnumerable<KeyValuePair<string, IEnumerable<string>>>? responseHeaders, [AllowNull] T data, Error? error): base(data, error) | ||||||
|         { |         { | ||||||
|             ResponseHeaders = responseHeaders; |  | ||||||
|             ResponseStatusCode = code; |             ResponseStatusCode = code; | ||||||
|         } |             ResponseHeaders = responseHeaders; | ||||||
| 
 |  | ||||||
|         /// <summary> |  | ||||||
|         /// Create an error result |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="error"></param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         public static WebCallResult<T> CreateErrorResult(Error error) |  | ||||||
|         { |  | ||||||
|             return new WebCallResult<T>(null, null, default!, error); |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
| @ -118,7 +194,7 @@ namespace CryptoExchange.Net.Objects | |||||||
|         /// <returns></returns> |         /// <returns></returns> | ||||||
|         public static WebCallResult<T> CreateErrorResult(HttpStatusCode? code, IEnumerable<KeyValuePair<string, IEnumerable<string>>>? responseHeaders, Error error) |         public static WebCallResult<T> CreateErrorResult(HttpStatusCode? code, IEnumerable<KeyValuePair<string, IEnumerable<string>>>? responseHeaders, Error error) | ||||||
|         { |         { | ||||||
|             return new WebCallResult<T>(code, responseHeaders, default!, error); |             return new WebCallResult<T>(code, responseHeaders, default, error); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user