How would I add an output and an input value. Basi...
# dotnet
f
How would I add an output and an input value. Basically trying to take a disk size which is provided by an output and add to it an Input value. This isn't possible to do
Copy code
Size = args.VmTemplate.Apply(x => x.Disks[0].Size ) + args.SrvExtendSize
as well as
Copy code
Size = args.VmTemplate.Apply(x => x.Disks[0].Size ) + args.SrvExtendSize.ToOutput()
So I must be missing something
I can call ToString on each and parse them back to an int but that doesn't seem right at all. Is there a special function to do math against outputs and inputs?
s
I think you can do something similar to this:
Copy code
Output.Tuple<?, int>(args.VmTemplate, args.SrvExtendSize).Apply(t => {
   var (template, extendedSize) = t;
   return template.Disks[0].Size + args.SrvExtendSize;
});
that will take both inputs and make sure that both are counted in/awaited if needed before converting them into a single output.
f
Ah that seems to work.
Copy code
Size = Output.Tuple(args.VmTemplate, args.SrvExtendSize).Apply(t => {
    var (template, extendedSize) = t;
    return template.Disks[0].Size + extendedSize;
}),
It just seems like a lot of work to just add two ints.
Thanks for the reply!!
s
Welcome, been there before 😄