pulumi/sdk/dotnet/Pulumi/Core/InputUnion.cs
2019-11-21 22:46:14 +01:00

39 lines
1.2 KiB
C#

// Copyright 2016-2019, Pulumi Corporation
using System;
namespace Pulumi
{
/// <summary>
/// Represents an <see cref="Input{T}"/> value that can be one of two different types. For
/// example, it might potentially be an <see cref="int"/> some of the time or a <see
/// cref="string"/> in other cases.
/// </summary>
public sealed class InputUnion<T0, T1> : Input<Union<T0, T1>>
{
public InputUnion() : this(Output.Create(default(Union<T0, T1>)))
{
}
private InputUnion(Output<Union<T0, T1>> oneOf)
: base(oneOf)
{
}
#region common conversions
public static implicit operator InputUnion<T0, T1>(T0 value)
=> Output.Create(value);
public static implicit operator InputUnion<T0, T1>(T1 value)
=> Output.Create(value);
public static implicit operator InputUnion<T0, T1>(Output<T0> value)
=> new InputUnion<T0, T1>(value.Apply(v => Union<T0, T1>.FromT0(v)));
public static implicit operator InputUnion<T0, T1>(Output<T1> value)
=> new InputUnion<T0, T1>(value.Apply(v => Union<T0, T1>.FromT1(v)));
#endregion
}
}