| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System.ComponentModel; |
| | | 5 | | using System.Diagnostics; |
| | | 6 | | |
| | | 7 | | namespace Azure |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Represents a result of Azure operation. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <typeparam name="T">The type of returned value.</typeparam> |
| | | 13 | | [DebuggerTypeProxy(typeof(ResponseDebugView<>))] |
| | | 14 | | public abstract class Response<T> |
| | | 15 | | { |
| | | 16 | | /// <summary> |
| | | 17 | | /// Returns the HTTP response returned by the service. |
| | | 18 | | /// </summary> |
| | | 19 | | /// <returns>The HTTP response returned by the service.</returns> |
| | | 20 | | public abstract Response GetRawResponse(); |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Gets the value returned by the service. |
| | | 24 | | /// </summary> |
| | | 25 | | public abstract T Value { get; } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Returns the value of this <see cref="Response{T}"/> object. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <param name="response">The <see cref="Response{T}"/> instance.</param> |
| | 6 | 31 | | public static implicit operator T(Response<T> response) => response.Value; |
| | | 32 | | |
| | | 33 | | /// <inheritdoc /> |
| | | 34 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 35 | | public override bool Equals(object? obj) => base.Equals(obj); |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | | 38 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 0 | 39 | | public override int GetHashCode() => base.GetHashCode(); |
| | | 40 | | |
| | | 41 | | /// <inheritdoc /> |
| | | 42 | | public override string ToString() |
| | | 43 | | { |
| | 2 | 44 | | return $"Status: {GetRawResponse().Status}, Value: {Value}"; |
| | | 45 | | } |
| | | 46 | | } |
| | | 47 | | } |