SN
Size: a a a
SN
A
AH
AH
AH
AH
AH
public abstract class Result
{
public sealed class Ok : Result
{
public string AccessToken { get; }
public string RefreshToken { get; }
public Ok(string accessToken, string refreshToken)
{
AccessToken = accessToken;
RefreshToken = refreshToken;
}
}
public sealed class Unauthorized : Result
{
public static Unauthorized Instance = new Unauthorized();
private Unauthorized()
{
}
}
public sealed class HttpError : Result
{
public int StatusCode { get; }
public string Reason { get; }
public HttpError(int statusCode, string reason)
{
StatusCode = statusCode;
Reason = reason;
}
}
public static Result Return(string accessToken, string refreshToken) =>
new Ok(accessToken, refreshToken);
public static Result FlatMap(Result x, Func<Ok, Result> f) => x switch
{
Ok ok => f(ok),
HttpError httpError => httpError,
Unauthorized unauthorized => unauthorized,
_ => throw new ArgumentOutOfRangeException(nameof(x))
};
}
AH
public static class ResultExtensions
{
public static Result FlatMap(this Result x, Func<Result.Ok, Result> f) =>
Result.FlatMap(x, f);
}
AH
M
public abstract class Result
{
public sealed class Ok : Result
{
public string AccessToken { get; }
public string RefreshToken { get; }
public Ok(string accessToken, string refreshToken)
{
AccessToken = accessToken;
RefreshToken = refreshToken;
}
}
public sealed class Unauthorized : Result
{
public static Unauthorized Instance = new Unauthorized();
private Unauthorized()
{
}
}
public sealed class HttpError : Result
{
public int StatusCode { get; }
public string Reason { get; }
public HttpError(int statusCode, string reason)
{
StatusCode = statusCode;
Reason = reason;
}
}
public static Result Return(string accessToken, string refreshToken) =>
new Ok(accessToken, refreshToken);
public static Result FlatMap(Result x, Func<Ok, Result> f) => x switch
{
Ok ok => f(ok),
HttpError httpError => httpError,
Unauthorized unauthorized => unauthorized,
_ => throw new ArgumentOutOfRangeException(nameof(x))
};
}
A
public static class ResultExtensions
{
public static Result FlatMap(this Result x, Func<Result.Ok, Result> f) =>
Result.FlatMap(x, f);
}
AH
M
public abstract class Result
{
public sealed class Ok : Result
{
public string AccessToken { get; }
public string RefreshToken { get; }
public Ok(string accessToken, string refreshToken)
{
AccessToken = accessToken;
RefreshToken = refreshToken;
}
}
public sealed class Unauthorized : Result
{
public static Unauthorized Instance = new Unauthorized();
private Unauthorized()
{
}
}
public sealed class HttpError : Result
{
public int StatusCode { get; }
public string Reason { get; }
public HttpError(int statusCode, string reason)
{
StatusCode = statusCode;
Reason = reason;
}
}
public static Result Return(string accessToken, string refreshToken) =>
new Ok(accessToken, refreshToken);
public static Result FlatMap(Result x, Func<Ok, Result> f) => x switch
{
Ok ok => f(ok),
HttpError httpError => httpError,
Unauthorized unauthorized => unauthorized,
_ => throw new ArgumentOutOfRangeException(nameof(x))
};
}
M
VK
AH
M
M