// Copyright 2016-2019, Pulumi Corporation using System; using System.Diagnostics.CodeAnalysis; namespace Pulumi { /// /// Internal interface to allow our code to operate on inputs in an untyped manner. Necessary as /// there is no reasonable way to write algorithms over heterogeneous instantiations of generic /// types. /// internal interface IInput { IOutput ToOutput(); } /// /// is a property input for a . It may be a promptly /// available T, or the output from a existing . /// public class Input : IInput { /// /// Technically, in .net we can represent Inputs entirely using the Output type (since /// Outputs can wrap values and promises). However, it would look very weird to state that /// the inputs to a resource *had* to be Outputs. So we basically just come up with this /// wrapper type so things look sensible, even though under the covers we implement things /// using the exact same type /// private protected Output _outputValue; private protected Input(Output outputValue) => _outputValue = outputValue ?? throw new ArgumentNullException(nameof(outputValue)); public static implicit operator Input([MaybeNull]T value) => Output.Create(value); public static implicit operator Input(Output value) => new Input(value); public static implicit operator Output(Input input) => input._outputValue; public Output ToOutput() => this; IOutput IInput.ToOutput() => ToOutput(); } }