| 1 | |
| 2 | static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { |
| 3 | HandleScope scope; |
| 4 | if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<@TX.ToWinRT(Model.Type)>(info[0])) { |
| 5 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); |
| 6 | return; |
| 7 | } |
| 8 | |
| 9 | @TX.ToWinRT(Model.Type) winRtInstance; |
| 10 | try { |
| 11 | winRtInstance = (@TX.ToWinRT(Model.Type)) NodeRT::Utils::GetObjectInstance(info[0]); |
| 12 | } catch (Platform::Exception ^exception) { |
| 13 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); |
| 14 | return; |
| 15 | } |
| 16 | |
| 17 | info.GetReturnValue().Set(Wrap@(Model.Name)(winRtInstance)); |
| 18 | } |