MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / Insert

Method Insert

src/NodeRTLib/ProjectFiles/CollectionsWrap.h:1792–1821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1790 }
1791
1792 static void Insert(Nan::NAN_METHOD_ARGS_TYPE info) {
1793 HandleScope scope;
1794
1795 if (!NodeRT::Utils::IsWinRtWrapperOf<
1796 ::Windows::Foundation::Collections::IMap<K, V> ^>(info.This())) {
1797 return;
1798 }
1799
1800 MapWrapper<K, V>* wrapper =
1801 MapWrapper<K, V>::Unwrap<MapWrapper<K, V>>(info.This());
1802
1803 if (info.Length() == 2 && wrapper->_checkKeyTypeFunc(info[0]) &&
1804 wrapper->_checkValueTypeFunc(info[1])) {
1805 try {
1806 K key = wrapper->_convertToKeyTypeFunc(info[0]);
1807 V value = wrapper->_convertToValueTypeFunc(info[1]);
1808
1809 bool result = wrapper->_instance->Insert(key, value);
1810
1811 info.GetReturnValue().Set(Nan::New<Boolean>(result));
1812 } catch (Platform::Exception ^ exception) {
1813 NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
1814 return;
1815 }
1816 } else {
1817 Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(
1818 L"Bad arguments: no suitable overload found")));
1819 return;
1820 }
1821 }
1822
1823 static void First(Nan::NAN_METHOD_ARGS_TYPE info) {
1824 HandleScope scope;

Callers 1

ToWinRTMethod · 0.80

Calls 2

NewStringFunction · 0.85
SetMethod · 0.45

Tested by

no test coverage detected