| 1 | static void @(Model.Name)Setter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) { |
| 2 | HandleScope scope; |
| 3 | |
| 4 | if (!@(String.Format(Converter.TypeCheck(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)),"value"))) { |
| 5 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); |
| 6 | return; |
| 7 | } |
| 8 | |
| 9 | if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.DeclaringType,true))>(info.This())) { |
| 10 | return; |
| 11 | } |
| 12 | |
| 13 | @(Model.DeclaringType.Name) *wrapper = @(Model.DeclaringType.Name)::Unwrap<@(Model.DeclaringType.Name)>(info.This()); |
| 14 | |
| 15 | try {@{ |
| 16 | var winrtConversionInfo = Converter.ToWinRT(Model.PropertyType); } |
| 17 | |
| 18 | @(winrtConversionInfo[0]) winRtValue = @(string.Format(winrtConversionInfo[1], "value")); |
| 19 | |
| 20 | wrapper->_instance->@(Model.Name) = winRtValue; |
| 21 | } catch (Platform::Exception ^exception) { |
| 22 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); |
| 23 | } |
| 24 | } |