Hi, I am looking to convert InputList<T> to...
# general
c
Hi, I am looking to convert InputList<T> to InputList<Union<string, T>>. I have written the following code to do it but at least in my mind this conversion should be automatic under some operator. I understand that T for Input<T> / Output<T> is opaque but I want to make sure I am not missing something
Copy code
InputList<Union<string, FrontDoorProtocol>> protocols = new InputList<Union<string, FrontDoorProtocol>>();
await foreach (var protocol in acceptedProtocols)
{
	protocols.Add(protocol);
}
return protocols;
1
b
i think you can do it with Apply instead of async/await - something like
Copy code
InputList<string> acceptedProtocols = ...

InputList<Union<string, FrontDoorProtocol>> protocols = acceptedProtocols.Apply(list =>
   list.Select(x => buildUnion(x, ...));
c
Thank you @bumpy-grass-54508 I think this will work. I completely missed the fact that has a
Union.From()
factory method
👍 1
Copy code
AcceptedProtocols = rule.AcceptedProtocols.Apply(protocolArray => protocolArray.Select(Union<string, FrontDoorProtocol>.FromT1))
Just for completeness in case someone else looks that thread.