// 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 Media { namespace Devices { 
  v8::Local<v8::Value> WrapIDefaultAudioDeviceChangedEventArgs(::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ wintRtInstance);
  ::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ UnwrapIDefaultAudioDeviceChangedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapDefaultAudioCaptureDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ wintRtInstance);
  ::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ UnwrapDefaultAudioCaptureDeviceChangedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapDefaultAudioRenderDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ wintRtInstance);
  ::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ UnwrapDefaultAudioRenderDeviceChangedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapModuleCommandResult(::Windows::Media::Devices::ModuleCommandResult^ wintRtInstance);
  ::Windows::Media::Devices::ModuleCommandResult^ UnwrapModuleCommandResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapAudioDeviceModulesManager(::Windows::Media::Devices::AudioDeviceModulesManager^ wintRtInstance);
  ::Windows::Media::Devices::AudioDeviceModulesManager^ UnwrapAudioDeviceModulesManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapAudioDeviceModuleNotificationEventArgs(::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ wintRtInstance);
  ::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ UnwrapAudioDeviceModuleNotificationEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapAudioDeviceModule(::Windows::Media::Devices::AudioDeviceModule^ wintRtInstance);
  ::Windows::Media::Devices::AudioDeviceModule^ UnwrapAudioDeviceModule(Local<Value> value);
  
  v8::Local<v8::Value> WrapMediaDevice(::Windows::Media::Devices::MediaDevice^ wintRtInstance);
  ::Windows::Media::Devices::MediaDevice^ UnwrapMediaDevice(Local<Value> value);
  
  v8::Local<v8::Value> WrapSceneModeControl(::Windows::Media::Devices::SceneModeControl^ wintRtInstance);
  ::Windows::Media::Devices::SceneModeControl^ UnwrapSceneModeControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapTorchControl(::Windows::Media::Devices::TorchControl^ wintRtInstance);
  ::Windows::Media::Devices::TorchControl^ UnwrapTorchControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapFlashControl(::Windows::Media::Devices::FlashControl^ wintRtInstance);
  ::Windows::Media::Devices::FlashControl^ UnwrapFlashControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapExposureCompensationControl(::Windows::Media::Devices::ExposureCompensationControl^ wintRtInstance);
  ::Windows::Media::Devices::ExposureCompensationControl^ UnwrapExposureCompensationControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapIsoSpeedControl(::Windows::Media::Devices::IsoSpeedControl^ wintRtInstance);
  ::Windows::Media::Devices::IsoSpeedControl^ UnwrapIsoSpeedControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapWhiteBalanceControl(::Windows::Media::Devices::WhiteBalanceControl^ wintRtInstance);
  ::Windows::Media::Devices::WhiteBalanceControl^ UnwrapWhiteBalanceControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapExposureControl(::Windows::Media::Devices::ExposureControl^ wintRtInstance);
  ::Windows::Media::Devices::ExposureControl^ UnwrapExposureControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapZoomSettings(::Windows::Media::Devices::ZoomSettings^ wintRtInstance);
  ::Windows::Media::Devices::ZoomSettings^ UnwrapZoomSettings(Local<Value> value);
  
  v8::Local<v8::Value> WrapZoomControl(::Windows::Media::Devices::ZoomControl^ wintRtInstance);
  ::Windows::Media::Devices::ZoomControl^ UnwrapZoomControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapFocusSettings(::Windows::Media::Devices::FocusSettings^ wintRtInstance);
  ::Windows::Media::Devices::FocusSettings^ UnwrapFocusSettings(Local<Value> value);
  
  v8::Local<v8::Value> WrapFocusControl(::Windows::Media::Devices::FocusControl^ wintRtInstance);
  ::Windows::Media::Devices::FocusControl^ UnwrapFocusControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapRegionOfInterest(::Windows::Media::Devices::RegionOfInterest^ wintRtInstance);
  ::Windows::Media::Devices::RegionOfInterest^ UnwrapRegionOfInterest(Local<Value> value);
  
  v8::Local<v8::Value> WrapRegionsOfInterestControl(::Windows::Media::Devices::RegionsOfInterestControl^ wintRtInstance);
  ::Windows::Media::Devices::RegionsOfInterestControl^ UnwrapRegionsOfInterestControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapExposurePriorityVideoControl(::Windows::Media::Devices::ExposurePriorityVideoControl^ wintRtInstance);
  ::Windows::Media::Devices::ExposurePriorityVideoControl^ UnwrapExposurePriorityVideoControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapHdrVideoControl(::Windows::Media::Devices::HdrVideoControl^ wintRtInstance);
  ::Windows::Media::Devices::HdrVideoControl^ UnwrapHdrVideoControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapAdvancedPhotoCaptureSettings(::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ wintRtInstance);
  ::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ UnwrapAdvancedPhotoCaptureSettings(Local<Value> value);
  
  v8::Local<v8::Value> WrapAdvancedPhotoControl(::Windows::Media::Devices::AdvancedPhotoControl^ wintRtInstance);
  ::Windows::Media::Devices::AdvancedPhotoControl^ UnwrapAdvancedPhotoControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapOpticalImageStabilizationControl(::Windows::Media::Devices::OpticalImageStabilizationControl^ wintRtInstance);
  ::Windows::Media::Devices::OpticalImageStabilizationControl^ UnwrapOpticalImageStabilizationControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapIMediaDeviceController(::Windows::Media::Devices::IMediaDeviceController^ wintRtInstance);
  ::Windows::Media::Devices::IMediaDeviceController^ UnwrapIMediaDeviceController(Local<Value> value);
  
  v8::Local<v8::Value> WrapMediaDeviceControl(::Windows::Media::Devices::MediaDeviceControl^ wintRtInstance);
  ::Windows::Media::Devices::MediaDeviceControl^ UnwrapMediaDeviceControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapLowLagPhotoSequenceControl(::Windows::Media::Devices::LowLagPhotoSequenceControl^ wintRtInstance);
  ::Windows::Media::Devices::LowLagPhotoSequenceControl^ UnwrapLowLagPhotoSequenceControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapLowLagPhotoControl(::Windows::Media::Devices::LowLagPhotoControl^ wintRtInstance);
  ::Windows::Media::Devices::LowLagPhotoControl^ UnwrapLowLagPhotoControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoConfirmationControl(::Windows::Media::Devices::PhotoConfirmationControl^ wintRtInstance);
  ::Windows::Media::Devices::PhotoConfirmationControl^ UnwrapPhotoConfirmationControl(Local<Value> value);
  
  v8::Local<v8::Value> WrapVideoDeviceControllerGetDevicePropertyResult(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ wintRtInstance);
  ::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ UnwrapVideoDeviceControllerGetDevicePropertyResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapMediaDeviceControlCapabilities(::Windows::Media::Devices::MediaDeviceControlCapabilities^ wintRtInstance);
  ::Windows::Media::Devices::MediaDeviceControlCapabilities^ UnwrapMediaDeviceControlCapabilities(Local<Value> value);
  
  v8::Local<v8::Value> WrapVideoDeviceController(::Windows::Media::Devices::VideoDeviceController^ wintRtInstance);
  ::Windows::Media::Devices::VideoDeviceController^ UnwrapVideoDeviceController(Local<Value> value);
  
  v8::Local<v8::Value> WrapAudioDeviceController(::Windows::Media::Devices::AudioDeviceController^ wintRtInstance);
  ::Windows::Media::Devices::AudioDeviceController^ UnwrapAudioDeviceController(Local<Value> value);
  
  v8::Local<v8::Value> WrapDialRequestedEventArgs(::Windows::Media::Devices::DialRequestedEventArgs^ wintRtInstance);
  ::Windows::Media::Devices::DialRequestedEventArgs^ UnwrapDialRequestedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapRedialRequestedEventArgs(::Windows::Media::Devices::RedialRequestedEventArgs^ wintRtInstance);
  ::Windows::Media::Devices::RedialRequestedEventArgs^ UnwrapRedialRequestedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapKeypadPressedEventArgs(::Windows::Media::Devices::KeypadPressedEventArgs^ wintRtInstance);
  ::Windows::Media::Devices::KeypadPressedEventArgs^ UnwrapKeypadPressedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapCallControl(::Windows::Media::Devices::CallControl^ wintRtInstance);
  ::Windows::Media::Devices::CallControl^ UnwrapCallControl(Local<Value> value);
  



  static void InitAudioDeviceRoleEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("AudioDeviceRole").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("default").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AudioDeviceRole::Default)));
    Nan::Set(enumObject, Nan::New<String>("communications").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AudioDeviceRole::Communications)));
  }

  static void InitSendCommandStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("SendCommandStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("success").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::SendCommandStatus::Success)));
    Nan::Set(enumObject, Nan::New<String>("deviceNotAvailable").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::SendCommandStatus::DeviceNotAvailable)));
  }

  static void InitIsoSpeedPresetEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("IsoSpeedPreset").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Auto)));
    Nan::Set(enumObject, Nan::New<String>("iso50").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso50)));
    Nan::Set(enumObject, Nan::New<String>("iso80").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso80)));
    Nan::Set(enumObject, Nan::New<String>("iso100").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso100)));
    Nan::Set(enumObject, Nan::New<String>("iso200").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso200)));
    Nan::Set(enumObject, Nan::New<String>("iso400").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso400)));
    Nan::Set(enumObject, Nan::New<String>("iso800").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso800)));
    Nan::Set(enumObject, Nan::New<String>("iso1600").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso1600)));
    Nan::Set(enumObject, Nan::New<String>("iso3200").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso3200)));
    Nan::Set(enumObject, Nan::New<String>("iso6400").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso6400)));
    Nan::Set(enumObject, Nan::New<String>("iso12800").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso12800)));
    Nan::Set(enumObject, Nan::New<String>("iso25600").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::IsoSpeedPreset::Iso25600)));
  }

  static void InitCaptureSceneModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("CaptureSceneMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Auto)));
    Nan::Set(enumObject, Nan::New<String>("manual").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Manual)));
    Nan::Set(enumObject, Nan::New<String>("macro").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Macro)));
    Nan::Set(enumObject, Nan::New<String>("portrait").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Portrait)));
    Nan::Set(enumObject, Nan::New<String>("sport").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Sport)));
    Nan::Set(enumObject, Nan::New<String>("snow").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Snow)));
    Nan::Set(enumObject, Nan::New<String>("night").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Night)));
    Nan::Set(enumObject, Nan::New<String>("beach").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Beach)));
    Nan::Set(enumObject, Nan::New<String>("sunset").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Sunset)));
    Nan::Set(enumObject, Nan::New<String>("candlelight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Candlelight)));
    Nan::Set(enumObject, Nan::New<String>("landscape").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Landscape)));
    Nan::Set(enumObject, Nan::New<String>("nightPortrait").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::NightPortrait)));
    Nan::Set(enumObject, Nan::New<String>("backlit").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureSceneMode::Backlit)));
  }

  static void InitMediaCaptureFocusStateEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MediaCaptureFocusState").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("uninitialized").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureFocusState::Uninitialized)));
    Nan::Set(enumObject, Nan::New<String>("lost").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureFocusState::Lost)));
    Nan::Set(enumObject, Nan::New<String>("searching").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureFocusState::Searching)));
    Nan::Set(enumObject, Nan::New<String>("focused").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureFocusState::Focused)));
    Nan::Set(enumObject, Nan::New<String>("failed").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureFocusState::Failed)));
  }

  static void InitCameraStreamStateEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("CameraStreamState").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("notStreaming").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CameraStreamState::NotStreaming)));
    Nan::Set(enumObject, Nan::New<String>("streaming").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CameraStreamState::Streaming)));
    Nan::Set(enumObject, Nan::New<String>("blockedForPrivacy").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CameraStreamState::BlockedForPrivacy)));
    Nan::Set(enumObject, Nan::New<String>("shutdown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CameraStreamState::Shutdown)));
  }

  static void InitMediaCapturePauseBehaviorEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MediaCapturePauseBehavior").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("retainHardwareResources").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCapturePauseBehavior::RetainHardwareResources)));
    Nan::Set(enumObject, Nan::New<String>("releaseHardwareResources").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCapturePauseBehavior::ReleaseHardwareResources)));
  }

  static void InitAdvancedPhotoModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("AdvancedPhotoMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AdvancedPhotoMode::Auto)));
    Nan::Set(enumObject, Nan::New<String>("standard").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AdvancedPhotoMode::Standard)));
    Nan::Set(enumObject, Nan::New<String>("hdr").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AdvancedPhotoMode::Hdr)));
    Nan::Set(enumObject, Nan::New<String>("lowLight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AdvancedPhotoMode::LowLight)));
  }

  static void InitColorTemperaturePresetEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ColorTemperaturePreset").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Auto)));
    Nan::Set(enumObject, Nan::New<String>("manual").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Manual)));
    Nan::Set(enumObject, Nan::New<String>("cloudy").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Cloudy)));
    Nan::Set(enumObject, Nan::New<String>("daylight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Daylight)));
    Nan::Set(enumObject, Nan::New<String>("flash").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Flash)));
    Nan::Set(enumObject, Nan::New<String>("fluorescent").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Fluorescent)));
    Nan::Set(enumObject, Nan::New<String>("tungsten").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Tungsten)));
    Nan::Set(enumObject, Nan::New<String>("candlelight").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ColorTemperaturePreset::Candlelight)));
  }

  static void InitZoomTransitionModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ZoomTransitionMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ZoomTransitionMode::Auto)));
    Nan::Set(enumObject, Nan::New<String>("direct").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ZoomTransitionMode::Direct)));
    Nan::Set(enumObject, Nan::New<String>("smooth").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ZoomTransitionMode::Smooth)));
  }

  static void InitFocusPresetEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("FocusPreset").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusPreset::Auto)));
    Nan::Set(enumObject, Nan::New<String>("manual").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusPreset::Manual)));
    Nan::Set(enumObject, Nan::New<String>("autoMacro").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusPreset::AutoMacro)));
    Nan::Set(enumObject, Nan::New<String>("autoNormal").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusPreset::AutoNormal)));
    Nan::Set(enumObject, Nan::New<String>("autoInfinity").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusPreset::AutoInfinity)));
    Nan::Set(enumObject, Nan::New<String>("autoHyperfocal").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusPreset::AutoHyperfocal)));
  }

  static void InitFocusModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("FocusMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusMode::Auto)));
    Nan::Set(enumObject, Nan::New<String>("single").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusMode::Single)));
    Nan::Set(enumObject, Nan::New<String>("continuous").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusMode::Continuous)));
    Nan::Set(enumObject, Nan::New<String>("manual").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::FocusMode::Manual)));
  }

  static void InitManualFocusDistanceEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ManualFocusDistance").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("infinity").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ManualFocusDistance::Infinity)));
    Nan::Set(enumObject, Nan::New<String>("hyperfocal").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ManualFocusDistance::Hyperfocal)));
    Nan::Set(enumObject, Nan::New<String>("nearest").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::ManualFocusDistance::Nearest)));
  }

  static void InitAutoFocusRangeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("AutoFocusRange").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("fullRange").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AutoFocusRange::FullRange)));
    Nan::Set(enumObject, Nan::New<String>("macro").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AutoFocusRange::Macro)));
    Nan::Set(enumObject, Nan::New<String>("normal").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::AutoFocusRange::Normal)));
  }

  static void InitRegionOfInterestTypeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("RegionOfInterestType").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("unknown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::RegionOfInterestType::Unknown)));
    Nan::Set(enumObject, Nan::New<String>("face").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::RegionOfInterestType::Face)));
  }

  static void InitHdrVideoModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("HdrVideoMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("off").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::HdrVideoMode::Off)));
    Nan::Set(enumObject, Nan::New<String>("on").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::HdrVideoMode::On)));
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::HdrVideoMode::Auto)));
  }

  static void InitOpticalImageStabilizationModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("OpticalImageStabilizationMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("off").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::OpticalImageStabilizationMode::Off)));
    Nan::Set(enumObject, Nan::New<String>("on").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::OpticalImageStabilizationMode::On)));
    Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::OpticalImageStabilizationMode::Auto)));
  }

  static void InitCaptureUseEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("CaptureUse").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureUse::None)));
    Nan::Set(enumObject, Nan::New<String>("photo").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureUse::Photo)));
    Nan::Set(enumObject, Nan::New<String>("video").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::CaptureUse::Video)));
  }

  static void InitMediaCaptureOptimizationEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("MediaCaptureOptimization").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("default").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureOptimization::Default)));
    Nan::Set(enumObject, Nan::New<String>("quality").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureOptimization::Quality)));
    Nan::Set(enumObject, Nan::New<String>("latency").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureOptimization::Latency)));
    Nan::Set(enumObject, Nan::New<String>("power").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureOptimization::Power)));
    Nan::Set(enumObject, Nan::New<String>("latencyThenQuality").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureOptimization::LatencyThenQuality)));
    Nan::Set(enumObject, Nan::New<String>("latencyThenPower").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureOptimization::LatencyThenPower)));
    Nan::Set(enumObject, Nan::New<String>("powerAndQuality").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::MediaCaptureOptimization::PowerAndQuality)));
  }

  static void InitVideoDeviceControllerSetDevicePropertyStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("VideoDeviceControllerSetDevicePropertyStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("success").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus::Success)));
    Nan::Set(enumObject, Nan::New<String>("unknownFailure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus::UnknownFailure)));
    Nan::Set(enumObject, Nan::New<String>("notSupported").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus::NotSupported)));
    Nan::Set(enumObject, Nan::New<String>("invalidValue").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus::InvalidValue)));
    Nan::Set(enumObject, Nan::New<String>("deviceNotAvailable").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus::DeviceNotAvailable)));
    Nan::Set(enumObject, Nan::New<String>("notInControl").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus::NotInControl)));
  }

  static void InitVideoDeviceControllerGetDevicePropertyStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("VideoDeviceControllerGetDevicePropertyStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("success").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus::Success)));
    Nan::Set(enumObject, Nan::New<String>("unknownFailure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus::UnknownFailure)));
    Nan::Set(enumObject, Nan::New<String>("bufferTooSmall").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus::BufferTooSmall)));
    Nan::Set(enumObject, Nan::New<String>("notSupported").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus::NotSupported)));
    Nan::Set(enumObject, Nan::New<String>("deviceNotAvailable").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus::DeviceNotAvailable)));
    Nan::Set(enumObject, Nan::New<String>("maxPropertyValueSizeTooSmall").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus::MaxPropertyValueSizeTooSmall)));
    Nan::Set(enumObject, Nan::New<String>("maxPropertyValueSizeRequired").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus::MaxPropertyValueSizeRequired)));
  }

  static void InitTelephonyKeyEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("TelephonyKey").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("d0").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D0)));
    Nan::Set(enumObject, Nan::New<String>("d1").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D1)));
    Nan::Set(enumObject, Nan::New<String>("d2").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D2)));
    Nan::Set(enumObject, Nan::New<String>("d3").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D3)));
    Nan::Set(enumObject, Nan::New<String>("d4").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D4)));
    Nan::Set(enumObject, Nan::New<String>("d5").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D5)));
    Nan::Set(enumObject, Nan::New<String>("d6").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D6)));
    Nan::Set(enumObject, Nan::New<String>("d7").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D7)));
    Nan::Set(enumObject, Nan::New<String>("d8").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D8)));
    Nan::Set(enumObject, Nan::New<String>("d9").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D9)));
    Nan::Set(enumObject, Nan::New<String>("star").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::Star)));
    Nan::Set(enumObject, Nan::New<String>("pound").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::Pound)));
    Nan::Set(enumObject, Nan::New<String>("a").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::A)));
    Nan::Set(enumObject, Nan::New<String>("b").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::B)));
    Nan::Set(enumObject, Nan::New<String>("c").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::C)));
    Nan::Set(enumObject, Nan::New<String>("d").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Devices::TelephonyKey::D)));
  }

  static bool IsCallControlContractJsObject(Local<Value> value) {
    if (!value->IsObject()) {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Media::Devices::CallControlContract CallControlContractFromJsObject(Local<Value> value) {
    HandleScope scope;
    ::Windows::Media::Devices::CallControlContract 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> CallControlContractToJsObject(::Windows::Media::Devices::CallControlContract value) {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();


    return scope.Escape(obj);
  }

  static bool IsRectJsObject(Local<Value> value) {
    if (!value->IsObject()) {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Foundation::Rect RectFromJsObject(Local<Value> value) {
    HandleScope scope;
    ::Windows::Foundation::Rect 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> RectToJsObject(::Windows::Foundation::Rect value) {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();


    return scope.Escape(obj);
  }

  class IDefaultAudioDeviceChangedEventArgs : 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>("IDefaultAudioDeviceChangedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("role").ToLocalChecked(), RoleGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("IDefaultAudioDeviceChangedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      IDefaultAudioDeviceChangedEventArgs(::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ 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::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^) 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());

      IDefaultAudioDeviceChangedEventArgs *wrapperInstance = new IDefaultAudioDeviceChangedEventArgs(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::Media::Devices::IDefaultAudioDeviceChangedEventArgs^>(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::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapIDefaultAudioDeviceChangedEventArgs(winRtInstance));
    }





    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^>(info.This())) {
        return;
      }

      IDefaultAudioDeviceChangedEventArgs *wrapper = IDefaultAudioDeviceChangedEventArgs::Unwrap<IDefaultAudioDeviceChangedEventArgs>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Id;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RoleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^>(info.This())) {
        return;
      }

      IDefaultAudioDeviceChangedEventArgs *wrapper = IDefaultAudioDeviceChangedEventArgs::Unwrap<IDefaultAudioDeviceChangedEventArgs>(info.This());

      try  {
        ::Windows::Media::Devices::AudioDeviceRole result = wrapper->_instance->Role;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapIDefaultAudioDeviceChangedEventArgs(::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ UnwrapIDefaultAudioDeviceChangedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> IDefaultAudioDeviceChangedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapIDefaultAudioDeviceChangedEventArgs(::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ 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>(IDefaultAudioDeviceChangedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::IDefaultAudioDeviceChangedEventArgs^ UnwrapIDefaultAudioDeviceChangedEventArgs(Local<Value> value) {
     return IDefaultAudioDeviceChangedEventArgs::Unwrap<IDefaultAudioDeviceChangedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitIDefaultAudioDeviceChangedEventArgs(Local<Object> exports) {
    IDefaultAudioDeviceChangedEventArgs::Init(exports);
  }

  class DefaultAudioCaptureDeviceChangedEventArgs : 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>("DefaultAudioCaptureDeviceChangedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("role").ToLocalChecked(), RoleGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("DefaultAudioCaptureDeviceChangedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      DefaultAudioCaptureDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ 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::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^) 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());

      DefaultAudioCaptureDeviceChangedEventArgs *wrapperInstance = new DefaultAudioCaptureDeviceChangedEventArgs(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::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^>(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::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapDefaultAudioCaptureDeviceChangedEventArgs(winRtInstance));
    }





    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^>(info.This())) {
        return;
      }

      DefaultAudioCaptureDeviceChangedEventArgs *wrapper = DefaultAudioCaptureDeviceChangedEventArgs::Unwrap<DefaultAudioCaptureDeviceChangedEventArgs>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Id;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RoleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^>(info.This())) {
        return;
      }

      DefaultAudioCaptureDeviceChangedEventArgs *wrapper = DefaultAudioCaptureDeviceChangedEventArgs::Unwrap<DefaultAudioCaptureDeviceChangedEventArgs>(info.This());

      try  {
        ::Windows::Media::Devices::AudioDeviceRole result = wrapper->_instance->Role;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapDefaultAudioCaptureDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ UnwrapDefaultAudioCaptureDeviceChangedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> DefaultAudioCaptureDeviceChangedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapDefaultAudioCaptureDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ 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>(DefaultAudioCaptureDeviceChangedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ UnwrapDefaultAudioCaptureDeviceChangedEventArgs(Local<Value> value) {
     return DefaultAudioCaptureDeviceChangedEventArgs::Unwrap<DefaultAudioCaptureDeviceChangedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitDefaultAudioCaptureDeviceChangedEventArgs(Local<Object> exports) {
    DefaultAudioCaptureDeviceChangedEventArgs::Init(exports);
  }

  class DefaultAudioRenderDeviceChangedEventArgs : 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>("DefaultAudioRenderDeviceChangedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("role").ToLocalChecked(), RoleGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("DefaultAudioRenderDeviceChangedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      DefaultAudioRenderDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ 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::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^) 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());

      DefaultAudioRenderDeviceChangedEventArgs *wrapperInstance = new DefaultAudioRenderDeviceChangedEventArgs(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::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^>(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::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapDefaultAudioRenderDeviceChangedEventArgs(winRtInstance));
    }





    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^>(info.This())) {
        return;
      }

      DefaultAudioRenderDeviceChangedEventArgs *wrapper = DefaultAudioRenderDeviceChangedEventArgs::Unwrap<DefaultAudioRenderDeviceChangedEventArgs>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Id;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RoleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^>(info.This())) {
        return;
      }

      DefaultAudioRenderDeviceChangedEventArgs *wrapper = DefaultAudioRenderDeviceChangedEventArgs::Unwrap<DefaultAudioRenderDeviceChangedEventArgs>(info.This());

      try  {
        ::Windows::Media::Devices::AudioDeviceRole result = wrapper->_instance->Role;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapDefaultAudioRenderDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ UnwrapDefaultAudioRenderDeviceChangedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> DefaultAudioRenderDeviceChangedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapDefaultAudioRenderDeviceChangedEventArgs(::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ 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>(DefaultAudioRenderDeviceChangedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ UnwrapDefaultAudioRenderDeviceChangedEventArgs(Local<Value> value) {
     return DefaultAudioRenderDeviceChangedEventArgs::Unwrap<DefaultAudioRenderDeviceChangedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitDefaultAudioRenderDeviceChangedEventArgs(Local<Object> exports) {
    DefaultAudioRenderDeviceChangedEventArgs::Init(exports);
  }

  class ModuleCommandResult : 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>("ModuleCommandResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("result").ToLocalChecked(), ResultGetter);
            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>("ModuleCommandResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ModuleCommandResult(::Windows::Media::Devices::ModuleCommandResult^ 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::Media::Devices::ModuleCommandResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ModuleCommandResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::ModuleCommandResult^) 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());

      ModuleCommandResult *wrapperInstance = new ModuleCommandResult(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::Media::Devices::ModuleCommandResult^>(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::Media::Devices::ModuleCommandResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::ModuleCommandResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapModuleCommandResult(winRtInstance));
    }





    static void ResultGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ModuleCommandResult^>(info.This())) {
        return;
      }

      ModuleCommandResult *wrapper = ModuleCommandResult::Unwrap<ModuleCommandResult>(info.This());

      try  {
        ::Windows::Storage::Streams::IBuffer^ result = wrapper->_instance->Result;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage.Streams", "IBuffer", 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::Media::Devices::ModuleCommandResult^>(info.This())) {
        return;
      }

      ModuleCommandResult *wrapper = ModuleCommandResult::Unwrap<ModuleCommandResult>(info.This());

      try  {
        ::Windows::Media::Devices::SendCommandStatus 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::Media::Devices::ModuleCommandResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapModuleCommandResult(::Windows::Media::Devices::ModuleCommandResult^ wintRtInstance);
      friend ::Windows::Media::Devices::ModuleCommandResult^ UnwrapModuleCommandResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> ModuleCommandResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapModuleCommandResult(::Windows::Media::Devices::ModuleCommandResult^ 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>(ModuleCommandResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::ModuleCommandResult^ UnwrapModuleCommandResult(Local<Value> value) {
     return ModuleCommandResult::Unwrap<ModuleCommandResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitModuleCommandResult(Local<Object> exports) {
    ModuleCommandResult::Init(exports);
  }

  class AudioDeviceModulesManager : 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>("AudioDeviceModulesManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "findAllById", FindAllById);
            Nan::SetPrototypeMethod(localRef, "findAll", FindAll);
          


          
          Nan::SetPrototypeMethod(localRef,"addListener", AddListener);
          Nan::SetPrototypeMethod(localRef,"on", AddListener);
          Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener);
          Nan::SetPrototypeMethod(localRef, "off", RemoveListener);


        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("AudioDeviceModulesManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      AudioDeviceModulesManager(::Windows::Media::Devices::AudioDeviceModulesManager^ 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::Media::Devices::AudioDeviceModulesManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModulesManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::AudioDeviceModulesManager^) 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::Media::Devices::AudioDeviceModulesManager(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());

      AudioDeviceModulesManager *wrapperInstance = new AudioDeviceModulesManager(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::Media::Devices::AudioDeviceModulesManager^>(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::Media::Devices::AudioDeviceModulesManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::AudioDeviceModulesManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapAudioDeviceModulesManager(winRtInstance));
    }


    static void FindAllById(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModulesManager^>(info.This())) {
        return;
      }

      AudioDeviceModulesManager *wrapper = AudioDeviceModulesManager::Unwrap<AudioDeviceModulesManager>(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])));
          
          ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::AudioDeviceModule^>^ result;
          result = wrapper->_instance->FindAllById(arg0);
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::AudioDeviceModule^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::AudioDeviceModule^ val) -> Local<Value> {
              return WrapAudioDeviceModule(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::AudioDeviceModule^ {
              return UnwrapAudioDeviceModule(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 FindAll(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModulesManager^>(info.This())) {
        return;
      }

      AudioDeviceModulesManager *wrapper = AudioDeviceModulesManager::Unwrap<AudioDeviceModulesManager>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::AudioDeviceModule^>^ result;
          result = wrapper->_instance->FindAll();
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::AudioDeviceModule^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::AudioDeviceModule^ val) -> Local<Value> {
              return WrapAudioDeviceModule(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::AudioDeviceModule^ {
              return UnwrapAudioDeviceModule(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 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"moduleNotificationReceived", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModulesManager^>(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;
        }
        AudioDeviceModulesManager *wrapper = AudioDeviceModulesManager::Unwrap<AudioDeviceModulesManager>(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->ModuleNotificationReceived::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Media::Devices::AudioDeviceModulesManager^, ::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^>(
            [callbackObjPtr](::Windows::Media::Devices::AudioDeviceModulesManager^ arg0, ::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapAudioDeviceModulesManager(arg0);
                  wrappedArg1 = WrapAudioDeviceModuleNotificationEventArgs(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"moduleNotificationReceived", 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"moduleNotificationReceived", str)) {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModulesManager^>(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;
          }
          AudioDeviceModulesManager *wrapper = AudioDeviceModulesManager::Unwrap<AudioDeviceModulesManager>(info.This());
          wrapper->_instance->ModuleNotificationReceived::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::Media::Devices::AudioDeviceModulesManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapAudioDeviceModulesManager(::Windows::Media::Devices::AudioDeviceModulesManager^ wintRtInstance);
      friend ::Windows::Media::Devices::AudioDeviceModulesManager^ UnwrapAudioDeviceModulesManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> AudioDeviceModulesManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapAudioDeviceModulesManager(::Windows::Media::Devices::AudioDeviceModulesManager^ 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>(AudioDeviceModulesManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::AudioDeviceModulesManager^ UnwrapAudioDeviceModulesManager(Local<Value> value) {
     return AudioDeviceModulesManager::Unwrap<AudioDeviceModulesManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAudioDeviceModulesManager(Local<Object> exports) {
    AudioDeviceModulesManager::Init(exports);
  }

  class AudioDeviceModuleNotificationEventArgs : 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>("AudioDeviceModuleNotificationEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("module").ToLocalChecked(), ModuleGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("notificationData").ToLocalChecked(), NotificationDataGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("AudioDeviceModuleNotificationEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      AudioDeviceModuleNotificationEventArgs(::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ 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::Media::Devices::AudioDeviceModuleNotificationEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^) 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());

      AudioDeviceModuleNotificationEventArgs *wrapperInstance = new AudioDeviceModuleNotificationEventArgs(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::Media::Devices::AudioDeviceModuleNotificationEventArgs^>(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::Media::Devices::AudioDeviceModuleNotificationEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapAudioDeviceModuleNotificationEventArgs(winRtInstance));
    }





    static void ModuleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^>(info.This())) {
        return;
      }

      AudioDeviceModuleNotificationEventArgs *wrapper = AudioDeviceModuleNotificationEventArgs::Unwrap<AudioDeviceModuleNotificationEventArgs>(info.This());

      try  {
        ::Windows::Media::Devices::AudioDeviceModule^ result = wrapper->_instance->Module;
        info.GetReturnValue().Set(WrapAudioDeviceModule(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void NotificationDataGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^>(info.This())) {
        return;
      }

      AudioDeviceModuleNotificationEventArgs *wrapper = AudioDeviceModuleNotificationEventArgs::Unwrap<AudioDeviceModuleNotificationEventArgs>(info.This());

      try  {
        ::Windows::Storage::Streams::IBuffer^ result = wrapper->_instance->NotificationData;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage.Streams", "IBuffer", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapAudioDeviceModuleNotificationEventArgs(::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ wintRtInstance);
      friend ::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ UnwrapAudioDeviceModuleNotificationEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> AudioDeviceModuleNotificationEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapAudioDeviceModuleNotificationEventArgs(::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ 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>(AudioDeviceModuleNotificationEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::AudioDeviceModuleNotificationEventArgs^ UnwrapAudioDeviceModuleNotificationEventArgs(Local<Value> value) {
     return AudioDeviceModuleNotificationEventArgs::Unwrap<AudioDeviceModuleNotificationEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAudioDeviceModuleNotificationEventArgs(Local<Object> exports) {
    AudioDeviceModuleNotificationEventArgs::Init(exports);
  }

  class AudioDeviceModule : 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>("AudioDeviceModule").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "sendCommandAsync", SendCommandAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("classId").ToLocalChecked(), ClassIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("instanceId").ToLocalChecked(), InstanceIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("majorVersion").ToLocalChecked(), MajorVersionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("minorVersion").ToLocalChecked(), MinorVersionGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("AudioDeviceModule").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      AudioDeviceModule(::Windows::Media::Devices::AudioDeviceModule^ 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::Media::Devices::AudioDeviceModule^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::AudioDeviceModule^) 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());

      AudioDeviceModule *wrapperInstance = new AudioDeviceModule(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::Media::Devices::AudioDeviceModule^>(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::Media::Devices::AudioDeviceModule^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::AudioDeviceModule^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapAudioDeviceModule(winRtInstance));
    }

    static void SendCommandAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(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;
      }

      AudioDeviceModule *wrapper = AudioDeviceModule::Unwrap<AudioDeviceModule>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Media::Devices::ModuleCommandResult^>^ op;


      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IBuffer^>(info[0]))
      {
        try
        {
          ::Windows::Storage::Streams::IBuffer^ arg0 = dynamic_cast<::Windows::Storage::Streams::IBuffer^>(NodeRT::Utils::GetObjectInstance(info[0]));
          
          op = wrapper->_instance->SendCommandAsync(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::Media::Devices::ModuleCommandResult^> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapModuleCommandResult(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 ClassIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(info.This())) {
        return;
      }

      AudioDeviceModule *wrapper = AudioDeviceModule::Unwrap<AudioDeviceModule>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->ClassId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(info.This())) {
        return;
      }

      AudioDeviceModule *wrapper = AudioDeviceModule::Unwrap<AudioDeviceModule>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->DisplayName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void InstanceIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(info.This())) {
        return;
      }

      AudioDeviceModule *wrapper = AudioDeviceModule::Unwrap<AudioDeviceModule>(info.This());

      try  {
        unsigned int result = wrapper->_instance->InstanceId;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MajorVersionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(info.This())) {
        return;
      }

      AudioDeviceModule *wrapper = AudioDeviceModule::Unwrap<AudioDeviceModule>(info.This());

      try  {
        unsigned int result = wrapper->_instance->MajorVersion;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinorVersionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceModule^>(info.This())) {
        return;
      }

      AudioDeviceModule *wrapper = AudioDeviceModule::Unwrap<AudioDeviceModule>(info.This());

      try  {
        unsigned int result = wrapper->_instance->MinorVersion;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::AudioDeviceModule^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapAudioDeviceModule(::Windows::Media::Devices::AudioDeviceModule^ wintRtInstance);
      friend ::Windows::Media::Devices::AudioDeviceModule^ UnwrapAudioDeviceModule(Local<Value> value);
  };

  Persistent<FunctionTemplate> AudioDeviceModule::s_constructorTemplate;

  v8::Local<v8::Value> WrapAudioDeviceModule(::Windows::Media::Devices::AudioDeviceModule^ 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>(AudioDeviceModule::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::AudioDeviceModule^ UnwrapAudioDeviceModule(Local<Value> value) {
     return AudioDeviceModule::Unwrap<AudioDeviceModule>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAudioDeviceModule(Local<Object> exports) {
    AudioDeviceModule::Init(exports);
  }

  class MediaDevice : 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>("MediaDevice").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);






        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "getAudioCaptureSelector", GetAudioCaptureSelector);
        Nan::SetMethod(constructor, "getAudioRenderSelector", GetAudioRenderSelector);
        Nan::SetMethod(constructor, "getVideoCaptureSelector", GetVideoCaptureSelector);
        Nan::SetMethod(constructor, "getDefaultAudioCaptureId", GetDefaultAudioCaptureId);
        Nan::SetMethod(constructor, "getDefaultAudioRenderId", GetDefaultAudioRenderId);
        
              Local<Function> addListenerFunc = Nan::GetFunction(Nan::New<FunctionTemplate>(AddListener)).ToLocalChecked();
              Nan::Set(constructor, Nan::New<String>("addListener").ToLocalChecked(), addListenerFunc);
              Nan::Set(constructor, Nan::New<String>("on").ToLocalChecked(), addListenerFunc);
              Local<Function> removeListenerFunc = Nan::GetFunction(Nan::New<FunctionTemplate>(RemoveListener)).ToLocalChecked();
              Nan::Set(constructor, Nan::New<String>("removeListener").ToLocalChecked(), removeListenerFunc);
              Nan::Set(constructor, Nan::New<String>("off").ToLocalChecked(), removeListenerFunc);


        Nan::Set(exports, Nan::New<String>("MediaDevice").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MediaDevice(::Windows::Media::Devices::MediaDevice^ 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::Media::Devices::MediaDevice^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDevice^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::MediaDevice^) 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());

      MediaDevice *wrapperInstance = new MediaDevice(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::Media::Devices::MediaDevice^>(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::Media::Devices::MediaDevice^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::MediaDevice^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMediaDevice(winRtInstance));
    }





    static void GetAudioCaptureSelector(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          Platform::String^ result;
          result = ::Windows::Media::Devices::MediaDevice::GetAudioCaptureSelector();
          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 GetAudioRenderSelector(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          Platform::String^ result;
          result = ::Windows::Media::Devices::MediaDevice::GetAudioRenderSelector();
          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 GetVideoCaptureSelector(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          Platform::String^ result;
          result = ::Windows::Media::Devices::MediaDevice::GetVideoCaptureSelector();
          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 GetDefaultAudioCaptureId(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Devices::AudioDeviceRole arg0 = static_cast<::Windows::Media::Devices::AudioDeviceRole>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          Platform::String^ result;
          result = ::Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId(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 GetDefaultAudioRenderId(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Devices::AudioDeviceRole arg0 = static_cast<::Windows::Media::Devices::AudioDeviceRole>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          Platform::String^ result;
          result = ::Windows::Media::Devices::MediaDevice::GetDefaultAudioRenderId(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 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"defaultAudioCaptureDeviceChanged", str))
      {
      
        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 = ::Windows::Media::Devices::MediaDevice::DefaultAudioCaptureDeviceChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Platform::Object^, ::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^>(
            [callbackObjPtr](::Platform::Object^ arg0, ::Windows::Media::Devices::DefaultAudioCaptureDeviceChangedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = CreateOpaqueWrapper(arg0);
                  wrappedArg1 = WrapDefaultAudioCaptureDeviceChangedEventArgs(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"defaultAudioRenderDeviceChanged", str))
      {
      
        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 = ::Windows::Media::Devices::MediaDevice::DefaultAudioRenderDeviceChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Platform::Object^, ::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^>(
            [callbackObjPtr](::Platform::Object^ arg0, ::Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = CreateOpaqueWrapper(arg0);
                  wrappedArg1 = WrapDefaultAudioRenderDeviceChangedEventArgs(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"defaultAudioCaptureDeviceChanged", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"defaultAudioRenderDeviceChanged", 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"defaultAudioCaptureDeviceChanged", str)) {
          ::Windows::Media::Devices::MediaDevice::DefaultAudioCaptureDeviceChanged::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"defaultAudioRenderDeviceChanged", str))
        {
          ::Windows::Media::Devices::MediaDevice::DefaultAudioRenderDeviceChanged::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::Media::Devices::MediaDevice^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMediaDevice(::Windows::Media::Devices::MediaDevice^ wintRtInstance);
      friend ::Windows::Media::Devices::MediaDevice^ UnwrapMediaDevice(Local<Value> value);
  };

  Persistent<FunctionTemplate> MediaDevice::s_constructorTemplate;

  v8::Local<v8::Value> WrapMediaDevice(::Windows::Media::Devices::MediaDevice^ 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>(MediaDevice::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::MediaDevice^ UnwrapMediaDevice(Local<Value> value) {
     return MediaDevice::Unwrap<MediaDevice>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMediaDevice(Local<Object> exports) {
    MediaDevice::Init(exports);
  }

  class SceneModeControl : 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>("SceneModeControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "setValueAsync", SetValueAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedModes").ToLocalChecked(), SupportedModesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("SceneModeControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      SceneModeControl(::Windows::Media::Devices::SceneModeControl^ 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::Media::Devices::SceneModeControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::SceneModeControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::SceneModeControl^) 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());

      SceneModeControl *wrapperInstance = new SceneModeControl(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::Media::Devices::SceneModeControl^>(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::Media::Devices::SceneModeControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::SceneModeControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapSceneModeControl(winRtInstance));
    }

    static void SetValueAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::SceneModeControl^>(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;
      }

      SceneModeControl *wrapper = SceneModeControl::Unwrap<SceneModeControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Devices::CaptureSceneMode arg0 = static_cast<::Windows::Media::Devices::CaptureSceneMode>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetValueAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 SupportedModesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::SceneModeControl^>(info.This())) {
        return;
      }

      SceneModeControl *wrapper = SceneModeControl::Unwrap<SceneModeControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::CaptureSceneMode>^ result = wrapper->_instance->SupportedModes;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::CaptureSceneMode>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::CaptureSceneMode val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::CaptureSceneMode {
              return static_cast<::Windows::Media::Devices::CaptureSceneMode>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::SceneModeControl^>(info.This())) {
        return;
      }

      SceneModeControl *wrapper = SceneModeControl::Unwrap<SceneModeControl>(info.This());

      try  {
        ::Windows::Media::Devices::CaptureSceneMode result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::SceneModeControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapSceneModeControl(::Windows::Media::Devices::SceneModeControl^ wintRtInstance);
      friend ::Windows::Media::Devices::SceneModeControl^ UnwrapSceneModeControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> SceneModeControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapSceneModeControl(::Windows::Media::Devices::SceneModeControl^ 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>(SceneModeControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::SceneModeControl^ UnwrapSceneModeControl(Local<Value> value) {
     return SceneModeControl::Unwrap<SceneModeControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSceneModeControl(Local<Object> exports) {
    SceneModeControl::Init(exports);
  }

  class TorchControl : 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>("TorchControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("powerPercent").ToLocalChecked(), PowerPercentGetter, PowerPercentSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("enabled").ToLocalChecked(), EnabledGetter, EnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("powerSupported").ToLocalChecked(), PowerSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("TorchControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      TorchControl(::Windows::Media::Devices::TorchControl^ 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::Media::Devices::TorchControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::TorchControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::TorchControl^) 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());

      TorchControl *wrapperInstance = new TorchControl(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::Media::Devices::TorchControl^>(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::Media::Devices::TorchControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::TorchControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapTorchControl(winRtInstance));
    }





    static void PowerPercentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::TorchControl^>(info.This())) {
        return;
      }

      TorchControl *wrapper = TorchControl::Unwrap<TorchControl>(info.This());

      try  {
        float result = wrapper->_instance->PowerPercent;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PowerPercentSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsNumber()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::TorchControl^>(info.This())) {
        return;
      }

      TorchControl *wrapper = TorchControl::Unwrap<TorchControl>(info.This());

      try {

        float winRtValue = static_cast<float>(Nan::To<double>(value).FromMaybe(0.0));

        wrapper->_instance->PowerPercent = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void EnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::TorchControl^>(info.This())) {
        return;
      }

      TorchControl *wrapper = TorchControl::Unwrap<TorchControl>(info.This());

      try  {
        bool result = wrapper->_instance->Enabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EnabledSetter(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::Media::Devices::TorchControl^>(info.This())) {
        return;
      }

      TorchControl *wrapper = TorchControl::Unwrap<TorchControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->Enabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void PowerSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::TorchControl^>(info.This())) {
        return;
      }

      TorchControl *wrapper = TorchControl::Unwrap<TorchControl>(info.This());

      try  {
        bool result = wrapper->_instance->PowerSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::TorchControl^>(info.This())) {
        return;
      }

      TorchControl *wrapper = TorchControl::Unwrap<TorchControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::TorchControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapTorchControl(::Windows::Media::Devices::TorchControl^ wintRtInstance);
      friend ::Windows::Media::Devices::TorchControl^ UnwrapTorchControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> TorchControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapTorchControl(::Windows::Media::Devices::TorchControl^ 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>(TorchControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::TorchControl^ UnwrapTorchControl(Local<Value> value) {
     return TorchControl::Unwrap<TorchControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitTorchControl(Local<Object> exports) {
    TorchControl::Init(exports);
  }

  class FlashControl : 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>("FlashControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("redEyeReduction").ToLocalChecked(), RedEyeReductionGetter, RedEyeReductionSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("powerPercent").ToLocalChecked(), PowerPercentGetter, PowerPercentSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("enabled").ToLocalChecked(), EnabledGetter, EnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("auto").ToLocalChecked(), AutoGetter, AutoSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("powerSupported").ToLocalChecked(), PowerSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("redEyeReductionSupported").ToLocalChecked(), RedEyeReductionSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("assistantLightEnabled").ToLocalChecked(), AssistantLightEnabledGetter, AssistantLightEnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("assistantLightSupported").ToLocalChecked(), AssistantLightSupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("FlashControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      FlashControl(::Windows::Media::Devices::FlashControl^ 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::Media::Devices::FlashControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::FlashControl^) 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());

      FlashControl *wrapperInstance = new FlashControl(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::Media::Devices::FlashControl^>(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::Media::Devices::FlashControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::FlashControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapFlashControl(winRtInstance));
    }





    static void RedEyeReductionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->RedEyeReduction;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RedEyeReductionSetter(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::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->RedEyeReduction = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void PowerPercentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        float result = wrapper->_instance->PowerPercent;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PowerPercentSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsNumber()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try {

        float winRtValue = static_cast<float>(Nan::To<double>(value).FromMaybe(0.0));

        wrapper->_instance->PowerPercent = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void EnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->Enabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EnabledSetter(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::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->Enabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AutoGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->Auto;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoSetter(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::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->Auto = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void PowerSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->PowerSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RedEyeReductionSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->RedEyeReductionSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AssistantLightEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->AssistantLightEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AssistantLightEnabledSetter(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::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AssistantLightEnabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AssistantLightSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FlashControl^>(info.This())) {
        return;
      }

      FlashControl *wrapper = FlashControl::Unwrap<FlashControl>(info.This());

      try  {
        bool result = wrapper->_instance->AssistantLightSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::FlashControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapFlashControl(::Windows::Media::Devices::FlashControl^ wintRtInstance);
      friend ::Windows::Media::Devices::FlashControl^ UnwrapFlashControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> FlashControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapFlashControl(::Windows::Media::Devices::FlashControl^ 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>(FlashControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::FlashControl^ UnwrapFlashControl(Local<Value> value) {
     return FlashControl::Unwrap<FlashControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFlashControl(Local<Object> exports) {
    FlashControl::Init(exports);
  }

  class ExposureCompensationControl : 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>("ExposureCompensationControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "setValueAsync", SetValueAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("max").ToLocalChecked(), MaxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("min").ToLocalChecked(), MinGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("step").ToLocalChecked(), StepGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ExposureCompensationControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ExposureCompensationControl(::Windows::Media::Devices::ExposureCompensationControl^ 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::Media::Devices::ExposureCompensationControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureCompensationControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::ExposureCompensationControl^) 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());

      ExposureCompensationControl *wrapperInstance = new ExposureCompensationControl(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::Media::Devices::ExposureCompensationControl^>(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::Media::Devices::ExposureCompensationControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::ExposureCompensationControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapExposureCompensationControl(winRtInstance));
    }

    static void SetValueAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureCompensationControl^>(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;
      }

      ExposureCompensationControl *wrapper = ExposureCompensationControl::Unwrap<ExposureCompensationControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsNumber())
      {
        try
        {
          float arg0 = static_cast<float>(Nan::To<double>(info[0]).FromMaybe(0.0));
          
          op = wrapper->_instance->SetValueAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 MaxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureCompensationControl^>(info.This())) {
        return;
      }

      ExposureCompensationControl *wrapper = ExposureCompensationControl::Unwrap<ExposureCompensationControl>(info.This());

      try  {
        float result = wrapper->_instance->Max;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureCompensationControl^>(info.This())) {
        return;
      }

      ExposureCompensationControl *wrapper = ExposureCompensationControl::Unwrap<ExposureCompensationControl>(info.This());

      try  {
        float result = wrapper->_instance->Min;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StepGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureCompensationControl^>(info.This())) {
        return;
      }

      ExposureCompensationControl *wrapper = ExposureCompensationControl::Unwrap<ExposureCompensationControl>(info.This());

      try  {
        float result = wrapper->_instance->Step;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureCompensationControl^>(info.This())) {
        return;
      }

      ExposureCompensationControl *wrapper = ExposureCompensationControl::Unwrap<ExposureCompensationControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureCompensationControl^>(info.This())) {
        return;
      }

      ExposureCompensationControl *wrapper = ExposureCompensationControl::Unwrap<ExposureCompensationControl>(info.This());

      try  {
        float result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::ExposureCompensationControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapExposureCompensationControl(::Windows::Media::Devices::ExposureCompensationControl^ wintRtInstance);
      friend ::Windows::Media::Devices::ExposureCompensationControl^ UnwrapExposureCompensationControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> ExposureCompensationControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapExposureCompensationControl(::Windows::Media::Devices::ExposureCompensationControl^ 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>(ExposureCompensationControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::ExposureCompensationControl^ UnwrapExposureCompensationControl(Local<Value> value) {
     return ExposureCompensationControl::Unwrap<ExposureCompensationControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitExposureCompensationControl(Local<Object> exports) {
    ExposureCompensationControl::Init(exports);
  }

  class IsoSpeedControl : 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>("IsoSpeedControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "setPresetAsync", SetPresetAsync);
            Nan::SetPrototypeMethod(localRef, "setValueAsync", SetValueAsync);
            Nan::SetPrototypeMethod(localRef, "setAutoAsync", SetAutoAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("preset").ToLocalChecked(), PresetGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedPresets").ToLocalChecked(), SupportedPresetsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("auto").ToLocalChecked(), AutoGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("max").ToLocalChecked(), MaxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("min").ToLocalChecked(), MinGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("step").ToLocalChecked(), StepGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("IsoSpeedControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      IsoSpeedControl(::Windows::Media::Devices::IsoSpeedControl^ 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::Media::Devices::IsoSpeedControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::IsoSpeedControl^) 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());

      IsoSpeedControl *wrapperInstance = new IsoSpeedControl(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::Media::Devices::IsoSpeedControl^>(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::Media::Devices::IsoSpeedControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::IsoSpeedControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapIsoSpeedControl(winRtInstance));
    }

    static void SetPresetAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(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;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Devices::IsoSpeedPreset arg0 = static_cast<::Windows::Media::Devices::IsoSpeedPreset>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetPresetAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 SetValueAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(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;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsUint32())
      {
        try
        {
          unsigned int arg0 = static_cast<unsigned int>(Nan::To<uint32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetValueAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 SetAutoAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(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;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->SetAutoAsync();
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 PresetGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        ::Windows::Media::Devices::IsoSpeedPreset result = wrapper->_instance->Preset;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedPresetsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::IsoSpeedPreset>^ result = wrapper->_instance->SupportedPresets;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::IsoSpeedPreset>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::IsoSpeedPreset val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::IsoSpeedPreset {
              return static_cast<::Windows::Media::Devices::IsoSpeedPreset>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        bool result = wrapper->_instance->Auto;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MaxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Max;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Min;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StepGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Step;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IsoSpeedControl^>(info.This())) {
        return;
      }

      IsoSpeedControl *wrapper = IsoSpeedControl::Unwrap<IsoSpeedControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::IsoSpeedControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapIsoSpeedControl(::Windows::Media::Devices::IsoSpeedControl^ wintRtInstance);
      friend ::Windows::Media::Devices::IsoSpeedControl^ UnwrapIsoSpeedControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> IsoSpeedControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapIsoSpeedControl(::Windows::Media::Devices::IsoSpeedControl^ 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>(IsoSpeedControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::IsoSpeedControl^ UnwrapIsoSpeedControl(Local<Value> value) {
     return IsoSpeedControl::Unwrap<IsoSpeedControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitIsoSpeedControl(Local<Object> exports) {
    IsoSpeedControl::Init(exports);
  }

  class WhiteBalanceControl : 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>("WhiteBalanceControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "setPresetAsync", SetPresetAsync);
            Nan::SetPrototypeMethod(localRef, "setValueAsync", SetValueAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("max").ToLocalChecked(), MaxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("min").ToLocalChecked(), MinGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("preset").ToLocalChecked(), PresetGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("step").ToLocalChecked(), StepGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("WhiteBalanceControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      WhiteBalanceControl(::Windows::Media::Devices::WhiteBalanceControl^ 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::Media::Devices::WhiteBalanceControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::WhiteBalanceControl^) 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());

      WhiteBalanceControl *wrapperInstance = new WhiteBalanceControl(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::Media::Devices::WhiteBalanceControl^>(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::Media::Devices::WhiteBalanceControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::WhiteBalanceControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapWhiteBalanceControl(winRtInstance));
    }

    static void SetPresetAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(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;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Devices::ColorTemperaturePreset arg0 = static_cast<::Windows::Media::Devices::ColorTemperaturePreset>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetPresetAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 SetValueAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(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;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsUint32())
      {
        try
        {
          unsigned int arg0 = static_cast<unsigned int>(Nan::To<uint32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetValueAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 MaxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(info.This())) {
        return;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Max;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(info.This())) {
        return;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Min;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PresetGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(info.This())) {
        return;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      try  {
        ::Windows::Media::Devices::ColorTemperaturePreset result = wrapper->_instance->Preset;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StepGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(info.This())) {
        return;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Step;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(info.This())) {
        return;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::WhiteBalanceControl^>(info.This())) {
        return;
      }

      WhiteBalanceControl *wrapper = WhiteBalanceControl::Unwrap<WhiteBalanceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::WhiteBalanceControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapWhiteBalanceControl(::Windows::Media::Devices::WhiteBalanceControl^ wintRtInstance);
      friend ::Windows::Media::Devices::WhiteBalanceControl^ UnwrapWhiteBalanceControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> WhiteBalanceControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapWhiteBalanceControl(::Windows::Media::Devices::WhiteBalanceControl^ 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>(WhiteBalanceControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::WhiteBalanceControl^ UnwrapWhiteBalanceControl(Local<Value> value) {
     return WhiteBalanceControl::Unwrap<WhiteBalanceControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitWhiteBalanceControl(Local<Object> exports) {
    WhiteBalanceControl::Init(exports);
  }

  class ExposureControl : 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>("ExposureControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "setAutoAsync", SetAutoAsync);
            Nan::SetPrototypeMethod(localRef, "setValueAsync", SetValueAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("auto").ToLocalChecked(), AutoGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("max").ToLocalChecked(), MaxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("min").ToLocalChecked(), MinGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("step").ToLocalChecked(), StepGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ExposureControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ExposureControl(::Windows::Media::Devices::ExposureControl^ 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::Media::Devices::ExposureControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::ExposureControl^) 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());

      ExposureControl *wrapperInstance = new ExposureControl(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::Media::Devices::ExposureControl^>(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::Media::Devices::ExposureControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::ExposureControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapExposureControl(winRtInstance));
    }

    static void SetAutoAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(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;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsBoolean())
      {
        try
        {
          bool arg0 = Nan::To<bool>(info[0]).FromMaybe(false);
          
          op = wrapper->_instance->SetAutoAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 SetValueAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(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;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsNumber())
      {
        try
        {
          ::Windows::Foundation::TimeSpan arg0 = NodeRT::Utils::TimeSpanFromMilli(Nan::To<int64_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetValueAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 AutoGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(info.This())) {
        return;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      try  {
        bool result = wrapper->_instance->Auto;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MaxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(info.This())) {
        return;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->Max;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(info.This())) {
        return;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->Min;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StepGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(info.This())) {
        return;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->Step;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(info.This())) {
        return;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposureControl^>(info.This())) {
        return;
      }

      ExposureControl *wrapper = ExposureControl::Unwrap<ExposureControl>(info.This());

      try  {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::ExposureControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapExposureControl(::Windows::Media::Devices::ExposureControl^ wintRtInstance);
      friend ::Windows::Media::Devices::ExposureControl^ UnwrapExposureControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> ExposureControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapExposureControl(::Windows::Media::Devices::ExposureControl^ 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>(ExposureControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::ExposureControl^ UnwrapExposureControl(Local<Value> value) {
     return ExposureControl::Unwrap<ExposureControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitExposureControl(Local<Object> exports) {
    ExposureControl::Init(exports);
  }

  class ZoomSettings : 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>("ZoomSettings").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter, ValueSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter, ModeSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ZoomSettings").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ZoomSettings(::Windows::Media::Devices::ZoomSettings^ 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::Media::Devices::ZoomSettings^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomSettings^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::ZoomSettings^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Media::Devices::ZoomSettings();
        } 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());

      ZoomSettings *wrapperInstance = new ZoomSettings(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::Media::Devices::ZoomSettings^>(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::Media::Devices::ZoomSettings^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::ZoomSettings^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapZoomSettings(winRtInstance));
    }





    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomSettings^>(info.This())) {
        return;
      }

      ZoomSettings *wrapper = ZoomSettings::Unwrap<ZoomSettings>(info.This());

      try  {
        float result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsNumber()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomSettings^>(info.This())) {
        return;
      }

      ZoomSettings *wrapper = ZoomSettings::Unwrap<ZoomSettings>(info.This());

      try {

        float winRtValue = static_cast<float>(Nan::To<double>(value).FromMaybe(0.0));

        wrapper->_instance->Value = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomSettings^>(info.This())) {
        return;
      }

      ZoomSettings *wrapper = ZoomSettings::Unwrap<ZoomSettings>(info.This());

      try  {
        ::Windows::Media::Devices::ZoomTransitionMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModeSetter(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::Media::Devices::ZoomSettings^>(info.This())) {
        return;
      }

      ZoomSettings *wrapper = ZoomSettings::Unwrap<ZoomSettings>(info.This());

      try {

        ::Windows::Media::Devices::ZoomTransitionMode winRtValue = static_cast<::Windows::Media::Devices::ZoomTransitionMode>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Mode = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Media::Devices::ZoomSettings^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapZoomSettings(::Windows::Media::Devices::ZoomSettings^ wintRtInstance);
      friend ::Windows::Media::Devices::ZoomSettings^ UnwrapZoomSettings(Local<Value> value);
  };

  Persistent<FunctionTemplate> ZoomSettings::s_constructorTemplate;

  v8::Local<v8::Value> WrapZoomSettings(::Windows::Media::Devices::ZoomSettings^ 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>(ZoomSettings::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::ZoomSettings^ UnwrapZoomSettings(Local<Value> value) {
     return ZoomSettings::Unwrap<ZoomSettings>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitZoomSettings(Local<Object> exports) {
    ZoomSettings::Init(exports);
  }

  class ZoomControl : 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>("ZoomControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "configure", Configure);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter, ValueSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("max").ToLocalChecked(), MaxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("min").ToLocalChecked(), MinGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("step").ToLocalChecked(), StepGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedModes").ToLocalChecked(), SupportedModesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ZoomControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ZoomControl(::Windows::Media::Devices::ZoomControl^ 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::Media::Devices::ZoomControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::ZoomControl^) 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());

      ZoomControl *wrapperInstance = new ZoomControl(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::Media::Devices::ZoomControl^>(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::Media::Devices::ZoomControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::ZoomControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapZoomControl(winRtInstance));
    }


    static void Configure(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomSettings^>(info[0]))
      {
        try
        {
          ::Windows::Media::Devices::ZoomSettings^ arg0 = UnwrapZoomSettings(info[0]);
          
          wrapper->_instance->Configure(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 ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try  {
        float result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsNumber()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try {

        float winRtValue = static_cast<float>(Nan::To<double>(value).FromMaybe(0.0));

        wrapper->_instance->Value = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void MaxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try  {
        float result = wrapper->_instance->Max;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try  {
        float result = wrapper->_instance->Min;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StepGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try  {
        float result = wrapper->_instance->Step;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try  {
        ::Windows::Media::Devices::ZoomTransitionMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedModesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ZoomControl^>(info.This())) {
        return;
      }

      ZoomControl *wrapper = ZoomControl::Unwrap<ZoomControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::ZoomTransitionMode>^ result = wrapper->_instance->SupportedModes;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::ZoomTransitionMode>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::ZoomTransitionMode val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::ZoomTransitionMode {
              return static_cast<::Windows::Media::Devices::ZoomTransitionMode>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::ZoomControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapZoomControl(::Windows::Media::Devices::ZoomControl^ wintRtInstance);
      friend ::Windows::Media::Devices::ZoomControl^ UnwrapZoomControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> ZoomControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapZoomControl(::Windows::Media::Devices::ZoomControl^ 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>(ZoomControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::ZoomControl^ UnwrapZoomControl(Local<Value> value) {
     return ZoomControl::Unwrap<ZoomControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitZoomControl(Local<Object> exports) {
    ZoomControl::Init(exports);
  }

  class FocusSettings : 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>("FocusSettings").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("waitForFocus").ToLocalChecked(), WaitForFocusGetter, WaitForFocusSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter, ValueSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter, ModeSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("distance").ToLocalChecked(), DistanceGetter, DistanceSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("disableDriverFallback").ToLocalChecked(), DisableDriverFallbackGetter, DisableDriverFallbackSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoFocusRange").ToLocalChecked(), AutoFocusRangeGetter, AutoFocusRangeSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("FocusSettings").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      FocusSettings(::Windows::Media::Devices::FocusSettings^ 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::Media::Devices::FocusSettings^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::FocusSettings^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Media::Devices::FocusSettings();
        } 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());

      FocusSettings *wrapperInstance = new FocusSettings(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::Media::Devices::FocusSettings^>(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::Media::Devices::FocusSettings^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::FocusSettings^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapFocusSettings(winRtInstance));
    }





    static void WaitForFocusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try  {
        bool result = wrapper->_instance->WaitForFocus;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void WaitForFocusSetter(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::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->WaitForFocus = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try  {
        ::Platform::IBox<unsigned int>^ result = wrapper->_instance->Value;
        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 ValueSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsUint32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try {

        ::Platform::IBox<unsigned int>^ winRtValue = ref new ::Platform::Box<unsigned int>(static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0)));

        wrapper->_instance->Value = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try  {
        ::Windows::Media::Devices::FocusMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModeSetter(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::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try {

        ::Windows::Media::Devices::FocusMode winRtValue = static_cast<::Windows::Media::Devices::FocusMode>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Mode = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DistanceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try  {
        ::Platform::IBox<::Windows::Media::Devices::ManualFocusDistance>^ result = wrapper->_instance->Distance;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Integer>(static_cast<int>(result->Value))) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DistanceSetter(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::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try {

        ::Platform::IBox<::Windows::Media::Devices::ManualFocusDistance>^ winRtValue = ref new ::Platform::Box<::Windows::Media::Devices::ManualFocusDistance>(static_cast<::Windows::Media::Devices::ManualFocusDistance>(Nan::To<int32_t>(value).FromMaybe(0)));

        wrapper->_instance->Distance = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DisableDriverFallbackGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try  {
        bool result = wrapper->_instance->DisableDriverFallback;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DisableDriverFallbackSetter(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::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->DisableDriverFallback = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AutoFocusRangeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try  {
        ::Windows::Media::Devices::AutoFocusRange result = wrapper->_instance->AutoFocusRange;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoFocusRangeSetter(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::Media::Devices::FocusSettings^>(info.This())) {
        return;
      }

      FocusSettings *wrapper = FocusSettings::Unwrap<FocusSettings>(info.This());

      try {

        ::Windows::Media::Devices::AutoFocusRange winRtValue = static_cast<::Windows::Media::Devices::AutoFocusRange>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->AutoFocusRange = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Media::Devices::FocusSettings^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapFocusSettings(::Windows::Media::Devices::FocusSettings^ wintRtInstance);
      friend ::Windows::Media::Devices::FocusSettings^ UnwrapFocusSettings(Local<Value> value);
  };

  Persistent<FunctionTemplate> FocusSettings::s_constructorTemplate;

  v8::Local<v8::Value> WrapFocusSettings(::Windows::Media::Devices::FocusSettings^ 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>(FocusSettings::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::FocusSettings^ UnwrapFocusSettings(Local<Value> value) {
     return FocusSettings::Unwrap<FocusSettings>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFocusSettings(Local<Object> exports) {
    FocusSettings::Init(exports);
  }

  class FocusControl : 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>("FocusControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "configure", Configure);
          

          
            Nan::SetPrototypeMethod(localRef, "setPresetAsync", SetPresetAsync);
            Nan::SetPrototypeMethod(localRef, "setValueAsync", SetValueAsync);
            Nan::SetPrototypeMethod(localRef, "focusAsync", FocusAsync);
            Nan::SetPrototypeMethod(localRef, "unlockAsync", UnlockAsync);
            Nan::SetPrototypeMethod(localRef, "lockAsync", LockAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("max").ToLocalChecked(), MaxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("min").ToLocalChecked(), MinGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("preset").ToLocalChecked(), PresetGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("step").ToLocalChecked(), StepGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedPresets").ToLocalChecked(), SupportedPresetsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("focusChangedSupported").ToLocalChecked(), FocusChangedSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("focusState").ToLocalChecked(), FocusStateGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedFocusDistances").ToLocalChecked(), SupportedFocusDistancesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedFocusModes").ToLocalChecked(), SupportedFocusModesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedFocusRanges").ToLocalChecked(), SupportedFocusRangesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("waitForFocusSupported").ToLocalChecked(), WaitForFocusSupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("FocusControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      FocusControl(::Windows::Media::Devices::FocusControl^ 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::Media::Devices::FocusControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::FocusControl^) 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());

      FocusControl *wrapperInstance = new FocusControl(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::Media::Devices::FocusControl^>(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::Media::Devices::FocusControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::FocusControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapFocusControl(winRtInstance));
    }

    static void SetPresetAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(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;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Devices::FocusPreset arg0 = static_cast<::Windows::Media::Devices::FocusPreset>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetPresetAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 3
        && info[0]->IsInt32()
        && info[1]->IsBoolean())
      {
        try
        {
          ::Windows::Media::Devices::FocusPreset arg0 = static_cast<::Windows::Media::Devices::FocusPreset>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          bool arg1 = Nan::To<bool>(info[1]).FromMaybe(false);
          
          op = wrapper->_instance->SetPresetAsync(arg0,arg1);
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 SetValueAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(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;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && info[0]->IsUint32())
      {
        try
        {
          unsigned int arg0 = static_cast<unsigned int>(Nan::To<uint32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->SetValueAsync(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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 FocusAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(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;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->FocusAsync();
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 UnlockAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(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;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->UnlockAsync();
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 LockAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(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;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->LockAsync();
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 Configure(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusSettings^>(info[0]))
      {
        try
        {
          ::Windows::Media::Devices::FocusSettings^ arg0 = UnwrapFocusSettings(info[0]);
          
          wrapper->_instance->Configure(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 MaxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Max;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Min;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PresetGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        ::Windows::Media::Devices::FocusPreset result = wrapper->_instance->Preset;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StepGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Step;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedPresetsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::FocusPreset>^ result = wrapper->_instance->SupportedPresets;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::FocusPreset>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::FocusPreset val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::FocusPreset {
              return static_cast<::Windows::Media::Devices::FocusPreset>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Value;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void FocusChangedSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        bool result = wrapper->_instance->FocusChangedSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void FocusStateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        ::Windows::Media::Devices::MediaCaptureFocusState result = wrapper->_instance->FocusState;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        ::Windows::Media::Devices::FocusMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedFocusDistancesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::ManualFocusDistance>^ result = wrapper->_instance->SupportedFocusDistances;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::ManualFocusDistance>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::ManualFocusDistance val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::ManualFocusDistance {
              return static_cast<::Windows::Media::Devices::ManualFocusDistance>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedFocusModesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::FocusMode>^ result = wrapper->_instance->SupportedFocusModes;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::FocusMode>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::FocusMode val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::FocusMode {
              return static_cast<::Windows::Media::Devices::FocusMode>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedFocusRangesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::AutoFocusRange>^ result = wrapper->_instance->SupportedFocusRanges;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::AutoFocusRange>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::AutoFocusRange val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::AutoFocusRange {
              return static_cast<::Windows::Media::Devices::AutoFocusRange>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void WaitForFocusSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::FocusControl^>(info.This())) {
        return;
      }

      FocusControl *wrapper = FocusControl::Unwrap<FocusControl>(info.This());

      try  {
        bool result = wrapper->_instance->WaitForFocusSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::FocusControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapFocusControl(::Windows::Media::Devices::FocusControl^ wintRtInstance);
      friend ::Windows::Media::Devices::FocusControl^ UnwrapFocusControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> FocusControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapFocusControl(::Windows::Media::Devices::FocusControl^ 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>(FocusControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::FocusControl^ UnwrapFocusControl(Local<Value> value) {
     return FocusControl::Unwrap<FocusControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFocusControl(Local<Object> exports) {
    FocusControl::Init(exports);
  }

  class RegionOfInterest : 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>("RegionOfInterest").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("bounds").ToLocalChecked(), BoundsGetter, BoundsSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoWhiteBalanceEnabled").ToLocalChecked(), AutoWhiteBalanceEnabledGetter, AutoWhiteBalanceEnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoFocusEnabled").ToLocalChecked(), AutoFocusEnabledGetter, AutoFocusEnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoExposureEnabled").ToLocalChecked(), AutoExposureEnabledGetter, AutoExposureEnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("weight").ToLocalChecked(), WeightGetter, WeightSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("type").ToLocalChecked(), TypeGetter, TypeSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("boundsNormalized").ToLocalChecked(), BoundsNormalizedGetter, BoundsNormalizedSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("RegionOfInterest").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      RegionOfInterest(::Windows::Media::Devices::RegionOfInterest^ 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::Media::Devices::RegionOfInterest^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::RegionOfInterest^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Media::Devices::RegionOfInterest();
        } 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());

      RegionOfInterest *wrapperInstance = new RegionOfInterest(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::Media::Devices::RegionOfInterest^>(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::Media::Devices::RegionOfInterest^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::RegionOfInterest^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapRegionOfInterest(winRtInstance));
    }





    static void BoundsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try  {
        ::Windows::Foundation::Rect result = wrapper->_instance->Bounds;
        info.GetReturnValue().Set(NodeRT::Utils::RectToJs(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void BoundsSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsRect(value)) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try {

        ::Windows::Foundation::Rect winRtValue = NodeRT::Utils::RectFromJs(value);

        wrapper->_instance->Bounds = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AutoWhiteBalanceEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try  {
        bool result = wrapper->_instance->AutoWhiteBalanceEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoWhiteBalanceEnabledSetter(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::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AutoWhiteBalanceEnabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AutoFocusEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try  {
        bool result = wrapper->_instance->AutoFocusEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoFocusEnabledSetter(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::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AutoFocusEnabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AutoExposureEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try  {
        bool result = wrapper->_instance->AutoExposureEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoExposureEnabledSetter(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::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AutoExposureEnabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void WeightGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try  {
        unsigned int result = wrapper->_instance->Weight;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void WeightSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsUint32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try {

        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->Weight = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void TypeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try  {
        ::Windows::Media::Devices::RegionOfInterestType result = wrapper->_instance->Type;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TypeSetter(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::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try {

        ::Windows::Media::Devices::RegionOfInterestType winRtValue = static_cast<::Windows::Media::Devices::RegionOfInterestType>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Type = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void BoundsNormalizedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try  {
        bool result = wrapper->_instance->BoundsNormalized;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void BoundsNormalizedSetter(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::Media::Devices::RegionOfInterest^>(info.This())) {
        return;
      }

      RegionOfInterest *wrapper = RegionOfInterest::Unwrap<RegionOfInterest>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->BoundsNormalized = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Media::Devices::RegionOfInterest^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapRegionOfInterest(::Windows::Media::Devices::RegionOfInterest^ wintRtInstance);
      friend ::Windows::Media::Devices::RegionOfInterest^ UnwrapRegionOfInterest(Local<Value> value);
  };

  Persistent<FunctionTemplate> RegionOfInterest::s_constructorTemplate;

  v8::Local<v8::Value> WrapRegionOfInterest(::Windows::Media::Devices::RegionOfInterest^ 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>(RegionOfInterest::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::RegionOfInterest^ UnwrapRegionOfInterest(Local<Value> value) {
     return RegionOfInterest::Unwrap<RegionOfInterest>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitRegionOfInterest(Local<Object> exports) {
    RegionOfInterest::Init(exports);
  }

  class RegionsOfInterestControl : 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>("RegionsOfInterestControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "setRegionsAsync", SetRegionsAsync);
            Nan::SetPrototypeMethod(localRef, "clearRegionsAsync", ClearRegionsAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoExposureSupported").ToLocalChecked(), AutoExposureSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoFocusSupported").ToLocalChecked(), AutoFocusSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoWhiteBalanceSupported").ToLocalChecked(), AutoWhiteBalanceSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("maxRegions").ToLocalChecked(), MaxRegionsGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("RegionsOfInterestControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      RegionsOfInterestControl(::Windows::Media::Devices::RegionsOfInterestControl^ 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::Media::Devices::RegionsOfInterestControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionsOfInterestControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::RegionsOfInterestControl^) 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());

      RegionsOfInterestControl *wrapperInstance = new RegionsOfInterestControl(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::Media::Devices::RegionsOfInterestControl^>(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::Media::Devices::RegionsOfInterestControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::RegionsOfInterestControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapRegionsOfInterestControl(winRtInstance));
    }

    static void SetRegionsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionsOfInterestControl^>(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;
      }

      RegionsOfInterestControl *wrapper = RegionsOfInterestControl::Unwrap<RegionsOfInterestControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 2
        && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^>(info[0]) || info[0]->IsArray()))
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Media::Devices::RegionOfInterest^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Media::Devices::RegionOfInterest^ {
                   return UnwrapRegionOfInterest(value);
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          
          op = wrapper->_instance->SetRegionsAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 3
        && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^>(info[0]) || info[0]->IsArray())
        && info[1]->IsBoolean())
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Media::Devices::RegionOfInterest^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionOfInterest^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Media::Devices::RegionOfInterest^ {
                   return UnwrapRegionOfInterest(value);
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Media::Devices::RegionOfInterest^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          bool arg1 = Nan::To<bool>(info[1]).FromMaybe(false);
          
          op = wrapper->_instance->SetRegionsAsync(arg0,arg1);
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 ClearRegionsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionsOfInterestControl^>(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;
      }

      RegionsOfInterestControl *wrapper = RegionsOfInterestControl::Unwrap<RegionsOfInterestControl>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->ClearRegionsAsync();
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 AutoExposureSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionsOfInterestControl^>(info.This())) {
        return;
      }

      RegionsOfInterestControl *wrapper = RegionsOfInterestControl::Unwrap<RegionsOfInterestControl>(info.This());

      try  {
        bool result = wrapper->_instance->AutoExposureSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoFocusSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionsOfInterestControl^>(info.This())) {
        return;
      }

      RegionsOfInterestControl *wrapper = RegionsOfInterestControl::Unwrap<RegionsOfInterestControl>(info.This());

      try  {
        bool result = wrapper->_instance->AutoFocusSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AutoWhiteBalanceSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionsOfInterestControl^>(info.This())) {
        return;
      }

      RegionsOfInterestControl *wrapper = RegionsOfInterestControl::Unwrap<RegionsOfInterestControl>(info.This());

      try  {
        bool result = wrapper->_instance->AutoWhiteBalanceSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MaxRegionsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RegionsOfInterestControl^>(info.This())) {
        return;
      }

      RegionsOfInterestControl *wrapper = RegionsOfInterestControl::Unwrap<RegionsOfInterestControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->MaxRegions;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::RegionsOfInterestControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapRegionsOfInterestControl(::Windows::Media::Devices::RegionsOfInterestControl^ wintRtInstance);
      friend ::Windows::Media::Devices::RegionsOfInterestControl^ UnwrapRegionsOfInterestControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> RegionsOfInterestControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapRegionsOfInterestControl(::Windows::Media::Devices::RegionsOfInterestControl^ 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>(RegionsOfInterestControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::RegionsOfInterestControl^ UnwrapRegionsOfInterestControl(Local<Value> value) {
     return RegionsOfInterestControl::Unwrap<RegionsOfInterestControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitRegionsOfInterestControl(Local<Object> exports) {
    RegionsOfInterestControl::Init(exports);
  }

  class ExposurePriorityVideoControl : 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>("ExposurePriorityVideoControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("enabled").ToLocalChecked(), EnabledGetter, EnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ExposurePriorityVideoControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ExposurePriorityVideoControl(::Windows::Media::Devices::ExposurePriorityVideoControl^ 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::Media::Devices::ExposurePriorityVideoControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposurePriorityVideoControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::ExposurePriorityVideoControl^) 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());

      ExposurePriorityVideoControl *wrapperInstance = new ExposurePriorityVideoControl(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::Media::Devices::ExposurePriorityVideoControl^>(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::Media::Devices::ExposurePriorityVideoControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::ExposurePriorityVideoControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapExposurePriorityVideoControl(winRtInstance));
    }





    static void EnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposurePriorityVideoControl^>(info.This())) {
        return;
      }

      ExposurePriorityVideoControl *wrapper = ExposurePriorityVideoControl::Unwrap<ExposurePriorityVideoControl>(info.This());

      try  {
        bool result = wrapper->_instance->Enabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EnabledSetter(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::Media::Devices::ExposurePriorityVideoControl^>(info.This())) {
        return;
      }

      ExposurePriorityVideoControl *wrapper = ExposurePriorityVideoControl::Unwrap<ExposurePriorityVideoControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->Enabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::ExposurePriorityVideoControl^>(info.This())) {
        return;
      }

      ExposurePriorityVideoControl *wrapper = ExposurePriorityVideoControl::Unwrap<ExposurePriorityVideoControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::ExposurePriorityVideoControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapExposurePriorityVideoControl(::Windows::Media::Devices::ExposurePriorityVideoControl^ wintRtInstance);
      friend ::Windows::Media::Devices::ExposurePriorityVideoControl^ UnwrapExposurePriorityVideoControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> ExposurePriorityVideoControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapExposurePriorityVideoControl(::Windows::Media::Devices::ExposurePriorityVideoControl^ 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>(ExposurePriorityVideoControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::ExposurePriorityVideoControl^ UnwrapExposurePriorityVideoControl(Local<Value> value) {
     return ExposurePriorityVideoControl::Unwrap<ExposurePriorityVideoControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitExposurePriorityVideoControl(Local<Object> exports) {
    ExposurePriorityVideoControl::Init(exports);
  }

  class HdrVideoControl : 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>("HdrVideoControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter, ModeSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedModes").ToLocalChecked(), SupportedModesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("HdrVideoControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      HdrVideoControl(::Windows::Media::Devices::HdrVideoControl^ 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::Media::Devices::HdrVideoControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::HdrVideoControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::HdrVideoControl^) 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());

      HdrVideoControl *wrapperInstance = new HdrVideoControl(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::Media::Devices::HdrVideoControl^>(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::Media::Devices::HdrVideoControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::HdrVideoControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapHdrVideoControl(winRtInstance));
    }





    static void ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::HdrVideoControl^>(info.This())) {
        return;
      }

      HdrVideoControl *wrapper = HdrVideoControl::Unwrap<HdrVideoControl>(info.This());

      try  {
        ::Windows::Media::Devices::HdrVideoMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModeSetter(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::Media::Devices::HdrVideoControl^>(info.This())) {
        return;
      }

      HdrVideoControl *wrapper = HdrVideoControl::Unwrap<HdrVideoControl>(info.This());

      try {

        ::Windows::Media::Devices::HdrVideoMode winRtValue = static_cast<::Windows::Media::Devices::HdrVideoMode>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Mode = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::HdrVideoControl^>(info.This())) {
        return;
      }

      HdrVideoControl *wrapper = HdrVideoControl::Unwrap<HdrVideoControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedModesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::HdrVideoControl^>(info.This())) {
        return;
      }

      HdrVideoControl *wrapper = HdrVideoControl::Unwrap<HdrVideoControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::HdrVideoMode>^ result = wrapper->_instance->SupportedModes;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::HdrVideoMode>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::HdrVideoMode val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::HdrVideoMode {
              return static_cast<::Windows::Media::Devices::HdrVideoMode>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::HdrVideoControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapHdrVideoControl(::Windows::Media::Devices::HdrVideoControl^ wintRtInstance);
      friend ::Windows::Media::Devices::HdrVideoControl^ UnwrapHdrVideoControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> HdrVideoControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapHdrVideoControl(::Windows::Media::Devices::HdrVideoControl^ 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>(HdrVideoControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::HdrVideoControl^ UnwrapHdrVideoControl(Local<Value> value) {
     return HdrVideoControl::Unwrap<HdrVideoControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitHdrVideoControl(Local<Object> exports) {
    HdrVideoControl::Init(exports);
  }

  class AdvancedPhotoCaptureSettings : 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>("AdvancedPhotoCaptureSettings").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter, ModeSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("AdvancedPhotoCaptureSettings").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      AdvancedPhotoCaptureSettings(::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ 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::Media::Devices::AdvancedPhotoCaptureSettings^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoCaptureSettings^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::AdvancedPhotoCaptureSettings^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try {
          winRtInstance = ref new ::Windows::Media::Devices::AdvancedPhotoCaptureSettings();
        } 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());

      AdvancedPhotoCaptureSettings *wrapperInstance = new AdvancedPhotoCaptureSettings(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::Media::Devices::AdvancedPhotoCaptureSettings^>(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::Media::Devices::AdvancedPhotoCaptureSettings^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::AdvancedPhotoCaptureSettings^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapAdvancedPhotoCaptureSettings(winRtInstance));
    }





    static void ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoCaptureSettings^>(info.This())) {
        return;
      }

      AdvancedPhotoCaptureSettings *wrapper = AdvancedPhotoCaptureSettings::Unwrap<AdvancedPhotoCaptureSettings>(info.This());

      try  {
        ::Windows::Media::Devices::AdvancedPhotoMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModeSetter(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::Media::Devices::AdvancedPhotoCaptureSettings^>(info.This())) {
        return;
      }

      AdvancedPhotoCaptureSettings *wrapper = AdvancedPhotoCaptureSettings::Unwrap<AdvancedPhotoCaptureSettings>(info.This());

      try {

        ::Windows::Media::Devices::AdvancedPhotoMode winRtValue = static_cast<::Windows::Media::Devices::AdvancedPhotoMode>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Mode = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapAdvancedPhotoCaptureSettings(::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ wintRtInstance);
      friend ::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ UnwrapAdvancedPhotoCaptureSettings(Local<Value> value);
  };

  Persistent<FunctionTemplate> AdvancedPhotoCaptureSettings::s_constructorTemplate;

  v8::Local<v8::Value> WrapAdvancedPhotoCaptureSettings(::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ 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>(AdvancedPhotoCaptureSettings::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ UnwrapAdvancedPhotoCaptureSettings(Local<Value> value) {
     return AdvancedPhotoCaptureSettings::Unwrap<AdvancedPhotoCaptureSettings>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAdvancedPhotoCaptureSettings(Local<Object> exports) {
    AdvancedPhotoCaptureSettings::Init(exports);
  }

  class AdvancedPhotoControl : 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>("AdvancedPhotoControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "configure", Configure);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedModes").ToLocalChecked(), SupportedModesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("AdvancedPhotoControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      AdvancedPhotoControl(::Windows::Media::Devices::AdvancedPhotoControl^ 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::Media::Devices::AdvancedPhotoControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::AdvancedPhotoControl^) 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());

      AdvancedPhotoControl *wrapperInstance = new AdvancedPhotoControl(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::Media::Devices::AdvancedPhotoControl^>(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::Media::Devices::AdvancedPhotoControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::AdvancedPhotoControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapAdvancedPhotoControl(winRtInstance));
    }


    static void Configure(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoControl^>(info.This())) {
        return;
      }

      AdvancedPhotoControl *wrapper = AdvancedPhotoControl::Unwrap<AdvancedPhotoControl>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoCaptureSettings^>(info[0]))
      {
        try
        {
          ::Windows::Media::Devices::AdvancedPhotoCaptureSettings^ arg0 = UnwrapAdvancedPhotoCaptureSettings(info[0]);
          
          wrapper->_instance->Configure(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 ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoControl^>(info.This())) {
        return;
      }

      AdvancedPhotoControl *wrapper = AdvancedPhotoControl::Unwrap<AdvancedPhotoControl>(info.This());

      try  {
        ::Windows::Media::Devices::AdvancedPhotoMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoControl^>(info.This())) {
        return;
      }

      AdvancedPhotoControl *wrapper = AdvancedPhotoControl::Unwrap<AdvancedPhotoControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedModesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AdvancedPhotoControl^>(info.This())) {
        return;
      }

      AdvancedPhotoControl *wrapper = AdvancedPhotoControl::Unwrap<AdvancedPhotoControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::AdvancedPhotoMode>^ result = wrapper->_instance->SupportedModes;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::AdvancedPhotoMode>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::AdvancedPhotoMode val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::AdvancedPhotoMode {
              return static_cast<::Windows::Media::Devices::AdvancedPhotoMode>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::AdvancedPhotoControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapAdvancedPhotoControl(::Windows::Media::Devices::AdvancedPhotoControl^ wintRtInstance);
      friend ::Windows::Media::Devices::AdvancedPhotoControl^ UnwrapAdvancedPhotoControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> AdvancedPhotoControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapAdvancedPhotoControl(::Windows::Media::Devices::AdvancedPhotoControl^ 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>(AdvancedPhotoControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::AdvancedPhotoControl^ UnwrapAdvancedPhotoControl(Local<Value> value) {
     return AdvancedPhotoControl::Unwrap<AdvancedPhotoControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAdvancedPhotoControl(Local<Object> exports) {
    AdvancedPhotoControl::Init(exports);
  }

  class OpticalImageStabilizationControl : 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>("OpticalImageStabilizationControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mode").ToLocalChecked(), ModeGetter, ModeSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedModes").ToLocalChecked(), SupportedModesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("OpticalImageStabilizationControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      OpticalImageStabilizationControl(::Windows::Media::Devices::OpticalImageStabilizationControl^ 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::Media::Devices::OpticalImageStabilizationControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::OpticalImageStabilizationControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::OpticalImageStabilizationControl^) 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());

      OpticalImageStabilizationControl *wrapperInstance = new OpticalImageStabilizationControl(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::Media::Devices::OpticalImageStabilizationControl^>(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::Media::Devices::OpticalImageStabilizationControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::OpticalImageStabilizationControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapOpticalImageStabilizationControl(winRtInstance));
    }





    static void ModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::OpticalImageStabilizationControl^>(info.This())) {
        return;
      }

      OpticalImageStabilizationControl *wrapper = OpticalImageStabilizationControl::Unwrap<OpticalImageStabilizationControl>(info.This());

      try  {
        ::Windows::Media::Devices::OpticalImageStabilizationMode result = wrapper->_instance->Mode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModeSetter(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::Media::Devices::OpticalImageStabilizationControl^>(info.This())) {
        return;
      }

      OpticalImageStabilizationControl *wrapper = OpticalImageStabilizationControl::Unwrap<OpticalImageStabilizationControl>(info.This());

      try {

        ::Windows::Media::Devices::OpticalImageStabilizationMode winRtValue = static_cast<::Windows::Media::Devices::OpticalImageStabilizationMode>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Mode = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::OpticalImageStabilizationControl^>(info.This())) {
        return;
      }

      OpticalImageStabilizationControl *wrapper = OpticalImageStabilizationControl::Unwrap<OpticalImageStabilizationControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedModesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::OpticalImageStabilizationControl^>(info.This())) {
        return;
      }

      OpticalImageStabilizationControl *wrapper = OpticalImageStabilizationControl::Unwrap<OpticalImageStabilizationControl>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Devices::OpticalImageStabilizationMode>^ result = wrapper->_instance->SupportedModes;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Devices::OpticalImageStabilizationMode>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Devices::OpticalImageStabilizationMode val) -> Local<Value> {
              return Nan::New<Integer>(static_cast<int>(val));
            },
            [](Local<Value> value) -> bool {
              return value->IsInt32();
            },
            [](Local<Value> value) -> ::Windows::Media::Devices::OpticalImageStabilizationMode {
              return static_cast<::Windows::Media::Devices::OpticalImageStabilizationMode>(Nan::To<int32_t>(value).FromMaybe(0));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::OpticalImageStabilizationControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapOpticalImageStabilizationControl(::Windows::Media::Devices::OpticalImageStabilizationControl^ wintRtInstance);
      friend ::Windows::Media::Devices::OpticalImageStabilizationControl^ UnwrapOpticalImageStabilizationControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> OpticalImageStabilizationControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapOpticalImageStabilizationControl(::Windows::Media::Devices::OpticalImageStabilizationControl^ 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>(OpticalImageStabilizationControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::OpticalImageStabilizationControl^ UnwrapOpticalImageStabilizationControl(Local<Value> value) {
     return OpticalImageStabilizationControl::Unwrap<OpticalImageStabilizationControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitOpticalImageStabilizationControl(Local<Object> exports) {
    OpticalImageStabilizationControl::Init(exports);
  }

  class IMediaDeviceController : 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>("IMediaDeviceController").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "getAvailableMediaStreamProperties", GetAvailableMediaStreamProperties);
            Nan::SetPrototypeMethod(localRef, "getMediaStreamProperties", GetMediaStreamProperties);
          

          
            Nan::SetPrototypeMethod(localRef, "setMediaStreamPropertiesAsync", SetMediaStreamPropertiesAsync);
          



        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("IMediaDeviceController").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      IMediaDeviceController(::Windows::Media::Devices::IMediaDeviceController^ 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::Media::Devices::IMediaDeviceController^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IMediaDeviceController^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::IMediaDeviceController^) 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());

      IMediaDeviceController *wrapperInstance = new IMediaDeviceController(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::Media::Devices::IMediaDeviceController^>(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::Media::Devices::IMediaDeviceController^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::IMediaDeviceController^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapIMediaDeviceController(winRtInstance));
    }

    static void SetMediaStreamPropertiesAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IMediaDeviceController^>(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;
      }

      IMediaDeviceController *wrapper = IMediaDeviceController::Unwrap<IMediaDeviceController>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 3
        && info[0]->IsInt32()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(info[1]))
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ arg1 = dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(info[1]));
          
          op = wrapper->_instance->SetMediaStreamPropertiesAsync(arg0,arg1);
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 GetAvailableMediaStreamProperties(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IMediaDeviceController^>(info.This())) {
        return;
      }

      IMediaDeviceController *wrapper = IMediaDeviceController::Unwrap<IMediaDeviceController>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          ::Windows::Foundation::Collections::IVectorView<::Windows::Media::MediaProperties::IMediaEncodingProperties^>^ result;
          result = wrapper->_instance->GetAvailableMediaStreamProperties(arg0);
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::MediaProperties::IMediaEncodingProperties^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::MediaProperties::IMediaEncodingProperties^ val) -> Local<Value> {
              return NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "IMediaEncodingProperties", val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::MediaProperties::IMediaEncodingProperties^ {
              return dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(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 GetMediaStreamProperties(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::IMediaDeviceController^>(info.This())) {
        return;
      }

      IMediaDeviceController *wrapper = IMediaDeviceController::Unwrap<IMediaDeviceController>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ result;
          result = wrapper->_instance->GetMediaStreamProperties(arg0);
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "IMediaEncodingProperties", 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;
      }
    }





    private:
      ::Windows::Media::Devices::IMediaDeviceController^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapIMediaDeviceController(::Windows::Media::Devices::IMediaDeviceController^ wintRtInstance);
      friend ::Windows::Media::Devices::IMediaDeviceController^ UnwrapIMediaDeviceController(Local<Value> value);
  };

  Persistent<FunctionTemplate> IMediaDeviceController::s_constructorTemplate;

  v8::Local<v8::Value> WrapIMediaDeviceController(::Windows::Media::Devices::IMediaDeviceController^ 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>(IMediaDeviceController::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::IMediaDeviceController^ UnwrapIMediaDeviceController(Local<Value> value) {
     return IMediaDeviceController::Unwrap<IMediaDeviceController>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitIMediaDeviceController(Local<Object> exports) {
    IMediaDeviceController::Init(exports);
  }

  class MediaDeviceControl : 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>("MediaDeviceControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "tryGetValue", TryGetValue);
            Nan::SetPrototypeMethod(localRef, "trySetValue", TrySetValue);
            Nan::SetPrototypeMethod(localRef, "tryGetAuto", TryGetAuto);
            Nan::SetPrototypeMethod(localRef, "trySetAuto", TrySetAuto);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("capabilities").ToLocalChecked(), CapabilitiesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MediaDeviceControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MediaDeviceControl(::Windows::Media::Devices::MediaDeviceControl^ 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::Media::Devices::MediaDeviceControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::MediaDeviceControl^) 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());

      MediaDeviceControl *wrapperInstance = new MediaDeviceControl(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::Media::Devices::MediaDeviceControl^>(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::Media::Devices::MediaDeviceControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::MediaDeviceControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMediaDeviceControl(winRtInstance));
    }


    static void TryGetValue(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControl^>(info.This())) {
        return;
      }

      MediaDeviceControl *wrapper = MediaDeviceControl::Unwrap<MediaDeviceControl>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          double arg0;
          
          bool result;
          result = wrapper->_instance->TryGetValue(&arg0);
          Local<Object> resObj = Nan::New<Object>();
          Nan::Set(resObj, Nan::New<String>("boolean").ToLocalChecked(), Nan::New<Boolean>(result));
          Nan::Set(resObj, Nan::New<String>("value").ToLocalChecked(), Nan::New<Number>(static_cast<double>(arg0)));
          info.GetReturnValue().Set(resObj);
          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 TrySetValue(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControl^>(info.This())) {
        return;
      }

      MediaDeviceControl *wrapper = MediaDeviceControl::Unwrap<MediaDeviceControl>(info.This());

      if (info.Length() == 1
        && info[0]->IsNumber())
      {
        try
        {
          double arg0 = Nan::To<double>(info[0]).FromMaybe(0.0);
          
          bool result;
          result = wrapper->_instance->TrySetValue(arg0);
          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 TryGetAuto(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControl^>(info.This())) {
        return;
      }

      MediaDeviceControl *wrapper = MediaDeviceControl::Unwrap<MediaDeviceControl>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          bool arg0;
          
          bool result;
          result = wrapper->_instance->TryGetAuto(&arg0);
          Local<Object> resObj = Nan::New<Object>();
          Nan::Set(resObj, Nan::New<String>("boolean").ToLocalChecked(), Nan::New<Boolean>(result));
          Nan::Set(resObj, Nan::New<String>("value").ToLocalChecked(), Nan::New<Boolean>(arg0));
          info.GetReturnValue().Set(resObj);
          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 TrySetAuto(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControl^>(info.This())) {
        return;
      }

      MediaDeviceControl *wrapper = MediaDeviceControl::Unwrap<MediaDeviceControl>(info.This());

      if (info.Length() == 1
        && info[0]->IsBoolean())
      {
        try
        {
          bool arg0 = Nan::To<bool>(info[0]).FromMaybe(false);
          
          bool result;
          result = wrapper->_instance->TrySetAuto(arg0);
          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 CapabilitiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControl^>(info.This())) {
        return;
      }

      MediaDeviceControl *wrapper = MediaDeviceControl::Unwrap<MediaDeviceControl>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControlCapabilities^ result = wrapper->_instance->Capabilities;
        info.GetReturnValue().Set(WrapMediaDeviceControlCapabilities(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::MediaDeviceControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMediaDeviceControl(::Windows::Media::Devices::MediaDeviceControl^ wintRtInstance);
      friend ::Windows::Media::Devices::MediaDeviceControl^ UnwrapMediaDeviceControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> MediaDeviceControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapMediaDeviceControl(::Windows::Media::Devices::MediaDeviceControl^ 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>(MediaDeviceControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::MediaDeviceControl^ UnwrapMediaDeviceControl(Local<Value> value) {
     return MediaDeviceControl::Unwrap<MediaDeviceControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMediaDeviceControl(Local<Object> exports) {
    MediaDeviceControl::Init(exports);
  }

  class LowLagPhotoSequenceControl : 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>("LowLagPhotoSequenceControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "getHighestConcurrentFrameRate", GetHighestConcurrentFrameRate);
            Nan::SetPrototypeMethod(localRef, "getCurrentFrameRate", GetCurrentFrameRate);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnailFormat").ToLocalChecked(), ThumbnailFormatGetter, ThumbnailFormatSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnailEnabled").ToLocalChecked(), ThumbnailEnabledGetter, ThumbnailEnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photosPerSecondLimit").ToLocalChecked(), PhotosPerSecondLimitGetter, PhotosPerSecondLimitSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("pastPhotoLimit").ToLocalChecked(), PastPhotoLimitGetter, PastPhotoLimitSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("desiredThumbnailSize").ToLocalChecked(), DesiredThumbnailSizeGetter, DesiredThumbnailSizeSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hardwareAcceleratedThumbnailSupported").ToLocalChecked(), HardwareAcceleratedThumbnailSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("maxPastPhotos").ToLocalChecked(), MaxPastPhotosGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("maxPhotosPerSecond").ToLocalChecked(), MaxPhotosPerSecondGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("LowLagPhotoSequenceControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      LowLagPhotoSequenceControl(::Windows::Media::Devices::LowLagPhotoSequenceControl^ 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::Media::Devices::LowLagPhotoSequenceControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::LowLagPhotoSequenceControl^) 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());

      LowLagPhotoSequenceControl *wrapperInstance = new LowLagPhotoSequenceControl(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::Media::Devices::LowLagPhotoSequenceControl^>(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::Media::Devices::LowLagPhotoSequenceControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::LowLagPhotoSequenceControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapLowLagPhotoSequenceControl(winRtInstance));
    }


    static void GetHighestConcurrentFrameRate(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(info[0]))
      {
        try
        {
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ arg0 = dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(info[0]));
          
          ::Windows::Media::MediaProperties::MediaRatio^ result;
          result = wrapper->_instance->GetHighestConcurrentFrameRate(arg0);
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "MediaRatio", 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 GetCurrentFrameRate(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Media::MediaProperties::MediaRatio^ result;
          result = wrapper->_instance->GetCurrentFrameRate();
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "MediaRatio", 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 ThumbnailFormatGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        ::Windows::Media::MediaProperties::MediaThumbnailFormat result = wrapper->_instance->ThumbnailFormat;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ThumbnailFormatSetter(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::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try {

        ::Windows::Media::MediaProperties::MediaThumbnailFormat winRtValue = static_cast<::Windows::Media::MediaProperties::MediaThumbnailFormat>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->ThumbnailFormat = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ThumbnailEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        bool result = wrapper->_instance->ThumbnailEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ThumbnailEnabledSetter(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::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->ThumbnailEnabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void PhotosPerSecondLimitGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        float result = wrapper->_instance->PhotosPerSecondLimit;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotosPerSecondLimitSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsNumber()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try {

        float winRtValue = static_cast<float>(Nan::To<double>(value).FromMaybe(0.0));

        wrapper->_instance->PhotosPerSecondLimit = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void PastPhotoLimitGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->PastPhotoLimit;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PastPhotoLimitSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsUint32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try {

        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->PastPhotoLimit = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DesiredThumbnailSizeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->DesiredThumbnailSize;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DesiredThumbnailSizeSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsUint32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try {

        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->DesiredThumbnailSize = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void HardwareAcceleratedThumbnailSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->HardwareAcceleratedThumbnailSupported;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MaxPastPhotosGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->MaxPastPhotos;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MaxPhotosPerSecondGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        float result = wrapper->_instance->MaxPhotosPerSecond;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoSequenceControl^>(info.This())) {
        return;
      }

      LowLagPhotoSequenceControl *wrapper = LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::LowLagPhotoSequenceControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapLowLagPhotoSequenceControl(::Windows::Media::Devices::LowLagPhotoSequenceControl^ wintRtInstance);
      friend ::Windows::Media::Devices::LowLagPhotoSequenceControl^ UnwrapLowLagPhotoSequenceControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> LowLagPhotoSequenceControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapLowLagPhotoSequenceControl(::Windows::Media::Devices::LowLagPhotoSequenceControl^ 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>(LowLagPhotoSequenceControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::LowLagPhotoSequenceControl^ UnwrapLowLagPhotoSequenceControl(Local<Value> value) {
     return LowLagPhotoSequenceControl::Unwrap<LowLagPhotoSequenceControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitLowLagPhotoSequenceControl(Local<Object> exports) {
    LowLagPhotoSequenceControl::Init(exports);
  }

  class LowLagPhotoControl : 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>("LowLagPhotoControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "getHighestConcurrentFrameRate", GetHighestConcurrentFrameRate);
            Nan::SetPrototypeMethod(localRef, "getCurrentFrameRate", GetCurrentFrameRate);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnailFormat").ToLocalChecked(), ThumbnailFormatGetter, ThumbnailFormatSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnailEnabled").ToLocalChecked(), ThumbnailEnabledGetter, ThumbnailEnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("desiredThumbnailSize").ToLocalChecked(), DesiredThumbnailSizeGetter, DesiredThumbnailSizeSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hardwareAcceleratedThumbnailSupported").ToLocalChecked(), HardwareAcceleratedThumbnailSupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("LowLagPhotoControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      LowLagPhotoControl(::Windows::Media::Devices::LowLagPhotoControl^ 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::Media::Devices::LowLagPhotoControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::LowLagPhotoControl^) 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());

      LowLagPhotoControl *wrapperInstance = new LowLagPhotoControl(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::Media::Devices::LowLagPhotoControl^>(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::Media::Devices::LowLagPhotoControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::LowLagPhotoControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapLowLagPhotoControl(winRtInstance));
    }


    static void GetHighestConcurrentFrameRate(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(info[0]))
      {
        try
        {
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ arg0 = dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(info[0]));
          
          ::Windows::Media::MediaProperties::MediaRatio^ result;
          result = wrapper->_instance->GetHighestConcurrentFrameRate(arg0);
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "MediaRatio", 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 GetCurrentFrameRate(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Media::MediaProperties::MediaRatio^ result;
          result = wrapper->_instance->GetCurrentFrameRate();
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "MediaRatio", 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 ThumbnailFormatGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      try  {
        ::Windows::Media::MediaProperties::MediaThumbnailFormat result = wrapper->_instance->ThumbnailFormat;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ThumbnailFormatSetter(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::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      try {

        ::Windows::Media::MediaProperties::MediaThumbnailFormat winRtValue = static_cast<::Windows::Media::MediaProperties::MediaThumbnailFormat>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->ThumbnailFormat = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ThumbnailEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      try  {
        bool result = wrapper->_instance->ThumbnailEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ThumbnailEnabledSetter(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::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->ThumbnailEnabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DesiredThumbnailSizeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->DesiredThumbnailSize;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DesiredThumbnailSizeSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsUint32()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      try {

        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->DesiredThumbnailSize = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void HardwareAcceleratedThumbnailSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::LowLagPhotoControl^>(info.This())) {
        return;
      }

      LowLagPhotoControl *wrapper = LowLagPhotoControl::Unwrap<LowLagPhotoControl>(info.This());

      try  {
        unsigned int result = wrapper->_instance->HardwareAcceleratedThumbnailSupported;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::LowLagPhotoControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapLowLagPhotoControl(::Windows::Media::Devices::LowLagPhotoControl^ wintRtInstance);
      friend ::Windows::Media::Devices::LowLagPhotoControl^ UnwrapLowLagPhotoControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> LowLagPhotoControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapLowLagPhotoControl(::Windows::Media::Devices::LowLagPhotoControl^ 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>(LowLagPhotoControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::LowLagPhotoControl^ UnwrapLowLagPhotoControl(Local<Value> value) {
     return LowLagPhotoControl::Unwrap<LowLagPhotoControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitLowLagPhotoControl(Local<Object> exports) {
    LowLagPhotoControl::Init(exports);
  }

  class PhotoConfirmationControl : 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>("PhotoConfirmationControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("pixelFormat").ToLocalChecked(), PixelFormatGetter, PixelFormatSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("enabled").ToLocalChecked(), EnabledGetter, EnabledSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoConfirmationControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoConfirmationControl(::Windows::Media::Devices::PhotoConfirmationControl^ 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::Media::Devices::PhotoConfirmationControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::PhotoConfirmationControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::PhotoConfirmationControl^) 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());

      PhotoConfirmationControl *wrapperInstance = new PhotoConfirmationControl(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::Media::Devices::PhotoConfirmationControl^>(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::Media::Devices::PhotoConfirmationControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::PhotoConfirmationControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoConfirmationControl(winRtInstance));
    }





    static void PixelFormatGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::PhotoConfirmationControl^>(info.This())) {
        return;
      }

      PhotoConfirmationControl *wrapper = PhotoConfirmationControl::Unwrap<PhotoConfirmationControl>(info.This());

      try  {
        ::Windows::Media::MediaProperties::MediaPixelFormat result = wrapper->_instance->PixelFormat;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PixelFormatSetter(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::Media::Devices::PhotoConfirmationControl^>(info.This())) {
        return;
      }

      PhotoConfirmationControl *wrapper = PhotoConfirmationControl::Unwrap<PhotoConfirmationControl>(info.This());

      try {

        ::Windows::Media::MediaProperties::MediaPixelFormat winRtValue = static_cast<::Windows::Media::MediaProperties::MediaPixelFormat>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->PixelFormat = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void EnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::PhotoConfirmationControl^>(info.This())) {
        return;
      }

      PhotoConfirmationControl *wrapper = PhotoConfirmationControl::Unwrap<PhotoConfirmationControl>(info.This());

      try  {
        bool result = wrapper->_instance->Enabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void EnabledSetter(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::Media::Devices::PhotoConfirmationControl^>(info.This())) {
        return;
      }

      PhotoConfirmationControl *wrapper = PhotoConfirmationControl::Unwrap<PhotoConfirmationControl>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->Enabled = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::PhotoConfirmationControl^>(info.This())) {
        return;
      }

      PhotoConfirmationControl *wrapper = PhotoConfirmationControl::Unwrap<PhotoConfirmationControl>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::PhotoConfirmationControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoConfirmationControl(::Windows::Media::Devices::PhotoConfirmationControl^ wintRtInstance);
      friend ::Windows::Media::Devices::PhotoConfirmationControl^ UnwrapPhotoConfirmationControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoConfirmationControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoConfirmationControl(::Windows::Media::Devices::PhotoConfirmationControl^ 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>(PhotoConfirmationControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::PhotoConfirmationControl^ UnwrapPhotoConfirmationControl(Local<Value> value) {
     return PhotoConfirmationControl::Unwrap<PhotoConfirmationControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoConfirmationControl(Local<Object> exports) {
    PhotoConfirmationControl::Init(exports);
  }

  class VideoDeviceControllerGetDevicePropertyResult : 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>("VideoDeviceControllerGetDevicePropertyResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("value").ToLocalChecked(), ValueGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("VideoDeviceControllerGetDevicePropertyResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      VideoDeviceControllerGetDevicePropertyResult(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ 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::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^) 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());

      VideoDeviceControllerGetDevicePropertyResult *wrapperInstance = new VideoDeviceControllerGetDevicePropertyResult(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::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^>(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::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapVideoDeviceControllerGetDevicePropertyResult(winRtInstance));
    }





    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^>(info.This())) {
        return;
      }

      VideoDeviceControllerGetDevicePropertyResult *wrapper = VideoDeviceControllerGetDevicePropertyResult::Unwrap<VideoDeviceControllerGetDevicePropertyResult>(info.This());

      try  {
        ::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^>(info.This())) {
        return;
      }

      VideoDeviceControllerGetDevicePropertyResult *wrapper = VideoDeviceControllerGetDevicePropertyResult::Unwrap<VideoDeviceControllerGetDevicePropertyResult>(info.This());

      try  {
        ::Platform::Object^ result = wrapper->_instance->Value;
        info.GetReturnValue().Set(CreateOpaqueWrapper(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapVideoDeviceControllerGetDevicePropertyResult(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ wintRtInstance);
      friend ::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ UnwrapVideoDeviceControllerGetDevicePropertyResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> VideoDeviceControllerGetDevicePropertyResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapVideoDeviceControllerGetDevicePropertyResult(::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ 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>(VideoDeviceControllerGetDevicePropertyResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ UnwrapVideoDeviceControllerGetDevicePropertyResult(Local<Value> value) {
     return VideoDeviceControllerGetDevicePropertyResult::Unwrap<VideoDeviceControllerGetDevicePropertyResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitVideoDeviceControllerGetDevicePropertyResult(Local<Object> exports) {
    VideoDeviceControllerGetDevicePropertyResult::Init(exports);
  }

  class MediaDeviceControlCapabilities : 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>("MediaDeviceControlCapabilities").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("autoModeSupported").ToLocalChecked(), AutoModeSupportedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("default").ToLocalChecked(), DefaultGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("max").ToLocalChecked(), MaxGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("min").ToLocalChecked(), MinGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("step").ToLocalChecked(), StepGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supported").ToLocalChecked(), SupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("MediaDeviceControlCapabilities").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      MediaDeviceControlCapabilities(::Windows::Media::Devices::MediaDeviceControlCapabilities^ 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::Media::Devices::MediaDeviceControlCapabilities^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControlCapabilities^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::MediaDeviceControlCapabilities^) 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());

      MediaDeviceControlCapabilities *wrapperInstance = new MediaDeviceControlCapabilities(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::Media::Devices::MediaDeviceControlCapabilities^>(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::Media::Devices::MediaDeviceControlCapabilities^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::MediaDeviceControlCapabilities^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapMediaDeviceControlCapabilities(winRtInstance));
    }





    static void AutoModeSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControlCapabilities^>(info.This())) {
        return;
      }

      MediaDeviceControlCapabilities *wrapper = MediaDeviceControlCapabilities::Unwrap<MediaDeviceControlCapabilities>(info.This());

      try  {
        bool result = wrapper->_instance->AutoModeSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DefaultGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControlCapabilities^>(info.This())) {
        return;
      }

      MediaDeviceControlCapabilities *wrapper = MediaDeviceControlCapabilities::Unwrap<MediaDeviceControlCapabilities>(info.This());

      try  {
        double result = wrapper->_instance->Default;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MaxGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControlCapabilities^>(info.This())) {
        return;
      }

      MediaDeviceControlCapabilities *wrapper = MediaDeviceControlCapabilities::Unwrap<MediaDeviceControlCapabilities>(info.This());

      try  {
        double result = wrapper->_instance->Max;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MinGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControlCapabilities^>(info.This())) {
        return;
      }

      MediaDeviceControlCapabilities *wrapper = MediaDeviceControlCapabilities::Unwrap<MediaDeviceControlCapabilities>(info.This());

      try  {
        double result = wrapper->_instance->Min;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StepGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControlCapabilities^>(info.This())) {
        return;
      }

      MediaDeviceControlCapabilities *wrapper = MediaDeviceControlCapabilities::Unwrap<MediaDeviceControlCapabilities>(info.This());

      try  {
        double result = wrapper->_instance->Step;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::MediaDeviceControlCapabilities^>(info.This())) {
        return;
      }

      MediaDeviceControlCapabilities *wrapper = MediaDeviceControlCapabilities::Unwrap<MediaDeviceControlCapabilities>(info.This());

      try  {
        bool result = wrapper->_instance->Supported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::MediaDeviceControlCapabilities^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapMediaDeviceControlCapabilities(::Windows::Media::Devices::MediaDeviceControlCapabilities^ wintRtInstance);
      friend ::Windows::Media::Devices::MediaDeviceControlCapabilities^ UnwrapMediaDeviceControlCapabilities(Local<Value> value);
  };

  Persistent<FunctionTemplate> MediaDeviceControlCapabilities::s_constructorTemplate;

  v8::Local<v8::Value> WrapMediaDeviceControlCapabilities(::Windows::Media::Devices::MediaDeviceControlCapabilities^ 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>(MediaDeviceControlCapabilities::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::MediaDeviceControlCapabilities^ UnwrapMediaDeviceControlCapabilities(Local<Value> value) {
     return MediaDeviceControlCapabilities::Unwrap<MediaDeviceControlCapabilities>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitMediaDeviceControlCapabilities(Local<Object> exports) {
    MediaDeviceControlCapabilities::Init(exports);
  }

  class VideoDeviceController : 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>("VideoDeviceController").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "trySetPowerlineFrequency", TrySetPowerlineFrequency);
            Nan::SetPrototypeMethod(localRef, "tryGetPowerlineFrequency", TryGetPowerlineFrequency);
            Nan::SetPrototypeMethod(localRef, "getAvailableMediaStreamProperties", GetAvailableMediaStreamProperties);
            Nan::SetPrototypeMethod(localRef, "getMediaStreamProperties", GetMediaStreamProperties);
            Nan::SetPrototypeMethod(localRef, "setDeviceProperty", SetDeviceProperty);
            Nan::SetPrototypeMethod(localRef, "getDeviceProperty", GetDeviceProperty);
            Nan::SetPrototypeMethod(localRef, "getDevicePropertyById", GetDevicePropertyById);
            Nan::SetPrototypeMethod(localRef, "setDevicePropertyById", SetDevicePropertyById);
            Nan::SetPrototypeMethod(localRef, "getDevicePropertyByExtendedId", GetDevicePropertyByExtendedId);
            Nan::SetPrototypeMethod(localRef, "setDevicePropertyByExtendedId", SetDevicePropertyByExtendedId);
          

          
            Nan::SetPrototypeMethod(localRef, "setMediaStreamPropertiesAsync", SetMediaStreamPropertiesAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("primaryUse").ToLocalChecked(), PrimaryUseGetter, PrimaryUseSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isoSpeedControl").ToLocalChecked(), IsoSpeedControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("focusControl").ToLocalChecked(), FocusControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("whiteBalanceControl").ToLocalChecked(), WhiteBalanceControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("torchControl").ToLocalChecked(), TorchControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sceneModeControl").ToLocalChecked(), SceneModeControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("flashControl").ToLocalChecked(), FlashControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("regionsOfInterestControl").ToLocalChecked(), RegionsOfInterestControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lowLagPhotoSequence").ToLocalChecked(), LowLagPhotoSequenceGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lowLagPhoto").ToLocalChecked(), LowLagPhotoGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("exposureCompensationControl").ToLocalChecked(), ExposureCompensationControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("exposureControl").ToLocalChecked(), ExposureControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("zoomControl").ToLocalChecked(), ZoomControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("variablePhotoSequenceController").ToLocalChecked(), VariablePhotoSequenceControllerGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photoConfirmationControl").ToLocalChecked(), PhotoConfirmationControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("desiredOptimization").ToLocalChecked(), DesiredOptimizationGetter, DesiredOptimizationSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hdrVideoControl").ToLocalChecked(), HdrVideoControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("advancedPhotoControl").ToLocalChecked(), AdvancedPhotoControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("exposurePriorityVideoControl").ToLocalChecked(), ExposurePriorityVideoControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("opticalImageStabilizationControl").ToLocalChecked(), OpticalImageStabilizationControlGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("pan").ToLocalChecked(), PanGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hue").ToLocalChecked(), HueGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("focus").ToLocalChecked(), FocusGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("contrast").ToLocalChecked(), ContrastGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("brightness").ToLocalChecked(), BrightnessGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("backlightCompensation").ToLocalChecked(), BacklightCompensationGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("zoom").ToLocalChecked(), ZoomGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("whiteBalance").ToLocalChecked(), WhiteBalanceGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("exposure").ToLocalChecked(), ExposureGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("tilt").ToLocalChecked(), TiltGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("roll").ToLocalChecked(), RollGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("VideoDeviceController").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      VideoDeviceController(::Windows::Media::Devices::VideoDeviceController^ 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::Media::Devices::VideoDeviceController^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::VideoDeviceController^) 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());

      VideoDeviceController *wrapperInstance = new VideoDeviceController(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::Media::Devices::VideoDeviceController^>(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::Media::Devices::VideoDeviceController^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::VideoDeviceController^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapVideoDeviceController(winRtInstance));
    }

    static void SetMediaStreamPropertiesAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(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;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 3
        && info[0]->IsInt32()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(info[1]))
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ arg1 = dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(info[1]));
          
          op = wrapper->_instance->SetMediaStreamPropertiesAsync(arg0,arg1);
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 TrySetPowerlineFrequency(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Capture::PowerlineFrequency arg0 = static_cast<::Windows::Media::Capture::PowerlineFrequency>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          bool result;
          result = wrapper->_instance->TrySetPowerlineFrequency(arg0);
          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 TryGetPowerlineFrequency(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Media::Capture::PowerlineFrequency arg0;
          
          bool result;
          result = wrapper->_instance->TryGetPowerlineFrequency(&arg0);
          Local<Object> resObj = Nan::New<Object>();
          Nan::Set(resObj, Nan::New<String>("boolean").ToLocalChecked(), Nan::New<Boolean>(result));
          Nan::Set(resObj, Nan::New<String>("value").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(arg0)));
          info.GetReturnValue().Set(resObj);
          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 GetAvailableMediaStreamProperties(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          ::Windows::Foundation::Collections::IVectorView<::Windows::Media::MediaProperties::IMediaEncodingProperties^>^ result;
          result = wrapper->_instance->GetAvailableMediaStreamProperties(arg0);
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::MediaProperties::IMediaEncodingProperties^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::MediaProperties::IMediaEncodingProperties^ val) -> Local<Value> {
              return NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "IMediaEncodingProperties", val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::MediaProperties::IMediaEncodingProperties^ {
              return dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(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 GetMediaStreamProperties(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ result;
          result = wrapper->_instance->GetMediaStreamProperties(arg0);
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "IMediaEncodingProperties", 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 SetDeviceProperty(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 2
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(info[1]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Platform::Object^ arg1 = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(info[1]));
          
          wrapper->_instance->SetDeviceProperty(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 GetDeviceProperty(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(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->GetDeviceProperty(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 GetDevicePropertyById(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsUint32())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Platform::IBox<unsigned int>^ arg1 = ref new ::Platform::Box<unsigned int>(static_cast<unsigned int>(Nan::To<uint32_t>(info[1]).FromMaybe(0)));
          
          ::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ result;
          result = wrapper->_instance->GetDevicePropertyById(arg0, arg1);
          info.GetReturnValue().Set(WrapVideoDeviceControllerGetDevicePropertyResult(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 SetDevicePropertyById(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 2
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Platform::Object^>(info[1]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Platform::Object^ arg1 = dynamic_cast<::Platform::Object^>(NodeRT::Utils::GetObjectInstance(info[1]));
          
          ::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus result;
          result = wrapper->_instance->SetDevicePropertyById(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 GetDevicePropertyByExtendedId(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 2
        && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array<unsigned char>^>(info[0]) || info[0]->IsArray())
        && info[1]->IsUint32())
      {
        try
        {
          ::Platform::Array<unsigned char>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Platform::Array<unsigned char>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtArray<unsigned char>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return value->IsInt32();
                 },
                 [](Local<Value> value) -> unsigned char {
                   return static_cast<unsigned char>(Nan::To<int32_t>(value).FromMaybe(0));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Platform::Array<unsigned char>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          ::Platform::IBox<unsigned int>^ arg1 = ref new ::Platform::Box<unsigned int>(static_cast<unsigned int>(Nan::To<uint32_t>(info[1]).FromMaybe(0)));
          
          ::Windows::Media::Devices::VideoDeviceControllerGetDevicePropertyResult^ result;
          result = wrapper->_instance->GetDevicePropertyByExtendedId(arg0, arg1);
          info.GetReturnValue().Set(WrapVideoDeviceControllerGetDevicePropertyResult(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 SetDevicePropertyByExtendedId(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      if (info.Length() == 2
        && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array<unsigned char>^>(info[0]) || info[0]->IsArray())
        && (NodeRT::Utils::IsWinRtWrapperOf<::Platform::Array<unsigned char>^>(info[1]) || info[1]->IsArray()))
      {
        try
        {
          ::Platform::Array<unsigned char>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Platform::Array<unsigned char>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtArray<unsigned char>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return value->IsInt32();
                 },
                 [](Local<Value> value) -> unsigned char {
                   return static_cast<unsigned char>(Nan::To<int32_t>(value).FromMaybe(0));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Platform::Array<unsigned char>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          ::Platform::Array<unsigned char>^ arg1 = 
            [] (v8::Local<v8::Value> value) -> ::Platform::Array<unsigned char>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtArray<unsigned char>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return value->IsInt32();
                 },
                 [](Local<Value> value) -> unsigned char {
                   return static_cast<unsigned char>(Nan::To<int32_t>(value).FromMaybe(0));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Platform::Array<unsigned char>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[1]);
          
          ::Windows::Media::Devices::VideoDeviceControllerSetDevicePropertyStatus result;
          result = wrapper->_instance->SetDevicePropertyByExtendedId(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 PrimaryUseGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::CaptureUse result = wrapper->_instance->PrimaryUse;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PrimaryUseSetter(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::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try {

        ::Windows::Media::Devices::CaptureUse winRtValue = static_cast<::Windows::Media::Devices::CaptureUse>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->PrimaryUse = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void IsoSpeedControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::IsoSpeedControl^ result = wrapper->_instance->IsoSpeedControl;
        info.GetReturnValue().Set(WrapIsoSpeedControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void FocusControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::FocusControl^ result = wrapper->_instance->FocusControl;
        info.GetReturnValue().Set(WrapFocusControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void WhiteBalanceControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::WhiteBalanceControl^ result = wrapper->_instance->WhiteBalanceControl;
        info.GetReturnValue().Set(WrapWhiteBalanceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TorchControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::TorchControl^ result = wrapper->_instance->TorchControl;
        info.GetReturnValue().Set(WrapTorchControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SceneModeControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::SceneModeControl^ result = wrapper->_instance->SceneModeControl;
        info.GetReturnValue().Set(WrapSceneModeControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void FlashControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::FlashControl^ result = wrapper->_instance->FlashControl;
        info.GetReturnValue().Set(WrapFlashControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RegionsOfInterestControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::RegionsOfInterestControl^ result = wrapper->_instance->RegionsOfInterestControl;
        info.GetReturnValue().Set(WrapRegionsOfInterestControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LowLagPhotoSequenceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::LowLagPhotoSequenceControl^ result = wrapper->_instance->LowLagPhotoSequence;
        info.GetReturnValue().Set(WrapLowLagPhotoSequenceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void LowLagPhotoGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::LowLagPhotoControl^ result = wrapper->_instance->LowLagPhoto;
        info.GetReturnValue().Set(WrapLowLagPhotoControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ExposureCompensationControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::ExposureCompensationControl^ result = wrapper->_instance->ExposureCompensationControl;
        info.GetReturnValue().Set(WrapExposureCompensationControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ExposureControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::ExposureControl^ result = wrapper->_instance->ExposureControl;
        info.GetReturnValue().Set(WrapExposureControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ZoomControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::ZoomControl^ result = wrapper->_instance->ZoomControl;
        info.GetReturnValue().Set(WrapZoomControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VariablePhotoSequenceControllerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::Core::VariablePhotoSequenceController^ result = wrapper->_instance->VariablePhotoSequenceController;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.Devices.Core", "VariablePhotoSequenceController", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotoConfirmationControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::PhotoConfirmationControl^ result = wrapper->_instance->PhotoConfirmationControl;
        info.GetReturnValue().Set(WrapPhotoConfirmationControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DesiredOptimizationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaCaptureOptimization result = wrapper->_instance->DesiredOptimization;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DesiredOptimizationSetter(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::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try {

        ::Windows::Media::Devices::MediaCaptureOptimization winRtValue = static_cast<::Windows::Media::Devices::MediaCaptureOptimization>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->DesiredOptimization = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void HdrVideoControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::HdrVideoControl^ result = wrapper->_instance->HdrVideoControl;
        info.GetReturnValue().Set(WrapHdrVideoControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AdvancedPhotoControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::AdvancedPhotoControl^ result = wrapper->_instance->AdvancedPhotoControl;
        info.GetReturnValue().Set(WrapAdvancedPhotoControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ExposurePriorityVideoControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::ExposurePriorityVideoControl^ result = wrapper->_instance->ExposurePriorityVideoControl;
        info.GetReturnValue().Set(WrapExposurePriorityVideoControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void OpticalImageStabilizationControlGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::OpticalImageStabilizationControl^ result = wrapper->_instance->OpticalImageStabilizationControl;
        info.GetReturnValue().Set(WrapOpticalImageStabilizationControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Id;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PanGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Pan;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void HueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Hue;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void FocusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Focus;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ContrastGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Contrast;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void BrightnessGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Brightness;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void BacklightCompensationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->BacklightCompensation;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ZoomGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Zoom;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void WhiteBalanceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->WhiteBalance;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ExposureGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Exposure;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TiltGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Tilt;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RollGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::VideoDeviceController^>(info.This())) {
        return;
      }

      VideoDeviceController *wrapper = VideoDeviceController::Unwrap<VideoDeviceController>(info.This());

      try  {
        ::Windows::Media::Devices::MediaDeviceControl^ result = wrapper->_instance->Roll;
        info.GetReturnValue().Set(WrapMediaDeviceControl(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::VideoDeviceController^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapVideoDeviceController(::Windows::Media::Devices::VideoDeviceController^ wintRtInstance);
      friend ::Windows::Media::Devices::VideoDeviceController^ UnwrapVideoDeviceController(Local<Value> value);
  };

  Persistent<FunctionTemplate> VideoDeviceController::s_constructorTemplate;

  v8::Local<v8::Value> WrapVideoDeviceController(::Windows::Media::Devices::VideoDeviceController^ 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>(VideoDeviceController::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::VideoDeviceController^ UnwrapVideoDeviceController(Local<Value> value) {
     return VideoDeviceController::Unwrap<VideoDeviceController>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitVideoDeviceController(Local<Object> exports) {
    VideoDeviceController::Init(exports);
  }

  class AudioDeviceController : 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>("AudioDeviceController").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "getAvailableMediaStreamProperties", GetAvailableMediaStreamProperties);
            Nan::SetPrototypeMethod(localRef, "getMediaStreamProperties", GetMediaStreamProperties);
          

          
            Nan::SetPrototypeMethod(localRef, "setMediaStreamPropertiesAsync", SetMediaStreamPropertiesAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("volumePercent").ToLocalChecked(), VolumePercentGetter, VolumePercentSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("muted").ToLocalChecked(), MutedGetter, MutedSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("AudioDeviceController").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      AudioDeviceController(::Windows::Media::Devices::AudioDeviceController^ 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::Media::Devices::AudioDeviceController^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceController^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::AudioDeviceController^) 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());

      AudioDeviceController *wrapperInstance = new AudioDeviceController(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::Media::Devices::AudioDeviceController^>(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::Media::Devices::AudioDeviceController^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::AudioDeviceController^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapAudioDeviceController(winRtInstance));
    }

    static void SetMediaStreamPropertiesAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceController^>(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;
      }

      AudioDeviceController *wrapper = AudioDeviceController::Unwrap<AudioDeviceController>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 3
        && info[0]->IsInt32()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(info[1]))
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ arg1 = dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(info[1]));
          
          op = wrapper->_instance->SetMediaStreamPropertiesAsync(arg0,arg1);
        }
        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<void> t) {
        try {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};


            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 GetAvailableMediaStreamProperties(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceController^>(info.This())) {
        return;
      }

      AudioDeviceController *wrapper = AudioDeviceController::Unwrap<AudioDeviceController>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          ::Windows::Foundation::Collections::IVectorView<::Windows::Media::MediaProperties::IMediaEncodingProperties^>^ result;
          result = wrapper->_instance->GetAvailableMediaStreamProperties(arg0);
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::MediaProperties::IMediaEncodingProperties^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::MediaProperties::IMediaEncodingProperties^ val) -> Local<Value> {
              return NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "IMediaEncodingProperties", val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::MediaProperties::IMediaEncodingProperties^ {
              return dynamic_cast<::Windows::Media::MediaProperties::IMediaEncodingProperties^>(NodeRT::Utils::GetObjectInstance(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 GetMediaStreamProperties(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceController^>(info.This())) {
        return;
      }

      AudioDeviceController *wrapper = AudioDeviceController::Unwrap<AudioDeviceController>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Capture::MediaStreamType arg0 = static_cast<::Windows::Media::Capture::MediaStreamType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          ::Windows::Media::MediaProperties::IMediaEncodingProperties^ result;
          result = wrapper->_instance->GetMediaStreamProperties(arg0);
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Media.MediaProperties", "IMediaEncodingProperties", 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 VolumePercentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceController^>(info.This())) {
        return;
      }

      AudioDeviceController *wrapper = AudioDeviceController::Unwrap<AudioDeviceController>(info.This());

      try  {
        float result = wrapper->_instance->VolumePercent;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VolumePercentSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsNumber()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceController^>(info.This())) {
        return;
      }

      AudioDeviceController *wrapper = AudioDeviceController::Unwrap<AudioDeviceController>(info.This());

      try {

        float winRtValue = static_cast<float>(Nan::To<double>(value).FromMaybe(0.0));

        wrapper->_instance->VolumePercent = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void MutedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::AudioDeviceController^>(info.This())) {
        return;
      }

      AudioDeviceController *wrapper = AudioDeviceController::Unwrap<AudioDeviceController>(info.This());

      try  {
        bool result = wrapper->_instance->Muted;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void MutedSetter(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::Media::Devices::AudioDeviceController^>(info.This())) {
        return;
      }

      AudioDeviceController *wrapper = AudioDeviceController::Unwrap<AudioDeviceController>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->Muted = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Media::Devices::AudioDeviceController^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapAudioDeviceController(::Windows::Media::Devices::AudioDeviceController^ wintRtInstance);
      friend ::Windows::Media::Devices::AudioDeviceController^ UnwrapAudioDeviceController(Local<Value> value);
  };

  Persistent<FunctionTemplate> AudioDeviceController::s_constructorTemplate;

  v8::Local<v8::Value> WrapAudioDeviceController(::Windows::Media::Devices::AudioDeviceController^ 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>(AudioDeviceController::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::AudioDeviceController^ UnwrapAudioDeviceController(Local<Value> value) {
     return AudioDeviceController::Unwrap<AudioDeviceController>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAudioDeviceController(Local<Object> exports) {
    AudioDeviceController::Init(exports);
  }

  class DialRequestedEventArgs : 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>("DialRequestedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "handled", Handled);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("contact").ToLocalChecked(), ContactGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("DialRequestedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      DialRequestedEventArgs(::Windows::Media::Devices::DialRequestedEventArgs^ 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::Media::Devices::DialRequestedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DialRequestedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::DialRequestedEventArgs^) 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());

      DialRequestedEventArgs *wrapperInstance = new DialRequestedEventArgs(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::Media::Devices::DialRequestedEventArgs^>(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::Media::Devices::DialRequestedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::DialRequestedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapDialRequestedEventArgs(winRtInstance));
    }


    static void Handled(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DialRequestedEventArgs^>(info.This())) {
        return;
      }

      DialRequestedEventArgs *wrapper = DialRequestedEventArgs::Unwrap<DialRequestedEventArgs>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Handled();
          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 ContactGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::DialRequestedEventArgs^>(info.This())) {
        return;
      }

      DialRequestedEventArgs *wrapper = DialRequestedEventArgs::Unwrap<DialRequestedEventArgs>(info.This());

      try  {
        ::Platform::Object^ result = wrapper->_instance->Contact;
        info.GetReturnValue().Set(CreateOpaqueWrapper(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::DialRequestedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapDialRequestedEventArgs(::Windows::Media::Devices::DialRequestedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Devices::DialRequestedEventArgs^ UnwrapDialRequestedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> DialRequestedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapDialRequestedEventArgs(::Windows::Media::Devices::DialRequestedEventArgs^ 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>(DialRequestedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::DialRequestedEventArgs^ UnwrapDialRequestedEventArgs(Local<Value> value) {
     return DialRequestedEventArgs::Unwrap<DialRequestedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitDialRequestedEventArgs(Local<Object> exports) {
    DialRequestedEventArgs::Init(exports);
  }

  class RedialRequestedEventArgs : 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>("RedialRequestedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "handled", Handled);
          




        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("RedialRequestedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      RedialRequestedEventArgs(::Windows::Media::Devices::RedialRequestedEventArgs^ 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::Media::Devices::RedialRequestedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RedialRequestedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::RedialRequestedEventArgs^) 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());

      RedialRequestedEventArgs *wrapperInstance = new RedialRequestedEventArgs(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::Media::Devices::RedialRequestedEventArgs^>(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::Media::Devices::RedialRequestedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::RedialRequestedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapRedialRequestedEventArgs(winRtInstance));
    }


    static void Handled(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::RedialRequestedEventArgs^>(info.This())) {
        return;
      }

      RedialRequestedEventArgs *wrapper = RedialRequestedEventArgs::Unwrap<RedialRequestedEventArgs>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Handled();
          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::Media::Devices::RedialRequestedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapRedialRequestedEventArgs(::Windows::Media::Devices::RedialRequestedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Devices::RedialRequestedEventArgs^ UnwrapRedialRequestedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> RedialRequestedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapRedialRequestedEventArgs(::Windows::Media::Devices::RedialRequestedEventArgs^ 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>(RedialRequestedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::RedialRequestedEventArgs^ UnwrapRedialRequestedEventArgs(Local<Value> value) {
     return RedialRequestedEventArgs::Unwrap<RedialRequestedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitRedialRequestedEventArgs(Local<Object> exports) {
    RedialRequestedEventArgs::Init(exports);
  }

  class KeypadPressedEventArgs : 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>("KeypadPressedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("telephonyKey").ToLocalChecked(), TelephonyKeyGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("KeypadPressedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      KeypadPressedEventArgs(::Windows::Media::Devices::KeypadPressedEventArgs^ 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::Media::Devices::KeypadPressedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::KeypadPressedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::KeypadPressedEventArgs^) 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());

      KeypadPressedEventArgs *wrapperInstance = new KeypadPressedEventArgs(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::Media::Devices::KeypadPressedEventArgs^>(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::Media::Devices::KeypadPressedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::KeypadPressedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapKeypadPressedEventArgs(winRtInstance));
    }





    static void TelephonyKeyGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::KeypadPressedEventArgs^>(info.This())) {
        return;
      }

      KeypadPressedEventArgs *wrapper = KeypadPressedEventArgs::Unwrap<KeypadPressedEventArgs>(info.This());

      try  {
        ::Windows::Media::Devices::TelephonyKey result = wrapper->_instance->TelephonyKey;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Devices::KeypadPressedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapKeypadPressedEventArgs(::Windows::Media::Devices::KeypadPressedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Devices::KeypadPressedEventArgs^ UnwrapKeypadPressedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> KeypadPressedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapKeypadPressedEventArgs(::Windows::Media::Devices::KeypadPressedEventArgs^ 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>(KeypadPressedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::KeypadPressedEventArgs^ UnwrapKeypadPressedEventArgs(Local<Value> value) {
     return KeypadPressedEventArgs::Unwrap<KeypadPressedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitKeypadPressedEventArgs(Local<Object> exports) {
    KeypadPressedEventArgs::Init(exports);
  }

  class CallControl : 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>("CallControl").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "indicateNewIncomingCall", IndicateNewIncomingCall);
            Nan::SetPrototypeMethod(localRef, "indicateNewOutgoingCall", IndicateNewOutgoingCall);
            Nan::SetPrototypeMethod(localRef, "indicateActiveCall", IndicateActiveCall);
            Nan::SetPrototypeMethod(localRef, "endCall", EndCall);
          


          
          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>("hasRinger").ToLocalChecked(), HasRingerGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "getDefault", GetDefault);
        Nan::SetMethod(constructor, "fromId", FromId);


        Nan::Set(exports, Nan::New<String>("CallControl").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      CallControl(::Windows::Media::Devices::CallControl^ 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::Media::Devices::CallControl^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Devices::CallControl^) 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());

      CallControl *wrapperInstance = new CallControl(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::Media::Devices::CallControl^>(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::Media::Devices::CallControl^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Devices::CallControl^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapCallControl(winRtInstance));
    }


    static void IndicateNewIncomingCall(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(info.This())) {
        return;
      }

      CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());

      if (info.Length() == 2
        && info[0]->IsBoolean()
        && info[1]->IsString())
      {
        try
        {
          bool arg0 = Nan::To<bool>(info[0]).FromMaybe(false);
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          
          unsigned __int64 result;
          result = wrapper->_instance->IndicateNewIncomingCall(arg0, arg1);
          info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(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 IndicateNewOutgoingCall(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(info.This())) {
        return;
      }

      CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          unsigned __int64 result;
          result = wrapper->_instance->IndicateNewOutgoingCall();
          info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(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 IndicateActiveCall(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(info.This())) {
        return;
      }

      CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());

      if (info.Length() == 1
        && info[0]->IsNumber())
      {
        try
        {
          unsigned __int64 arg0 = static_cast<unsigned __int64>(Nan::To<int64_t>(info[0]).FromMaybe(0));
          
          wrapper->_instance->IndicateActiveCall(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 EndCall(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(info.This())) {
        return;
      }

      CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());

      if (info.Length() == 1
        && info[0]->IsNumber())
      {
        try
        {
          unsigned __int64 arg0 = static_cast<unsigned __int64>(Nan::To<int64_t>(info[0]).FromMaybe(0));
          
          wrapper->_instance->EndCall(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 GetDefault(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Media::Devices::CallControl^ result;
          result = ::Windows::Media::Devices::CallControl::GetDefault();
          info.GetReturnValue().Set(WrapCallControl(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 FromId(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::Media::Devices::CallControl^ result;
          result = ::Windows::Media::Devices::CallControl::FromId(arg0);
          info.GetReturnValue().Set(WrapCallControl(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 HasRingerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(info.This())) {
        return;
      }

      CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());

      try  {
        bool result = wrapper->_instance->HasRinger;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        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"answerRequested", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
        }
        CallControl *wrapper = CallControl::Unwrap<CallControl>(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->AnswerRequested::add(
            ref new ::Windows::Media::Devices::CallControlEventHandler(
            [callbackObjPtr](::Windows::Media::Devices::CallControl^ arg0) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0]() {
                HandleScope scope;


                Local<Value> wrappedArg0;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapCallControl(arg0);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0 };
                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"audioTransferRequested", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
        }
        CallControl *wrapper = CallControl::Unwrap<CallControl>(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->AudioTransferRequested::add(
            ref new ::Windows::Media::Devices::CallControlEventHandler(
            [callbackObjPtr](::Windows::Media::Devices::CallControl^ arg0) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0]() {
                HandleScope scope;


                Local<Value> wrappedArg0;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapCallControl(arg0);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0 };
                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"dialRequested", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
        }
        CallControl *wrapper = CallControl::Unwrap<CallControl>(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->DialRequested::add(
            ref new ::Windows::Media::Devices::DialRequestedEventHandler(
            [callbackObjPtr](::Windows::Media::Devices::CallControl^ arg0, ::Windows::Media::Devices::DialRequestedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapCallControl(arg0);
                  wrappedArg1 = WrapDialRequestedEventArgs(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"hangUpRequested", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
        }
        CallControl *wrapper = CallControl::Unwrap<CallControl>(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->HangUpRequested::add(
            ref new ::Windows::Media::Devices::CallControlEventHandler(
            [callbackObjPtr](::Windows::Media::Devices::CallControl^ arg0) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0]() {
                HandleScope scope;


                Local<Value> wrappedArg0;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapCallControl(arg0);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0 };
                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"keypadPressed", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
        }
        CallControl *wrapper = CallControl::Unwrap<CallControl>(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->KeypadPressed::add(
            ref new ::Windows::Media::Devices::KeypadPressedEventHandler(
            [callbackObjPtr](::Windows::Media::Devices::CallControl^ arg0, ::Windows::Media::Devices::KeypadPressedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapCallControl(arg0);
                  wrappedArg1 = WrapKeypadPressedEventArgs(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"redialRequested", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
        }
        CallControl *wrapper = CallControl::Unwrap<CallControl>(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->RedialRequested::add(
            ref new ::Windows::Media::Devices::RedialRequestedEventHandler(
            [callbackObjPtr](::Windows::Media::Devices::CallControl^ arg0, ::Windows::Media::Devices::RedialRequestedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapCallControl(arg0);
                  wrappedArg1 = WrapRedialRequestedEventArgs(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"answerRequested", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"audioTransferRequested", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"dialRequested", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"hangUpRequested", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"keypadPressed", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"redialRequested", 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"answerRequested", str)) {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
          }
          CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());
          wrapper->_instance->AnswerRequested::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"audioTransferRequested", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
          }
          CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());
          wrapper->_instance->AudioTransferRequested::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"dialRequested", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
          }
          CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());
          wrapper->_instance->DialRequested::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"hangUpRequested", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
          }
          CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());
          wrapper->_instance->HangUpRequested::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"keypadPressed", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
          }
          CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());
          wrapper->_instance->KeypadPressed::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"redialRequested", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Devices::CallControl^>(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;
          }
          CallControl *wrapper = CallControl::Unwrap<CallControl>(info.This());
          wrapper->_instance->RedialRequested::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::Media::Devices::CallControl^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapCallControl(::Windows::Media::Devices::CallControl^ wintRtInstance);
      friend ::Windows::Media::Devices::CallControl^ UnwrapCallControl(Local<Value> value);
  };

  Persistent<FunctionTemplate> CallControl::s_constructorTemplate;

  v8::Local<v8::Value> WrapCallControl(::Windows::Media::Devices::CallControl^ 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>(CallControl::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Devices::CallControl^ UnwrapCallControl(Local<Value> value) {
     return CallControl::Unwrap<CallControl>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitCallControl(Local<Object> exports) {
    CallControl::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::Media::Devices::InitAudioDeviceRoleEnum(target);
      NodeRT::Windows::Media::Devices::InitSendCommandStatusEnum(target);
      NodeRT::Windows::Media::Devices::InitIsoSpeedPresetEnum(target);
      NodeRT::Windows::Media::Devices::InitCaptureSceneModeEnum(target);
      NodeRT::Windows::Media::Devices::InitMediaCaptureFocusStateEnum(target);
      NodeRT::Windows::Media::Devices::InitCameraStreamStateEnum(target);
      NodeRT::Windows::Media::Devices::InitMediaCapturePauseBehaviorEnum(target);
      NodeRT::Windows::Media::Devices::InitAdvancedPhotoModeEnum(target);
      NodeRT::Windows::Media::Devices::InitColorTemperaturePresetEnum(target);
      NodeRT::Windows::Media::Devices::InitZoomTransitionModeEnum(target);
      NodeRT::Windows::Media::Devices::InitFocusPresetEnum(target);
      NodeRT::Windows::Media::Devices::InitFocusModeEnum(target);
      NodeRT::Windows::Media::Devices::InitManualFocusDistanceEnum(target);
      NodeRT::Windows::Media::Devices::InitAutoFocusRangeEnum(target);
      NodeRT::Windows::Media::Devices::InitRegionOfInterestTypeEnum(target);
      NodeRT::Windows::Media::Devices::InitHdrVideoModeEnum(target);
      NodeRT::Windows::Media::Devices::InitOpticalImageStabilizationModeEnum(target);
      NodeRT::Windows::Media::Devices::InitCaptureUseEnum(target);
      NodeRT::Windows::Media::Devices::InitMediaCaptureOptimizationEnum(target);
      NodeRT::Windows::Media::Devices::InitVideoDeviceControllerSetDevicePropertyStatusEnum(target);
      NodeRT::Windows::Media::Devices::InitVideoDeviceControllerGetDevicePropertyStatusEnum(target);
      NodeRT::Windows::Media::Devices::InitTelephonyKeyEnum(target);
      NodeRT::Windows::Media::Devices::InitIDefaultAudioDeviceChangedEventArgs(target);
      NodeRT::Windows::Media::Devices::InitDefaultAudioCaptureDeviceChangedEventArgs(target);
      NodeRT::Windows::Media::Devices::InitDefaultAudioRenderDeviceChangedEventArgs(target);
      NodeRT::Windows::Media::Devices::InitModuleCommandResult(target);
      NodeRT::Windows::Media::Devices::InitAudioDeviceModulesManager(target);
      NodeRT::Windows::Media::Devices::InitAudioDeviceModuleNotificationEventArgs(target);
      NodeRT::Windows::Media::Devices::InitAudioDeviceModule(target);
      NodeRT::Windows::Media::Devices::InitMediaDevice(target);
      NodeRT::Windows::Media::Devices::InitSceneModeControl(target);
      NodeRT::Windows::Media::Devices::InitTorchControl(target);
      NodeRT::Windows::Media::Devices::InitFlashControl(target);
      NodeRT::Windows::Media::Devices::InitExposureCompensationControl(target);
      NodeRT::Windows::Media::Devices::InitIsoSpeedControl(target);
      NodeRT::Windows::Media::Devices::InitWhiteBalanceControl(target);
      NodeRT::Windows::Media::Devices::InitExposureControl(target);
      NodeRT::Windows::Media::Devices::InitZoomSettings(target);
      NodeRT::Windows::Media::Devices::InitZoomControl(target);
      NodeRT::Windows::Media::Devices::InitFocusSettings(target);
      NodeRT::Windows::Media::Devices::InitFocusControl(target);
      NodeRT::Windows::Media::Devices::InitRegionOfInterest(target);
      NodeRT::Windows::Media::Devices::InitRegionsOfInterestControl(target);
      NodeRT::Windows::Media::Devices::InitExposurePriorityVideoControl(target);
      NodeRT::Windows::Media::Devices::InitHdrVideoControl(target);
      NodeRT::Windows::Media::Devices::InitAdvancedPhotoCaptureSettings(target);
      NodeRT::Windows::Media::Devices::InitAdvancedPhotoControl(target);
      NodeRT::Windows::Media::Devices::InitOpticalImageStabilizationControl(target);
      NodeRT::Windows::Media::Devices::InitIMediaDeviceController(target);
      NodeRT::Windows::Media::Devices::InitMediaDeviceControl(target);
      NodeRT::Windows::Media::Devices::InitLowLagPhotoSequenceControl(target);
      NodeRT::Windows::Media::Devices::InitLowLagPhotoControl(target);
      NodeRT::Windows::Media::Devices::InitPhotoConfirmationControl(target);
      NodeRT::Windows::Media::Devices::InitVideoDeviceControllerGetDevicePropertyResult(target);
      NodeRT::Windows::Media::Devices::InitMediaDeviceControlCapabilities(target);
      NodeRT::Windows::Media::Devices::InitVideoDeviceController(target);
      NodeRT::Windows::Media::Devices::InitAudioDeviceController(target);
      NodeRT::Windows::Media::Devices::InitDialRequestedEventArgs(target);
      NodeRT::Windows::Media::Devices::InitRedialRequestedEventArgs(target);
      NodeRT::Windows::Media::Devices::InitKeypadPressedEventArgs(target);
      NodeRT::Windows::Media::Devices::InitCallControl(target);


  NodeRT::Utils::RegisterNameSpace("Windows.Media.Devices", target);
}



NODE_MODULE(binding, init)
