// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
namespace AWS.Deploy.Orchestration.CDK
{
///
/// Wrapper to return result for methods that follows TryGet pattern.
///
/// Especially handy for async methods that don't support out parameters.
///
///
/// Type of the encapsulated object
public class TryGetResult
{
public bool Success { get; }
public TResult? Result { get; }
public TryGetResult(TResult? result, bool success)
{
Result = result;
Success = success;
}
}
///
/// Convenience static class to build instance
///
public static class TryGetResult
{
public static TryGetResult Failure() => new(default, false);
public static TryGetResult FromResult(T result) => new(result, true);
}
}