| 155 | } |
| 156 | |
| 157 | static void Set(uint32_t index, |
| 158 | Local<Value> value, |
| 159 | const Nan::PropertyCallbackInfo<v8::Value>& info) { |
| 160 | HandleScope scope; |
| 161 | if (!NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array<T> ^>(info.This())) { |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | ArrayWrapper<T>* wrapper = |
| 166 | ArrayWrapper<T>::Unwrap<ArrayWrapper<T>>(info.This()); |
| 167 | |
| 168 | if (wrapper->_checkTypeFunc && !wrapper->_checkTypeFunc(value)) { |
| 169 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString( |
| 170 | L"The argument to set isn't of the expected type or internal WinRt " |
| 171 | L"object was disposed"))); |
| 172 | return; |
| 173 | } |
| 174 | |
| 175 | if (wrapper->_instance->Length <= index) { |
| 176 | Nan::ThrowError(Nan::Error( |
| 177 | NodeRT::Utils::NewString(L"Given index exceeded array length"))); |
| 178 | return; |
| 179 | } |
| 180 | |
| 181 | if (wrapper->_convertToTypeFunc) { |
| 182 | try { |
| 183 | wrapper->_instance[index] = wrapper->_convertToTypeFunc(value); |
| 184 | } catch (::Platform::Exception ^ e) { |
| 185 | NodeRT::Utils::ThrowWinRtExceptionInJs(e); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | private: |
| 193 | ::Platform::Array<T> ^ _instance; |
no test coverage detected