Adds an out parameter to ChangeType to indicate the result of the conversion. This prevents us from needing to have a CanConvert or similar function, which would result in duplicative work. In all cases where ChangeType would result in NoMatch, an exception is thrown.
In the As operator, if there is a custom conversion defined between two types, we invoke it. If ChangeType identifies a NoMatch condition, we return default. Otherwise, we produce a standard C# as operator.
ChangeType
to indicate the result of the conversion. This prevents us from needing to have aCanConvert
or similar function, which would result in duplicative work. In all cases whereChangeType
would result inNoMatch
, an exception is thrown.As
operator, if there is a custom conversion defined between two types, we invoke it. IfChangeType
identifies aNoMatch
condition, we returndefault
. Otherwise, we produce a standard C#as
operator.