// Copyright (c) The NodeRT Contributors
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the ""License""); you may
// not use this file except in compliance with the License. You may obtain a
// copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
//
// See the Apache Version 2.0 License for specific language governing permissions
// and limitations under the License.

// TODO: Verify that this is is still needed..
#define NTDDI_VERSION 0x06010000

#include <v8.h>
#include "nan.h"
#include <string>
#include <ppltasks.h>
#include "CollectionsConverter.h"
#include "CollectionsWrap.h"
#include "node-async.h"
#include "NodeRtUtils.h"
#include "OpaqueWrapper.h"
#include "WrapperBase.h"

#using <Windows.WinMD>

// this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search
// Some of the node header files brings windows definitions with the same names as some of the WinRT methods
#undef DocumentProperties
#undef GetObject
#undef CreateEvent
#undef FindText
#undef SendMessage

const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__";

using v8::Array;
using v8::String;
using v8::Value;
using v8::Boolean;
using v8::Integer;
using v8::FunctionTemplate;
using v8::Object;
using v8::Local;
using v8::Function;
using v8::Date;
using v8::Number;
using v8::PropertyAttribute;
using v8::Primitive;
using Nan::HandleScope;
using Nan::Persistent;
using Nan::Undefined;
using Nan::True;
using Nan::False;
using Nan::Null;
using Nan::MaybeLocal;
using Nan::EscapableHandleScope;
using Nan::HandleScope;
using Nan::TryCatch;
using namespace concurrency;

namespace NodeRT { namespace Windows { namespace Management { namespace Update { 
  v8::Local<v8::Value> WrapPreviewBuildsManager(::Windows::Management::Update::PreviewBuildsManager^ wintRtInstance);
  ::Windows::Management::Update::PreviewBuildsManager^ UnwrapPreviewBuildsManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapPreviewBuildsState(::Windows::Management::Update::PreviewBuildsState^ wintRtInstance);
  ::Windows::Management::Update::PreviewBuildsState^ UnwrapPreviewBuildsState(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdate(::Windows::Management::Update::WindowsUpdate^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdate^ UnwrapWindowsUpdate(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateActionCompletedEventArgs(::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ UnwrapWindowsUpdateActionCompletedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateActionProgress(::Windows::Management::Update::WindowsUpdateActionProgress^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateActionProgress^ UnwrapWindowsUpdateActionProgress(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateActionResult(::Windows::Management::Update::WindowsUpdateActionResult^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateActionResult^ UnwrapWindowsUpdateActionResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateAdministrator(::Windows::Management::Update::WindowsUpdateAdministrator^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateAdministrator^ UnwrapWindowsUpdateAdministrator(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateApprovalData(::Windows::Management::Update::WindowsUpdateApprovalData^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateApprovalData^ UnwrapWindowsUpdateApprovalData(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateAttentionRequiredInfo(::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ UnwrapWindowsUpdateAttentionRequiredInfo(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ UnwrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateGetAdministratorResult(::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ UnwrapWindowsUpdateGetAdministratorResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateItem(::Windows::Management::Update::WindowsUpdateItem^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateItem^ UnwrapWindowsUpdateItem(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateManager(::Windows::Management::Update::WindowsUpdateManager^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateManager^ UnwrapWindowsUpdateManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateProgressChangedEventArgs(::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ UnwrapWindowsUpdateProgressChangedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateRestartRequestOptions(::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ UnwrapWindowsUpdateRestartRequestOptions(Local<Value> value);
  
  v8::Local<v8::Value> WrapWindowsUpdateScanCompletedEventArgs(::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ wintRtInstance);
  ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ UnwrapWindowsUpdateScanCompletedEventArgs(Local<Value> value);
  



  static void InitWindowsUpdateAdministratorOptionsEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("WindowsUpdateAdministratorOptions").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAdministratorOptions::None)));
    Nan::Set(enumObject, Nan::New<String>("requireAdministratorApprovalForScans").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAdministratorOptions::RequireAdministratorApprovalForScans)));
    Nan::Set(enumObject, Nan::New<String>("requireAdministratorApprovalForUpdates").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAdministratorOptions::RequireAdministratorApprovalForUpdates)));
    Nan::Set(enumObject, Nan::New<String>("requireAdministratorApprovalForActions").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAdministratorOptions::RequireAdministratorApprovalForActions)));
  }

  static void InitWindowsUpdateAdministratorStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("WindowsUpdateAdministratorStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("succeeded").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAdministratorStatus::Succeeded)));
    Nan::Set(enumObject, Nan::New<String>("noAdministratorRegistered").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAdministratorStatus::NoAdministratorRegistered)));
    Nan::Set(enumObject, Nan::New<String>("otherAdministratorIsRegistered").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAdministratorStatus::OtherAdministratorIsRegistered)));
  }

  static void InitWindowsUpdateAttentionRequiredReasonEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("WindowsUpdateAttentionRequiredReason").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::None)));
    Nan::Set(enumObject, Nan::New<String>("seekerUpdate").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::SeekerUpdate)));
    Nan::Set(enumObject, Nan::New<String>("readyToReboot").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::ReadyToReboot)));
    Nan::Set(enumObject, Nan::New<String>("needNonMeteredNetwork").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedNonMeteredNetwork)));
    Nan::Set(enumObject, Nan::New<String>("needUserAgreementForMeteredNetwork").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedUserAgreementForMeteredNetwork)));
    Nan::Set(enumObject, Nan::New<String>("needNetwork").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedNetwork)));
    Nan::Set(enumObject, Nan::New<String>("needMoreSpace").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedMoreSpace)));
    Nan::Set(enumObject, Nan::New<String>("batterySaverEnabled").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BatterySaverEnabled)));
    Nan::Set(enumObject, Nan::New<String>("needUserInteraction").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedUserInteraction)));
    Nan::Set(enumObject, Nan::New<String>("needUserAgreementForPolicy").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedUserAgreementForPolicy)));
    Nan::Set(enumObject, Nan::New<String>("compatibilityError").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::CompatibilityError)));
    Nan::Set(enumObject, Nan::New<String>("needUserInteractionForEula").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedUserInteractionForEula)));
    Nan::Set(enumObject, Nan::New<String>("needUserInteractionForCta").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::NeedUserInteractionForCta)));
    Nan::Set(enumObject, Nan::New<String>("regulated").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::Regulated)));
    Nan::Set(enumObject, Nan::New<String>("externalReboot").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::ExternalReboot)));
    Nan::Set(enumObject, Nan::New<String>("otherUpdate").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::OtherUpdate)));
    Nan::Set(enumObject, Nan::New<String>("blockedByProvider").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByProvider)));
    Nan::Set(enumObject, Nan::New<String>("blockedByPostRebootFailure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByPostRebootFailure)));
    Nan::Set(enumObject, Nan::New<String>("userEngaged").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::UserEngaged)));
    Nan::Set(enumObject, Nan::New<String>("blockedByBattery").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByBattery)));
    Nan::Set(enumObject, Nan::New<String>("exclusivity").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::Exclusivity)));
    Nan::Set(enumObject, Nan::New<String>("blockedBySerialization").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedBySerialization)));
    Nan::Set(enumObject, Nan::New<String>("conflictClass").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::ConflictClass)));
    Nan::Set(enumObject, Nan::New<String>("blockedByAdminApproval").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByAdminApproval)));
    Nan::Set(enumObject, Nan::New<String>("blockedByTooManyAttempts").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByTooManyAttempts)));
    Nan::Set(enumObject, Nan::New<String>("blockedByFailure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByFailure)));
    Nan::Set(enumObject, Nan::New<String>("demotion").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::Demotion)));
    Nan::Set(enumObject, Nan::New<String>("blockedByActiveHours").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByActiveHours)));
    Nan::Set(enumObject, Nan::New<String>("scheduledForMaintenance").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::ScheduledForMaintenance)));
    Nan::Set(enumObject, Nan::New<String>("policyScheduledInstallTime").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::PolicyScheduledInstallTime)));
    Nan::Set(enumObject, Nan::New<String>("blockedByOobe").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::BlockedByOobe)));
    Nan::Set(enumObject, Nan::New<String>("deferredDuringOobe").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::DeferredDuringOobe)));
    Nan::Set(enumObject, Nan::New<String>("deferredForSustainableTime").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Management::Update::WindowsUpdateAttentionRequiredReason::DeferredForSustainableTime)));
  }

  static bool IsWindowsUpdateContractJsObject(Local<Value> value) {
    if (!value->IsObject()) {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Management::Update::WindowsUpdateContract WindowsUpdateContractFromJsObject(Local<Value> value) {
    HandleScope scope;
    ::Windows::Management::Update::WindowsUpdateContract returnValue;

    if (!value->IsObject()) {
      Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object")));
      return returnValue;
    }

    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();
    Local<String> symbol;

    return returnValue;
  }

  Local<Value> WindowsUpdateContractToJsObject(::Windows::Management::Update::WindowsUpdateContract value) {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();


    return scope.Escape(obj);
  }


  class PreviewBuildsManager : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("PreviewBuildsManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "getCurrentState", GetCurrentState);
          

          
            Nan::SetPrototypeMethod(localRef, "syncAsync", SyncAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("arePreviewBuildsAllowed").ToLocalChecked(), ArePreviewBuildsAllowedGetter, ArePreviewBuildsAllowedSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "getDefault", GetDefault);
        Nan::SetMethod(constructor, "isSupported", IsSupported);


        Nan::Set(exports, Nan::New<String>("PreviewBuildsManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PreviewBuildsManager(::Windows::Management::Update::PreviewBuildsManager^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::PreviewBuildsManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::PreviewBuildsManager^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      PreviewBuildsManager *wrapperInstance = new PreviewBuildsManager(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsManager^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::PreviewBuildsManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::PreviewBuildsManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPreviewBuildsManager(winRtInstance));
    }

    static void SyncAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsManager^>(info.This())) {
        return;
      }

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      PreviewBuildsManager *wrapper = PreviewBuildsManager::Unwrap<PreviewBuildsManager>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->SyncAsync();
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<bool> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<Boolean>(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        } catch (Platform::Exception^ exception) {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetCurrentState(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsManager^>(info.This())) {
        return;
      }

      PreviewBuildsManager *wrapper = PreviewBuildsManager::Unwrap<PreviewBuildsManager>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Management::Update::PreviewBuildsState^ result;
          result = wrapper->_instance->GetCurrentState();
          info.GetReturnValue().Set(WrapPreviewBuildsState(result));
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void GetDefault(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Management::Update::PreviewBuildsManager^ result;
          result = ::Windows::Management::Update::PreviewBuildsManager::GetDefault();
          info.GetReturnValue().Set(WrapPreviewBuildsManager(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void IsSupported(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          bool result;
          result = ::Windows::Management::Update::PreviewBuildsManager::IsSupported();
          info.GetReturnValue().Set(Nan::New<Boolean>(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void ArePreviewBuildsAllowedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsManager^>(info.This())) {
        return;
      }

      PreviewBuildsManager *wrapper = PreviewBuildsManager::Unwrap<PreviewBuildsManager>(info.This());

      try  {
        bool result = wrapper->_instance->ArePreviewBuildsAllowed;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ArePreviewBuildsAllowedSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsBoolean()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsManager^>(info.This())) {
        return;
      }

      PreviewBuildsManager *wrapper = PreviewBuildsManager::Unwrap<PreviewBuildsManager>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->ArePreviewBuildsAllowed = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Management::Update::PreviewBuildsManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPreviewBuildsManager(::Windows::Management::Update::PreviewBuildsManager^ wintRtInstance);
      friend ::Windows::Management::Update::PreviewBuildsManager^ UnwrapPreviewBuildsManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> PreviewBuildsManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapPreviewBuildsManager(::Windows::Management::Update::PreviewBuildsManager^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(PreviewBuildsManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::PreviewBuildsManager^ UnwrapPreviewBuildsManager(Local<Value> value) {
     return PreviewBuildsManager::Unwrap<PreviewBuildsManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPreviewBuildsManager(Local<Object> exports) {
    PreviewBuildsManager::Init(exports);
  }

  class PreviewBuildsState : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("PreviewBuildsState").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("properties").ToLocalChecked(), PropertiesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PreviewBuildsState").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PreviewBuildsState(::Windows::Management::Update::PreviewBuildsState^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::PreviewBuildsState^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsState^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::PreviewBuildsState^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      PreviewBuildsState *wrapperInstance = new PreviewBuildsState(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsState^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::PreviewBuildsState^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::PreviewBuildsState^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPreviewBuildsState(winRtInstance));
    }





    static void PropertiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::PreviewBuildsState^>(info.This())) {
        return;
      }

      PreviewBuildsState *wrapper = PreviewBuildsState::Unwrap<PreviewBuildsState>(info.This());

      try  {
        ::Windows::Foundation::Collections::ValueSet^ result = wrapper->_instance->Properties;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation.Collections", "ValueSet", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::PreviewBuildsState^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPreviewBuildsState(::Windows::Management::Update::PreviewBuildsState^ wintRtInstance);
      friend ::Windows::Management::Update::PreviewBuildsState^ UnwrapPreviewBuildsState(Local<Value> value);
  };

  Persistent<FunctionTemplate> PreviewBuildsState::s_constructorTemplate;

  v8::Local<v8::Value> WrapPreviewBuildsState(::Windows::Management::Update::PreviewBuildsState^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(PreviewBuildsState::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::PreviewBuildsState^ UnwrapPreviewBuildsState(Local<Value> value) {
     return PreviewBuildsState::Unwrap<PreviewBuildsState>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPreviewBuildsState(Local<Object> exports) {
    PreviewBuildsState::Init(exports);
  }

  class WindowsUpdate : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdate").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "getPropertyValue", GetPropertyValue);
            Nan::SetPrototypeMethod(localRef, "acceptEula", AcceptEula);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("actionProgress").ToLocalChecked(), ActionProgressGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("actionResult").ToLocalChecked(), ActionResultGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("attentionRequiredInfo").ToLocalChecked(), AttentionRequiredInfoGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("currentAction").ToLocalChecked(), CurrentActionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("deadline").ToLocalChecked(), DeadlineGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("description").ToLocalChecked(), DescriptionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("eulaText").ToLocalChecked(), EulaTextGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isCritical").ToLocalChecked(), IsCriticalGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isDriver").ToLocalChecked(), IsDriverGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isEulaAccepted").ToLocalChecked(), IsEulaAcceptedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isFeatureUpdate").ToLocalChecked(), IsFeatureUpdateGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isForOS").ToLocalChecked(), IsForOSGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isMandatory").ToLocalChecked(), IsMandatoryGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isMinorImpact").ToLocalChecked(), IsMinorImpactGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isSecurity").ToLocalChecked(), IsSecurityGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isSeeker").ToLocalChecked(), IsSeekerGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isUrgent").ToLocalChecked(), IsUrgentGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("moreInfoUrl").ToLocalChecked(), MoreInfoUrlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("providerId").ToLocalChecked(), ProviderIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportUrl").ToLocalChecked(), SupportUrlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("title").ToLocalChecked(), TitleGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("updateId").ToLocalChecked(), UpdateIdGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdate").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdate(::Windows::Management::Update::WindowsUpdate^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdate^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdate^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdate *wrapperInstance = new WindowsUpdate(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdate^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdate^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdate(winRtInstance));
    }


    static void GetPropertyValue(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Platform::Object^ result;
          result = wrapper->_instance->GetPropertyValue(arg0);
          info.GetReturnValue().Set(CreateOpaqueWrapper(result));
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void AcceptEula(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->AcceptEula();
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void ActionProgressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateActionProgress^ result = wrapper->_instance->ActionProgress;
        info.GetReturnValue().Set(WrapWindowsUpdateActionProgress(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ActionResultGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateActionResult^ result = wrapper->_instance->ActionResult;
        info.GetReturnValue().Set(WrapWindowsUpdateActionResult(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AttentionRequiredInfoGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ result = wrapper->_instance->AttentionRequiredInfo;
        info.GetReturnValue().Set(WrapWindowsUpdateAttentionRequiredInfo(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CurrentActionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->CurrentAction;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DeadlineGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        ::Platform::IBox<::Windows::Foundation::DateTime>^ result = wrapper->_instance->Deadline;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(NodeRT::Utils::DateTimeToJS(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Description;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EulaTextGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->EulaText;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsCriticalGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsCritical;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsDriverGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsDriver;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsEulaAcceptedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsEulaAccepted;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsFeatureUpdateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsFeatureUpdate;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsForOSGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsForOS;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsMandatoryGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsMandatory;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsMinorImpactGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsMinorImpact;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsSecurityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsSecurity;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsSeekerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsSeeker;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsUrgentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        bool result = wrapper->_instance->IsUrgent;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MoreInfoUrlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->MoreInfoUrl;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ProviderIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->ProviderId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportUrlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->SupportUrl;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TitleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Title;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void UpdateIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(info.This())) {
        return;
      }

      WindowsUpdate *wrapper = WindowsUpdate::Unwrap<WindowsUpdate>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->UpdateId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdate^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdate(::Windows::Management::Update::WindowsUpdate^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdate^ UnwrapWindowsUpdate(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdate::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdate(::Windows::Management::Update::WindowsUpdate^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdate::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdate^ UnwrapWindowsUpdate(Local<Value> value) {
     return WindowsUpdate::Unwrap<WindowsUpdate>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdate(Local<Object> exports) {
    WindowsUpdate::Init(exports);
  }

  class WindowsUpdateActionCompletedEventArgs : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateActionCompletedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("action").ToLocalChecked(), ActionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("extendedError").ToLocalChecked(), ExtendedErrorGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("succeeded").ToLocalChecked(), SucceededGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("update").ToLocalChecked(), UpdateGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateActionCompletedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateActionCompletedEventArgs(::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateActionCompletedEventArgs *wrapperInstance = new WindowsUpdateActionCompletedEventArgs(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateActionCompletedEventArgs(winRtInstance));
    }





    static void ActionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateActionCompletedEventArgs *wrapper = WindowsUpdateActionCompletedEventArgs::Unwrap<WindowsUpdateActionCompletedEventArgs>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Action;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ExtendedErrorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateActionCompletedEventArgs *wrapper = WindowsUpdateActionCompletedEventArgs::Unwrap<WindowsUpdateActionCompletedEventArgs>(info.This());

      try  {
        ::Windows::Foundation::HResult result = wrapper->_instance->ExtendedError;
        info.GetReturnValue().Set(Nan::New<Integer>(result.Value));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SucceededGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateActionCompletedEventArgs *wrapper = WindowsUpdateActionCompletedEventArgs::Unwrap<WindowsUpdateActionCompletedEventArgs>(info.This());

      try  {
        bool result = wrapper->_instance->Succeeded;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void UpdateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateActionCompletedEventArgs *wrapper = WindowsUpdateActionCompletedEventArgs::Unwrap<WindowsUpdateActionCompletedEventArgs>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdate^ result = wrapper->_instance->Update;
        info.GetReturnValue().Set(WrapWindowsUpdate(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateActionCompletedEventArgs(::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ UnwrapWindowsUpdateActionCompletedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateActionCompletedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateActionCompletedEventArgs(::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateActionCompletedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ UnwrapWindowsUpdateActionCompletedEventArgs(Local<Value> value) {
     return WindowsUpdateActionCompletedEventArgs::Unwrap<WindowsUpdateActionCompletedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateActionCompletedEventArgs(Local<Object> exports) {
    WindowsUpdateActionCompletedEventArgs::Init(exports);
  }

  class WindowsUpdateActionProgress : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateActionProgress").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("action").ToLocalChecked(), ActionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("progress").ToLocalChecked(), ProgressGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateActionProgress").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateActionProgress(::Windows::Management::Update::WindowsUpdateActionProgress^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateActionProgress^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionProgress^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateActionProgress^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateActionProgress *wrapperInstance = new WindowsUpdateActionProgress(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionProgress^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateActionProgress^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateActionProgress^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateActionProgress(winRtInstance));
    }





    static void ActionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionProgress^>(info.This())) {
        return;
      }

      WindowsUpdateActionProgress *wrapper = WindowsUpdateActionProgress::Unwrap<WindowsUpdateActionProgress>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Action;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ProgressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionProgress^>(info.This())) {
        return;
      }

      WindowsUpdateActionProgress *wrapper = WindowsUpdateActionProgress::Unwrap<WindowsUpdateActionProgress>(info.This());

      try  {
        double result = wrapper->_instance->Progress;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateActionProgress^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateActionProgress(::Windows::Management::Update::WindowsUpdateActionProgress^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateActionProgress^ UnwrapWindowsUpdateActionProgress(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateActionProgress::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateActionProgress(::Windows::Management::Update::WindowsUpdateActionProgress^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateActionProgress::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateActionProgress^ UnwrapWindowsUpdateActionProgress(Local<Value> value) {
     return WindowsUpdateActionProgress::Unwrap<WindowsUpdateActionProgress>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateActionProgress(Local<Object> exports) {
    WindowsUpdateActionProgress::Init(exports);
  }

  class WindowsUpdateActionResult : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateActionResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("action").ToLocalChecked(), ActionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("extendedError").ToLocalChecked(), ExtendedErrorGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("succeeded").ToLocalChecked(), SucceededGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("timestamp").ToLocalChecked(), TimestampGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateActionResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateActionResult(::Windows::Management::Update::WindowsUpdateActionResult^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateActionResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateActionResult^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateActionResult *wrapperInstance = new WindowsUpdateActionResult(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionResult^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateActionResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateActionResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateActionResult(winRtInstance));
    }





    static void ActionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionResult^>(info.This())) {
        return;
      }

      WindowsUpdateActionResult *wrapper = WindowsUpdateActionResult::Unwrap<WindowsUpdateActionResult>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Action;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ExtendedErrorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionResult^>(info.This())) {
        return;
      }

      WindowsUpdateActionResult *wrapper = WindowsUpdateActionResult::Unwrap<WindowsUpdateActionResult>(info.This());

      try  {
        ::Windows::Foundation::HResult result = wrapper->_instance->ExtendedError;
        info.GetReturnValue().Set(Nan::New<Integer>(result.Value));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SucceededGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionResult^>(info.This())) {
        return;
      }

      WindowsUpdateActionResult *wrapper = WindowsUpdateActionResult::Unwrap<WindowsUpdateActionResult>(info.This());

      try  {
        bool result = wrapper->_instance->Succeeded;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TimestampGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateActionResult^>(info.This())) {
        return;
      }

      WindowsUpdateActionResult *wrapper = WindowsUpdateActionResult::Unwrap<WindowsUpdateActionResult>(info.This());

      try  {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Timestamp;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateActionResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateActionResult(::Windows::Management::Update::WindowsUpdateActionResult^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateActionResult^ UnwrapWindowsUpdateActionResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateActionResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateActionResult(::Windows::Management::Update::WindowsUpdateActionResult^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateActionResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateActionResult^ UnwrapWindowsUpdateActionResult(Local<Value> value) {
     return WindowsUpdateActionResult::Unwrap<WindowsUpdateActionResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateActionResult(Local<Object> exports) {
    WindowsUpdateActionResult::Init(exports);
  }

  class WindowsUpdateAdministrator : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateAdministrator").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "startAdministratorScan", StartAdministratorScan);
            Nan::SetPrototypeMethod(localRef, "approveWindowsUpdateAction", ApproveWindowsUpdateAction);
            Nan::SetPrototypeMethod(localRef, "revokeWindowsUpdateActionApproval", RevokeWindowsUpdateActionApproval);
            Nan::SetPrototypeMethod(localRef, "approveWindowsUpdate", ApproveWindowsUpdate);
            Nan::SetPrototypeMethod(localRef, "revokeWindowsUpdateApproval", RevokeWindowsUpdateApproval);
            Nan::SetPrototypeMethod(localRef, "getUpdates", GetUpdates);
          




        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "getRegisteredAdministrator", GetRegisteredAdministrator);
        Nan::SetMethod(constructor, "registerForAdministration", RegisterForAdministration);
        Nan::SetMethod(constructor, "unregisterForAdministration", UnregisterForAdministration);
        Nan::SetMethod(constructor, "getRegisteredAdministratorName", GetRegisteredAdministratorName);
        Nan::SetMethod(constructor, "requestRestart", RequestRestart);
        Nan::SetMethod(constructor, "cancelRestartRequest", CancelRestartRequest);


        Nan::Set(exports, Nan::New<String>("WindowsUpdateAdministrator").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateAdministrator(::Windows::Management::Update::WindowsUpdateAdministrator^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateAdministrator^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateAdministrator^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateAdministrator *wrapperInstance = new WindowsUpdateAdministrator(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateAdministrator^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateAdministrator^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateAdministrator(winRtInstance));
    }


    static void StartAdministratorScan(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info.This())) {
        return;
      }

      WindowsUpdateAdministrator *wrapper = WindowsUpdateAdministrator::Unwrap<WindowsUpdateAdministrator>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->StartAdministratorScan();
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void ApproveWindowsUpdateAction(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info.This())) {
        return;
      }

      WindowsUpdateAdministrator *wrapper = WindowsUpdateAdministrator::Unwrap<WindowsUpdateAdministrator>(info.This());

      if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          
          wrapper->_instance->ApproveWindowsUpdateAction(arg0, arg1);
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void RevokeWindowsUpdateActionApproval(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info.This())) {
        return;
      }

      WindowsUpdateAdministrator *wrapper = WindowsUpdateAdministrator::Unwrap<WindowsUpdateAdministrator>(info.This());

      if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          
          wrapper->_instance->RevokeWindowsUpdateActionApproval(arg0, arg1);
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void ApproveWindowsUpdate(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info.This())) {
        return;
      }

      WindowsUpdateAdministrator *wrapper = WindowsUpdateAdministrator::Unwrap<WindowsUpdateAdministrator>(info.This());

      if (info.Length() == 2
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info[1]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Windows::Management::Update::WindowsUpdateApprovalData^ arg1 = UnwrapWindowsUpdateApprovalData(info[1]);
          
          wrapper->_instance->ApproveWindowsUpdate(arg0, arg1);
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void RevokeWindowsUpdateApproval(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info.This())) {
        return;
      }

      WindowsUpdateAdministrator *wrapper = WindowsUpdateAdministrator::Unwrap<WindowsUpdateAdministrator>(info.This());

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          wrapper->_instance->RevokeWindowsUpdateApproval(arg0);
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void GetUpdates(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAdministrator^>(info.This())) {
        return;
      }

      WindowsUpdateAdministrator *wrapper = WindowsUpdateAdministrator::Unwrap<WindowsUpdateAdministrator>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Foundation::Collections::IVectorView<::Windows::Management::Update::WindowsUpdate^>^ result;
          result = wrapper->_instance->GetUpdates();
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Management::Update::WindowsUpdate^>::CreateVectorViewWrapper(result, 
            [](::Windows::Management::Update::WindowsUpdate^ val) -> Local<Value> {
              return WrapWindowsUpdate(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(value);
            },
            [](Local<Value> value) -> ::Windows::Management::Update::WindowsUpdate^ {
              return UnwrapWindowsUpdate(value);
            }
          ));
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void GetRegisteredAdministrator(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ result;
          result = ::Windows::Management::Update::WindowsUpdateAdministrator::GetRegisteredAdministrator(arg0);
          info.GetReturnValue().Set(WrapWindowsUpdateGetAdministratorResult(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void RegisterForAdministration(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsInt32())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Windows::Management::Update::WindowsUpdateAdministratorOptions arg1 = static_cast<::Windows::Management::Update::WindowsUpdateAdministratorOptions>(Nan::To<int32_t>(info[1]).FromMaybe(0));
          
          ::Windows::Management::Update::WindowsUpdateAdministratorStatus result;
          result = ::Windows::Management::Update::WindowsUpdateAdministrator::RegisterForAdministration(arg0, arg1);
          info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void UnregisterForAdministration(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Windows::Management::Update::WindowsUpdateAdministratorStatus result;
          result = ::Windows::Management::Update::WindowsUpdateAdministrator::UnregisterForAdministration(arg0);
          info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void GetRegisteredAdministratorName(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          Platform::String^ result;
          result = ::Windows::Management::Update::WindowsUpdateAdministrator::GetRegisteredAdministratorName();
          info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void RequestRestart(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info[0]))
      {
        try
        {
          ::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ arg0 = UnwrapWindowsUpdateRestartRequestOptions(info[0]);
          
          Platform::String^ result;
          result = ::Windows::Management::Update::WindowsUpdateAdministrator::RequestRestart(arg0);
          info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void CancelRestartRequest(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Windows::Management::Update::WindowsUpdateAdministrator::CancelRestartRequest(arg0);
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    private:
      ::Windows::Management::Update::WindowsUpdateAdministrator^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateAdministrator(::Windows::Management::Update::WindowsUpdateAdministrator^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateAdministrator^ UnwrapWindowsUpdateAdministrator(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateAdministrator::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateAdministrator(::Windows::Management::Update::WindowsUpdateAdministrator^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateAdministrator::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateAdministrator^ UnwrapWindowsUpdateAdministrator(Local<Value> value) {
     return WindowsUpdateAdministrator::Unwrap<WindowsUpdateAdministrator>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateAdministrator(Local<Object> exports) {
    WindowsUpdateAdministrator::Init(exports);
  }

  class WindowsUpdateApprovalData : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateApprovalData").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("seeker").ToLocalChecked(), SeekerGetter, SeekerSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("optOutOfAutoReboot").ToLocalChecked(), OptOutOfAutoRebootGetter, OptOutOfAutoRebootSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("complianceGracePeriodInDays").ToLocalChecked(), ComplianceGracePeriodInDaysGetter, ComplianceGracePeriodInDaysSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("complianceDeadlineInDays").ToLocalChecked(), ComplianceDeadlineInDaysGetter, ComplianceDeadlineInDaysSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("allowDownloadOnMetered").ToLocalChecked(), AllowDownloadOnMeteredGetter, AllowDownloadOnMeteredSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateApprovalData").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateApprovalData(::Windows::Management::Update::WindowsUpdateApprovalData^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateApprovalData^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateApprovalData^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Management::Update::WindowsUpdateApprovalData();
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateApprovalData *wrapperInstance = new WindowsUpdateApprovalData(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateApprovalData^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateApprovalData^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateApprovalData(winRtInstance));
    }





    static void SeekerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try  {
        ::Platform::IBox<bool>^ result = wrapper->_instance->Seeker;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Boolean>(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SeekerSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsBoolean()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try {

        ::Platform::IBox<bool>^ winRtValue = ref new ::Platform::Box<bool>(Nan::To<bool>(value).FromMaybe(false));

        wrapper->_instance->Seeker = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void OptOutOfAutoRebootGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try  {
        ::Platform::IBox<bool>^ result = wrapper->_instance->OptOutOfAutoReboot;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Boolean>(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void OptOutOfAutoRebootSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsBoolean()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try {

        ::Platform::IBox<bool>^ winRtValue = ref new ::Platform::Box<bool>(Nan::To<bool>(value).FromMaybe(false));

        wrapper->_instance->OptOutOfAutoReboot = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ComplianceGracePeriodInDaysGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try  {
        ::Platform::IBox<int>^ result = wrapper->_instance->ComplianceGracePeriodInDays;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Integer>(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ComplianceGracePeriodInDaysSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsInt32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try {

        ::Platform::IBox<int>^ winRtValue = ref new ::Platform::Box<int>(static_cast<int>(Nan::To<int32_t>(value).FromMaybe(0)));

        wrapper->_instance->ComplianceGracePeriodInDays = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ComplianceDeadlineInDaysGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try  {
        ::Platform::IBox<int>^ result = wrapper->_instance->ComplianceDeadlineInDays;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Integer>(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ComplianceDeadlineInDaysSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsInt32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try {

        ::Platform::IBox<int>^ winRtValue = ref new ::Platform::Box<int>(static_cast<int>(Nan::To<int32_t>(value).FromMaybe(0)));

        wrapper->_instance->ComplianceDeadlineInDays = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AllowDownloadOnMeteredGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try  {
        ::Platform::IBox<bool>^ result = wrapper->_instance->AllowDownloadOnMetered;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Boolean>(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AllowDownloadOnMeteredSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsBoolean()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateApprovalData^>(info.This())) {
        return;
      }

      WindowsUpdateApprovalData *wrapper = WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(info.This());

      try {

        ::Platform::IBox<bool>^ winRtValue = ref new ::Platform::Box<bool>(Nan::To<bool>(value).FromMaybe(false));

        wrapper->_instance->AllowDownloadOnMetered = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateApprovalData^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateApprovalData(::Windows::Management::Update::WindowsUpdateApprovalData^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateApprovalData^ UnwrapWindowsUpdateApprovalData(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateApprovalData::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateApprovalData(::Windows::Management::Update::WindowsUpdateApprovalData^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateApprovalData::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateApprovalData^ UnwrapWindowsUpdateApprovalData(Local<Value> value) {
     return WindowsUpdateApprovalData::Unwrap<WindowsUpdateApprovalData>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateApprovalData(Local<Object> exports) {
    WindowsUpdateApprovalData::Init(exports);
  }

  class WindowsUpdateAttentionRequiredInfo : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateAttentionRequiredInfo").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("reason").ToLocalChecked(), ReasonGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("timestamp").ToLocalChecked(), TimestampGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateAttentionRequiredInfo").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateAttentionRequiredInfo(::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateAttentionRequiredInfo *wrapperInstance = new WindowsUpdateAttentionRequiredInfo(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateAttentionRequiredInfo(winRtInstance));
    }





    static void ReasonGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^>(info.This())) {
        return;
      }

      WindowsUpdateAttentionRequiredInfo *wrapper = WindowsUpdateAttentionRequiredInfo::Unwrap<WindowsUpdateAttentionRequiredInfo>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateAttentionRequiredReason result = wrapper->_instance->Reason;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TimestampGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^>(info.This())) {
        return;
      }

      WindowsUpdateAttentionRequiredInfo *wrapper = WindowsUpdateAttentionRequiredInfo::Unwrap<WindowsUpdateAttentionRequiredInfo>(info.This());

      try  {
        ::Platform::IBox<::Windows::Foundation::DateTime>^ result = wrapper->_instance->Timestamp;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(NodeRT::Utils::DateTimeToJS(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateAttentionRequiredInfo(::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ UnwrapWindowsUpdateAttentionRequiredInfo(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateAttentionRequiredInfo::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateAttentionRequiredInfo(::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateAttentionRequiredInfo::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateAttentionRequiredInfo^ UnwrapWindowsUpdateAttentionRequiredInfo(Local<Value> value) {
     return WindowsUpdateAttentionRequiredInfo::Unwrap<WindowsUpdateAttentionRequiredInfo>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateAttentionRequiredInfo(Local<Object> exports) {
    WindowsUpdateAttentionRequiredInfo::Init(exports);
  }

  class WindowsUpdateAttentionRequiredReasonChangedEventArgs : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateAttentionRequiredReasonChangedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("reason").ToLocalChecked(), ReasonGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("update").ToLocalChecked(), UpdateGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateAttentionRequiredReasonChangedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateAttentionRequiredReasonChangedEventArgs(::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateAttentionRequiredReasonChangedEventArgs *wrapperInstance = new WindowsUpdateAttentionRequiredReasonChangedEventArgs(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(winRtInstance));
    }





    static void ReasonGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateAttentionRequiredReasonChangedEventArgs *wrapper = WindowsUpdateAttentionRequiredReasonChangedEventArgs::Unwrap<WindowsUpdateAttentionRequiredReasonChangedEventArgs>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateAttentionRequiredReason result = wrapper->_instance->Reason;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void UpdateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateAttentionRequiredReasonChangedEventArgs *wrapper = WindowsUpdateAttentionRequiredReasonChangedEventArgs::Unwrap<WindowsUpdateAttentionRequiredReasonChangedEventArgs>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdate^ result = wrapper->_instance->Update;
        info.GetReturnValue().Set(WrapWindowsUpdate(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ UnwrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateAttentionRequiredReasonChangedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateAttentionRequiredReasonChangedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ UnwrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(Local<Value> value) {
     return WindowsUpdateAttentionRequiredReasonChangedEventArgs::Unwrap<WindowsUpdateAttentionRequiredReasonChangedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateAttentionRequiredReasonChangedEventArgs(Local<Object> exports) {
    WindowsUpdateAttentionRequiredReasonChangedEventArgs::Init(exports);
  }

  class WindowsUpdateGetAdministratorResult : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateGetAdministratorResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("administrator").ToLocalChecked(), AdministratorGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateGetAdministratorResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateGetAdministratorResult(::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateGetAdministratorResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateGetAdministratorResult^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateGetAdministratorResult *wrapperInstance = new WindowsUpdateGetAdministratorResult(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateGetAdministratorResult^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateGetAdministratorResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateGetAdministratorResult(winRtInstance));
    }





    static void AdministratorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateGetAdministratorResult^>(info.This())) {
        return;
      }

      WindowsUpdateGetAdministratorResult *wrapper = WindowsUpdateGetAdministratorResult::Unwrap<WindowsUpdateGetAdministratorResult>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateAdministrator^ result = wrapper->_instance->Administrator;
        info.GetReturnValue().Set(WrapWindowsUpdateAdministrator(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateGetAdministratorResult^>(info.This())) {
        return;
      }

      WindowsUpdateGetAdministratorResult *wrapper = WindowsUpdateGetAdministratorResult::Unwrap<WindowsUpdateGetAdministratorResult>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateAdministratorStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateGetAdministratorResult(::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ UnwrapWindowsUpdateGetAdministratorResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateGetAdministratorResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateGetAdministratorResult(::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateGetAdministratorResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateGetAdministratorResult^ UnwrapWindowsUpdateGetAdministratorResult(Local<Value> value) {
     return WindowsUpdateGetAdministratorResult::Unwrap<WindowsUpdateGetAdministratorResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateGetAdministratorResult(Local<Object> exports) {
    WindowsUpdateGetAdministratorResult::Init(exports);
  }

  class WindowsUpdateItem : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateItem").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("category").ToLocalChecked(), CategoryGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("description").ToLocalChecked(), DescriptionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("moreInfoUrl").ToLocalChecked(), MoreInfoUrlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("operation").ToLocalChecked(), OperationGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("providerId").ToLocalChecked(), ProviderIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("timestamp").ToLocalChecked(), TimestampGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("title").ToLocalChecked(), TitleGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("updateId").ToLocalChecked(), UpdateIdGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateItem").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateItem(::Windows::Management::Update::WindowsUpdateItem^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateItem^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateItem^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateItem *wrapperInstance = new WindowsUpdateItem(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateItem^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateItem^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateItem(winRtInstance));
    }





    static void CategoryGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Category;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Description;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MoreInfoUrlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->MoreInfoUrl;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void OperationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Operation;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ProviderIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->ProviderId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TimestampGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Timestamp;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TitleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Title;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void UpdateIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(info.This())) {
        return;
      }

      WindowsUpdateItem *wrapper = WindowsUpdateItem::Unwrap<WindowsUpdateItem>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->UpdateId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateItem^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateItem(::Windows::Management::Update::WindowsUpdateItem^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateItem^ UnwrapWindowsUpdateItem(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateItem::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateItem(::Windows::Management::Update::WindowsUpdateItem^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateItem::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateItem^ UnwrapWindowsUpdateItem(Local<Value> value) {
     return WindowsUpdateItem::Unwrap<WindowsUpdateItem>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateItem(Local<Object> exports) {
    WindowsUpdateItem::Init(exports);
  }

  class WindowsUpdateManager : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "getApplicableUpdates", GetApplicableUpdates);
            Nan::SetPrototypeMethod(localRef, "getMostRecentCompletedUpdates", GetMostRecentCompletedUpdates);
            Nan::SetPrototypeMethod(localRef, "startScan", StartScan);
          

          
            Nan::SetPrototypeMethod(localRef, "getMostRecentCompletedUpdatesAsync", GetMostRecentCompletedUpdatesAsync);
          

          
          Nan::SetPrototypeMethod(localRef,"addListener", AddListener);
          Nan::SetPrototypeMethod(localRef,"on", AddListener);
          Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener);
          Nan::SetPrototypeMethod(localRef, "off", RemoveListener);

          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isScanning").ToLocalChecked(), IsScanningGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isWorking").ToLocalChecked(), IsWorkingGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lastSuccessfulScanTimestamp").ToLocalChecked(), LastSuccessfulScanTimestampGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateManager(::Windows::Management::Update::WindowsUpdateManager^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateManager^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 1
        && info[0]->IsString())
      {
        try {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          winRtInstance = ref new ::Windows::Management::Update::WindowsUpdateManager(arg0);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateManager *wrapperInstance = new WindowsUpdateManager(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateManager(winRtInstance));
    }

    static void GetMostRecentCompletedUpdatesAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This())) {
        return;
      }

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::Management::Update::WindowsUpdateItem^>^>^ op;


      if (info.Length() == 2
        && info[0]->IsInt32())
      {
        try
        {
          int arg0 = static_cast<int>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->GetMostRecentCompletedUpdatesAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Foundation::Collections::IVectorView<::Windows::Management::Update::WindowsUpdateItem^>^> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::Management::Update::WindowsUpdateItem^>::CreateVectorViewWrapper(result, 
            [](::Windows::Management::Update::WindowsUpdateItem^ val) -> Local<Value> {
              return WrapWindowsUpdateItem(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(value);
            },
            [](Local<Value> value) -> ::Windows::Management::Update::WindowsUpdateItem^ {
              return UnwrapWindowsUpdateItem(value);
            }
          );
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        } catch (Platform::Exception^ exception) {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetApplicableUpdates(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This())) {
        return;
      }

      WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Foundation::Collections::IVectorView<::Windows::Management::Update::WindowsUpdate^>^ result;
          result = wrapper->_instance->GetApplicableUpdates();
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Management::Update::WindowsUpdate^>::CreateVectorViewWrapper(result, 
            [](::Windows::Management::Update::WindowsUpdate^ val) -> Local<Value> {
              return WrapWindowsUpdate(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(value);
            },
            [](Local<Value> value) -> ::Windows::Management::Update::WindowsUpdate^ {
              return UnwrapWindowsUpdate(value);
            }
          ));
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void GetMostRecentCompletedUpdates(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This())) {
        return;
      }

      WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          int arg0 = static_cast<int>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          ::Windows::Foundation::Collections::IVectorView<::Windows::Management::Update::WindowsUpdateItem^>^ result;
          result = wrapper->_instance->GetMostRecentCompletedUpdates(arg0);
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Management::Update::WindowsUpdateItem^>::CreateVectorViewWrapper(result, 
            [](::Windows::Management::Update::WindowsUpdateItem^ val) -> Local<Value> {
              return WrapWindowsUpdateItem(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateItem^>(value);
            },
            [](Local<Value> value) -> ::Windows::Management::Update::WindowsUpdateItem^ {
              return UnwrapWindowsUpdateItem(value);
            }
          ));
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void StartScan(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This())) {
        return;
      }

      WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());

      if (info.Length() == 1
        && info[0]->IsBoolean())
      {
        try
        {
          bool arg0 = Nan::To<bool>(info[0]).FromMaybe(false);
          
          wrapper->_instance->StartScan(arg0);
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void IsScanningGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This())) {
        return;
      }

      WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());

      try  {
        bool result = wrapper->_instance->IsScanning;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsWorkingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This())) {
        return;
      }

      WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());

      try  {
        bool result = wrapper->_instance->IsWorking;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LastSuccessfulScanTimestampGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This())) {
        return;
      }

      WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());

      try  {
        ::Platform::IBox<::Windows::Foundation::DateTime>^ result = wrapper->_instance->LastSuccessfulScanTimestamp;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(NodeRT::Utils::DateTimeToJS(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)")));
        return;
      }

      String::Value eventName(v8::Isolate::GetCurrent(), info[0]);
      auto str = *eventName;

      Local<Function> callback = info[1].As<Function>();

      ::Windows::Foundation::EventRegistrationToken registrationToken;
      if (NodeRT::Utils::CaseInsenstiveEquals(L"actionCompleted", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
        {
          Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
      return;
        }
        WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = wrapper->_instance->ActionCompleted::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Management::Update::WindowsUpdateManager^, ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^>(
            [callbackObjPtr](::Windows::Management::Update::WindowsUpdateManager^ arg0, ::Windows::Management::Update::WindowsUpdateActionCompletedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapWindowsUpdateManager(arg0);
                  wrappedArg1 = WrapWindowsUpdateActionCompletedEventArgs(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"attentionRequiredReasonChanged", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
        {
          Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
      return;
        }
        WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = wrapper->_instance->AttentionRequiredReasonChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Management::Update::WindowsUpdateManager^, ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^>(
            [callbackObjPtr](::Windows::Management::Update::WindowsUpdateManager^ arg0, ::Windows::Management::Update::WindowsUpdateAttentionRequiredReasonChangedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapWindowsUpdateManager(arg0);
                  wrappedArg1 = WrapWindowsUpdateAttentionRequiredReasonChangedEventArgs(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"progressChanged", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
        {
          Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
      return;
        }
        WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = wrapper->_instance->ProgressChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Management::Update::WindowsUpdateManager^, ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^>(
            [callbackObjPtr](::Windows::Management::Update::WindowsUpdateManager^ arg0, ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapWindowsUpdateManager(arg0);
                  wrappedArg1 = WrapWindowsUpdateProgressChangedEventArgs(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"scanCompleted", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
        {
          Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
      return;
        }
        WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = wrapper->_instance->ScanCompleted::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Management::Update::WindowsUpdateManager^, ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^>(
            [callbackObjPtr](::Windows::Management::Update::WindowsUpdateManager^ arg0, ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapWindowsUpdateManager(arg0);
                  wrappedArg1 = WrapWindowsUpdateScanCompletedEventArgs(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"scanningStateChanged", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
        {
          Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
      return;
        }
        WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = wrapper->_instance->ScanningStateChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Management::Update::WindowsUpdateManager^, ::Platform::Object^>(
            [callbackObjPtr](::Windows::Management::Update::WindowsUpdateManager^ arg0, ::Platform::Object^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapWindowsUpdateManager(arg0);
                  wrappedArg1 = CreateOpaqueWrapper(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"workingStateChanged", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
        {
          Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
      return;
        }
        WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = wrapper->_instance->WorkingStateChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Management::Update::WindowsUpdateManager^, ::Platform::Object^>(
            [callbackObjPtr](::Windows::Management::Update::WindowsUpdateManager^ arg0, ::Platform::Object^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapWindowsUpdateManager(arg0);
                  wrappedArg1 = CreateOpaqueWrapper(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
 else  {
        Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As<String>())));
        return;
      }

      Local<Value> tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New<String>(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked());
      Local<Object> tokenMap;

      if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) {
        tokenMap = Nan::New<Object>();
        NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New<String>(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap);
      } else {
        tokenMap = Nan::To<Object>(tokenMapVal).ToLocalChecked();
      }

      Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value)));
    }

    static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback")));
        return;
      }

      String::Value eventName(v8::Isolate::GetCurrent(), info[0]);
      auto str = *eventName;

      if ((!NodeRT::Utils::CaseInsenstiveEquals(L"actionCompleted", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"attentionRequiredReasonChanged", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"progressChanged", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"scanCompleted", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"scanningStateChanged", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"workingStateChanged", str))) {
        Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As<String>())));
        return;
      }

      Local<Function> callback = info[1].As<Function>();
      Local<Value> tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New<String>(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked());

      if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) {
        return;
      }

      Local<Value> opaqueWrapperObj =  Nan::Get(Nan::To<Object>(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked();

      if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) {
        return;
      }

      OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap<OpaqueWrapper>(opaqueWrapperObj.As<Object>());

      long long tokenValue = (long long) opaqueWrapper->GetObjectInstance();
      ::Windows::Foundation::EventRegistrationToken registrationToken;
      registrationToken.Value = tokenValue;

      try  {
        if (NodeRT::Utils::CaseInsenstiveEquals(L"actionCompleted", str)) {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
          {
            Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
            return;
          }
          WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
          wrapper->_instance->ActionCompleted::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"attentionRequiredReasonChanged", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
          {
            Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
            return;
          }
          WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
          wrapper->_instance->AttentionRequiredReasonChanged::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"progressChanged", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
          {
            Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
            return;
          }
          WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
          wrapper->_instance->ProgressChanged::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"scanCompleted", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
          {
            Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
            return;
          }
          WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
          wrapper->_instance->ScanCompleted::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"scanningStateChanged", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
          {
            Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
            return;
          }
          WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
          wrapper->_instance->ScanningStateChanged::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"workingStateChanged", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateManager^>(info.This()))
          {
            Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed")));
            return;
          }
          WindowsUpdateManager *wrapper = WindowsUpdateManager::Unwrap<WindowsUpdateManager>(info.This());
          wrapper->_instance->WorkingStateChanged::remove(registrationToken);
        }
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }

      Nan::Delete(Nan::To<Object>(tokenMap).ToLocalChecked(), Nan::To<String>(info[0]).ToLocalChecked());
    }
    private:
      ::Windows::Management::Update::WindowsUpdateManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateManager(::Windows::Management::Update::WindowsUpdateManager^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateManager^ UnwrapWindowsUpdateManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateManager(::Windows::Management::Update::WindowsUpdateManager^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateManager^ UnwrapWindowsUpdateManager(Local<Value> value) {
     return WindowsUpdateManager::Unwrap<WindowsUpdateManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateManager(Local<Object> exports) {
    WindowsUpdateManager::Init(exports);
  }

  class WindowsUpdateProgressChangedEventArgs : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateProgressChangedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("actionProgress").ToLocalChecked(), ActionProgressGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("update").ToLocalChecked(), UpdateGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateProgressChangedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateProgressChangedEventArgs(::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateProgressChangedEventArgs *wrapperInstance = new WindowsUpdateProgressChangedEventArgs(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateProgressChangedEventArgs(winRtInstance));
    }





    static void ActionProgressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateProgressChangedEventArgs *wrapper = WindowsUpdateProgressChangedEventArgs::Unwrap<WindowsUpdateProgressChangedEventArgs>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdateActionProgress^ result = wrapper->_instance->ActionProgress;
        info.GetReturnValue().Set(WrapWindowsUpdateActionProgress(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void UpdateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateProgressChangedEventArgs *wrapper = WindowsUpdateProgressChangedEventArgs::Unwrap<WindowsUpdateProgressChangedEventArgs>(info.This());

      try  {
        ::Windows::Management::Update::WindowsUpdate^ result = wrapper->_instance->Update;
        info.GetReturnValue().Set(WrapWindowsUpdate(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateProgressChangedEventArgs(::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ UnwrapWindowsUpdateProgressChangedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateProgressChangedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateProgressChangedEventArgs(::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateProgressChangedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateProgressChangedEventArgs^ UnwrapWindowsUpdateProgressChangedEventArgs(Local<Value> value) {
     return WindowsUpdateProgressChangedEventArgs::Unwrap<WindowsUpdateProgressChangedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateProgressChangedEventArgs(Local<Object> exports) {
    WindowsUpdateProgressChangedEventArgs::Init(exports);
  }

  class WindowsUpdateRestartRequestOptions : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateRestartRequestOptions").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("title").ToLocalChecked(), TitleGetter, TitleSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("organizationName").ToLocalChecked(), OrganizationNameGetter, OrganizationNameSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("optOutOfAutoReboot").ToLocalChecked(), OptOutOfAutoRebootGetter, OptOutOfAutoRebootSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("moreInfoUrl").ToLocalChecked(), MoreInfoUrlGetter, MoreInfoUrlSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("description").ToLocalChecked(), DescriptionGetter, DescriptionSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("complianceGracePeriodInDays").ToLocalChecked(), ComplianceGracePeriodInDaysGetter, ComplianceGracePeriodInDaysSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("complianceDeadlineInDays").ToLocalChecked(), ComplianceDeadlineInDaysGetter, ComplianceDeadlineInDaysSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateRestartRequestOptions").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateRestartRequestOptions(::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateRestartRequestOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 5
        && info[0]->IsString()
        && info[1]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(info[2])
        && info[3]->IsInt32()
        && info[4]->IsInt32())
      {
        try {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Foundation::Uri^ arg2 = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(info[2]));
          int arg3 = static_cast<int>(Nan::To<int32_t>(info[3]).FromMaybe(0));
          int arg4 = static_cast<int>(Nan::To<int32_t>(info[4]).FromMaybe(0));
          
          winRtInstance = ref new ::Windows::Management::Update::WindowsUpdateRestartRequestOptions(arg0,arg1,arg2,arg3,arg4);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Management::Update::WindowsUpdateRestartRequestOptions();
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateRestartRequestOptions *wrapperInstance = new WindowsUpdateRestartRequestOptions(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateRestartRequestOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateRestartRequestOptions(winRtInstance));
    }





    static void TitleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Title;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TitleSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsString()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->Title = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void OrganizationNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->OrganizationName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void OrganizationNameSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsString()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->OrganizationName = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void OptOutOfAutoRebootGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try  {
        bool result = wrapper->_instance->OptOutOfAutoReboot;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void OptOutOfAutoRebootSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsBoolean()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->OptOutOfAutoReboot = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void MoreInfoUrlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try  {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->MoreInfoUrl;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MoreInfoUrlSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value)) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try {

        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->MoreInfoUrl = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Description;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DescriptionSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsString()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->Description = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ComplianceGracePeriodInDaysGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try  {
        int result = wrapper->_instance->ComplianceGracePeriodInDays;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ComplianceGracePeriodInDaysSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsInt32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try {

        int winRtValue = static_cast<int>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->ComplianceGracePeriodInDays = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ComplianceDeadlineInDaysGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try  {
        int result = wrapper->_instance->ComplianceDeadlineInDays;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ComplianceDeadlineInDaysSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsInt32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateRestartRequestOptions^>(info.This())) {
        return;
      }

      WindowsUpdateRestartRequestOptions *wrapper = WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(info.This());

      try {

        int winRtValue = static_cast<int>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->ComplianceDeadlineInDays = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateRestartRequestOptions(::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ UnwrapWindowsUpdateRestartRequestOptions(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateRestartRequestOptions::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateRestartRequestOptions(::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateRestartRequestOptions::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateRestartRequestOptions^ UnwrapWindowsUpdateRestartRequestOptions(Local<Value> value) {
     return WindowsUpdateRestartRequestOptions::Unwrap<WindowsUpdateRestartRequestOptions>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateRestartRequestOptions(Local<Object> exports) {
    WindowsUpdateRestartRequestOptions::Init(exports);
  }

  class WindowsUpdateScanCompletedEventArgs : public WrapperBase {
    public:
      
      static void Init(const Local<Object> exports) {
        HandleScope scope;

        Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
        s_constructorTemplate.Reset(localRef);
        localRef->SetClassName(Nan::New<String>("WindowsUpdateScanCompletedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("extendedError").ToLocalChecked(), ExtendedErrorGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("providerId").ToLocalChecked(), ProviderIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("succeeded").ToLocalChecked(), SucceededGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("updates").ToLocalChecked(), UpdatesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WindowsUpdateScanCompletedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WindowsUpdateScanCompletedEventArgs(::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ instance) {
        _instance = instance;
      }

      
    static void New(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This())) {
        if (info.Length() > 0) {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++) {
            argsPtr[i] = info[i];
          }

          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        } else {
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);

          if (res.IsEmpty()) {
            return;
          }

          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }

      ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      WindowsUpdateScanCompletedEventArgs *wrapperInstance = new WindowsUpdateScanCompletedEventArgs(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


      
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;
      if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^>(info[0])) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
        return;
      }

      ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWindowsUpdateScanCompletedEventArgs(winRtInstance));
    }





    static void ExtendedErrorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateScanCompletedEventArgs *wrapper = WindowsUpdateScanCompletedEventArgs::Unwrap<WindowsUpdateScanCompletedEventArgs>(info.This());

      try  {
        ::Windows::Foundation::HResult result = wrapper->_instance->ExtendedError;
        info.GetReturnValue().Set(Nan::New<Integer>(result.Value));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ProviderIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateScanCompletedEventArgs *wrapper = WindowsUpdateScanCompletedEventArgs::Unwrap<WindowsUpdateScanCompletedEventArgs>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->ProviderId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SucceededGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateScanCompletedEventArgs *wrapper = WindowsUpdateScanCompletedEventArgs::Unwrap<WindowsUpdateScanCompletedEventArgs>(info.This());

      try  {
        bool result = wrapper->_instance->Succeeded;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void UpdatesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^>(info.This())) {
        return;
      }

      WindowsUpdateScanCompletedEventArgs *wrapper = WindowsUpdateScanCompletedEventArgs::Unwrap<WindowsUpdateScanCompletedEventArgs>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Management::Update::WindowsUpdate^>^ result = wrapper->_instance->Updates;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Management::Update::WindowsUpdate^>::CreateVectorViewWrapper(result, 
            [](::Windows::Management::Update::WindowsUpdate^ val) -> Local<Value> {
              return WrapWindowsUpdate(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Management::Update::WindowsUpdate^>(value);
            },
            [](Local<Value> value) -> ::Windows::Management::Update::WindowsUpdate^ {
              return UnwrapWindowsUpdate(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWindowsUpdateScanCompletedEventArgs(::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ wintRtInstance);
      friend ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ UnwrapWindowsUpdateScanCompletedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> WindowsUpdateScanCompletedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapWindowsUpdateScanCompletedEventArgs(::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ winRtInstance) {
    EscapableHandleScope scope;

    if (winRtInstance == nullptr) {
      return scope.Escape(Undefined());
    }

    Local<Value> opaqueWrapper = CreateOpaqueWrapper(winRtInstance);
    Local<Value> args[] = {opaqueWrapper};
    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(WindowsUpdateScanCompletedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Management::Update::WindowsUpdateScanCompletedEventArgs^ UnwrapWindowsUpdateScanCompletedEventArgs(Local<Value> value) {
     return WindowsUpdateScanCompletedEventArgs::Unwrap<WindowsUpdateScanCompletedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWindowsUpdateScanCompletedEventArgs(Local<Object> exports) {
    WindowsUpdateScanCompletedEventArgs::Init(exports);
  }


} } } } 

NAN_MODULE_INIT(init) {
  // We ignore failures for now since it probably means that
  // the initialization already happened for STA, and that's cool

  CoInitializeEx(nullptr, COINIT_MULTITHREADED);

  /*
  if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) {
    Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"error in CoInitializeEx()")));
    return;
  }
  */

      NodeRT::Windows::Management::Update::InitWindowsUpdateAdministratorOptionsEnum(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateAdministratorStatusEnum(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateAttentionRequiredReasonEnum(target);
      NodeRT::Windows::Management::Update::InitPreviewBuildsManager(target);
      NodeRT::Windows::Management::Update::InitPreviewBuildsState(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdate(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateActionCompletedEventArgs(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateActionProgress(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateActionResult(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateAdministrator(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateApprovalData(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateAttentionRequiredInfo(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateAttentionRequiredReasonChangedEventArgs(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateGetAdministratorResult(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateItem(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateManager(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateProgressChangedEventArgs(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateRestartRequestOptions(target);
      NodeRT::Windows::Management::Update::InitWindowsUpdateScanCompletedEventArgs(target);


  NodeRT::Utils::RegisterNameSpace("Windows.Management.Update", target);
}



NODE_MODULE(binding, init)
