// 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 Import { 
  v8::Local<v8::Value> WrapPhotoImportSource(::Windows::Media::Import::PhotoImportSource^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportSource^ UnwrapPhotoImportSource(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportOperation(::Windows::Media::Import::PhotoImportOperation^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportOperation^ UnwrapPhotoImportOperation(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportManager(::Windows::Media::Import::PhotoImportManager^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportManager^ UnwrapPhotoImportManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportSession(::Windows::Media::Import::PhotoImportSession^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportSession^ UnwrapPhotoImportSession(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportFindItemsResult(::Windows::Media::Import::PhotoImportFindItemsResult^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportFindItemsResult^ UnwrapPhotoImportFindItemsResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportImportItemsResult(::Windows::Media::Import::PhotoImportImportItemsResult^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportImportItemsResult^ UnwrapPhotoImportImportItemsResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportDeleteImportedItemsFromSourceResult(::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ UnwrapPhotoImportDeleteImportedItemsFromSourceResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportStorageMedium(::Windows::Media::Import::PhotoImportStorageMedium^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportStorageMedium^ UnwrapPhotoImportStorageMedium(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportSidecar(::Windows::Media::Import::PhotoImportSidecar^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportSidecar^ UnwrapPhotoImportSidecar(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportVideoSegment(::Windows::Media::Import::PhotoImportVideoSegment^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportVideoSegment^ UnwrapPhotoImportVideoSegment(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportItem(::Windows::Media::Import::PhotoImportItem^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportItem^ UnwrapPhotoImportItem(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportSelectionChangedEventArgs(::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ UnwrapPhotoImportSelectionChangedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapPhotoImportItemImportedEventArgs(::Windows::Media::Import::PhotoImportItemImportedEventArgs^ wintRtInstance);
  ::Windows::Media::Import::PhotoImportItemImportedEventArgs^ UnwrapPhotoImportItemImportedEventArgs(Local<Value> value);
  



  static void InitPhotoImportStageEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportStage").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("notStarted").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportStage::NotStarted)));
    Nan::Set(enumObject, Nan::New<String>("findingItems").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportStage::FindingItems)));
    Nan::Set(enumObject, Nan::New<String>("importingItems").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportStage::ImportingItems)));
    Nan::Set(enumObject, Nan::New<String>("deletingImportedItemsFromSource").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportStage::DeletingImportedItemsFromSource)));
  }

  static void InitPhotoImportAccessModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportAccessMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("readWrite").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportAccessMode::ReadWrite)));
    Nan::Set(enumObject, Nan::New<String>("readOnly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportAccessMode::ReadOnly)));
    Nan::Set(enumObject, Nan::New<String>("readAndDelete").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportAccessMode::ReadAndDelete)));
  }

  static void InitPhotoImportImportModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportImportMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("importEverything").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportImportMode::ImportEverything)));
    Nan::Set(enumObject, Nan::New<String>("ignoreSidecars").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportImportMode::IgnoreSidecars)));
    Nan::Set(enumObject, Nan::New<String>("ignoreSiblings").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportImportMode::IgnoreSiblings)));
    Nan::Set(enumObject, Nan::New<String>("ignoreSidecarsAndSiblings").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportImportMode::IgnoreSidecarsAndSiblings)));
  }

  static void InitPhotoImportSourceTypeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportSourceType").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("generic").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSourceType::Generic)));
    Nan::Set(enumObject, Nan::New<String>("camera").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSourceType::Camera)));
    Nan::Set(enumObject, Nan::New<String>("mediaPlayer").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSourceType::MediaPlayer)));
    Nan::Set(enumObject, Nan::New<String>("phone").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSourceType::Phone)));
    Nan::Set(enumObject, Nan::New<String>("video").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSourceType::Video)));
    Nan::Set(enumObject, Nan::New<String>("personalInfoManager").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSourceType::PersonalInfoManager)));
    Nan::Set(enumObject, Nan::New<String>("audioRecorder").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSourceType::AudioRecorder)));
  }

  static void InitPhotoImportContentTypeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportContentType").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("unknown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportContentType::Unknown)));
    Nan::Set(enumObject, Nan::New<String>("image").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportContentType::Image)));
    Nan::Set(enumObject, Nan::New<String>("video").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportContentType::Video)));
  }

  static void InitPhotoImportPowerSourceEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportPowerSource").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("unknown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportPowerSource::Unknown)));
    Nan::Set(enumObject, Nan::New<String>("battery").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportPowerSource::Battery)));
    Nan::Set(enumObject, Nan::New<String>("external").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportPowerSource::External)));
  }

  static void InitPhotoImportStorageMediumTypeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportStorageMediumType").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("undefined").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportStorageMediumType::Undefined)));
    Nan::Set(enumObject, Nan::New<String>("fixed").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportStorageMediumType::Fixed)));
    Nan::Set(enumObject, Nan::New<String>("removable").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportStorageMediumType::Removable)));
  }

  static void InitPhotoImportContentTypeFilterEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportContentTypeFilter").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("onlyImages").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportContentTypeFilter::OnlyImages)));
    Nan::Set(enumObject, Nan::New<String>("onlyVideos").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportContentTypeFilter::OnlyVideos)));
    Nan::Set(enumObject, Nan::New<String>("imagesAndVideos").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportContentTypeFilter::ImagesAndVideos)));
  }

  static void InitPhotoImportItemSelectionModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportItemSelectionMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("selectAll").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportItemSelectionMode::SelectAll)));
    Nan::Set(enumObject, Nan::New<String>("selectNone").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportItemSelectionMode::SelectNone)));
    Nan::Set(enumObject, Nan::New<String>("selectNew").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportItemSelectionMode::SelectNew)));
  }

  static void InitPhotoImportSubfolderDateFormatEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportSubfolderDateFormat").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("year").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSubfolderDateFormat::Year)));
    Nan::Set(enumObject, Nan::New<String>("yearMonth").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSubfolderDateFormat::YearMonth)));
    Nan::Set(enumObject, Nan::New<String>("yearMonthDay").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSubfolderDateFormat::YearMonthDay)));
  }

  static void InitPhotoImportConnectionTransportEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportConnectionTransport").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("unknown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportConnectionTransport::Unknown)));
    Nan::Set(enumObject, Nan::New<String>("usb").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportConnectionTransport::Usb)));
    Nan::Set(enumObject, Nan::New<String>("iP").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportConnectionTransport::IP)));
    Nan::Set(enumObject, Nan::New<String>("bluetooth").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportConnectionTransport::Bluetooth)));
  }

  static void InitPhotoImportSubfolderCreationModeEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("PhotoImportSubfolderCreationMode").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("doNotCreateSubfolders").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSubfolderCreationMode::DoNotCreateSubfolders)));
    Nan::Set(enumObject, Nan::New<String>("createSubfoldersFromFileDate").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSubfolderCreationMode::CreateSubfoldersFromFileDate)));
    Nan::Set(enumObject, Nan::New<String>("createSubfoldersFromExifDate").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSubfolderCreationMode::CreateSubfoldersFromExifDate)));
    Nan::Set(enumObject, Nan::New<String>("keepOriginalFolderStructure").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Media::Import::PhotoImportSubfolderCreationMode::KeepOriginalFolderStructure)));
  }

  static bool IsPhotoImportProgressJsObject(Local<Value> value) {
    if (!value->IsObject()) {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    symbol = Nan::New<String>("itemsImported").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) {
        return false;
      }
    }
    
    symbol = Nan::New<String>("totalItemsToImport").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32()) {
        return false;
      }
    }
    
    symbol = Nan::New<String>("bytesImported").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      if (!Nan::Get(obj,symbol).ToLocalChecked()->IsNumber()) {
        return false;
      }
    }
    
    symbol = Nan::New<String>("totalBytesToImport").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      if (!Nan::Get(obj,symbol).ToLocalChecked()->IsNumber()) {
        return false;
      }
    }
    
    symbol = Nan::New<String>("importProgress").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      if (!Nan::Get(obj,symbol).ToLocalChecked()->IsNumber()) {
        return false;
      }
    }
    
    return true;
  }

  ::Windows::Media::Import::PhotoImportProgress PhotoImportProgressFromJsObject(Local<Value> value) {
    HandleScope scope;
    ::Windows::Media::Import::PhotoImportProgress 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;

    symbol = Nan::New<String>("itemsImported").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      returnValue.ItemsImported = static_cast<unsigned int>(Nan::To<uint32_t>(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0));
    }
    
    symbol = Nan::New<String>("totalItemsToImport").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      returnValue.TotalItemsToImport = static_cast<unsigned int>(Nan::To<uint32_t>(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0));
    }
    
    symbol = Nan::New<String>("bytesImported").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      returnValue.BytesImported = static_cast<unsigned __int64>(Nan::To<int64_t>(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0));
    }
    
    symbol = Nan::New<String>("totalBytesToImport").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      returnValue.TotalBytesToImport = static_cast<unsigned __int64>(Nan::To<int64_t>(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0));
    }
    
    symbol = Nan::New<String>("importProgress").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false)) {
      returnValue.ImportProgress = Nan::To<double>(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0.0);
    }
    
    return returnValue;
  }

  Local<Value> PhotoImportProgressToJsObject(::Windows::Media::Import::PhotoImportProgress value) {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();

    Nan::Set(obj, Nan::New<String>("itemsImported").ToLocalChecked(), Nan::New<Integer>(value.ItemsImported));
    Nan::Set(obj, Nan::New<String>("totalItemsToImport").ToLocalChecked(), Nan::New<Integer>(value.TotalItemsToImport));
    Nan::Set(obj, Nan::New<String>("bytesImported").ToLocalChecked(), Nan::New<Number>(static_cast<double>(value.BytesImported)));
    Nan::Set(obj, Nan::New<String>("totalBytesToImport").ToLocalChecked(), Nan::New<Number>(static_cast<double>(value.TotalBytesToImport)));
    Nan::Set(obj, Nan::New<String>("importProgress").ToLocalChecked(), Nan::New<Number>(static_cast<double>(value.ImportProgress)));

    return scope.Escape(obj);
  }


  class PhotoImportSource : 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>("PhotoImportSource").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "createImportSession", CreateImportSession);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("batteryLevelPercent").ToLocalChecked(), BatteryLevelPercentGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("connectionProtocol").ToLocalChecked(), ConnectionProtocolGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("connectionTransport").ToLocalChecked(), ConnectionTransportGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("dateTime").ToLocalChecked(), DateTimeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("description").ToLocalChecked(), DescriptionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("id").ToLocalChecked(), IdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isLocked").ToLocalChecked(), IsLockedGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isMassStorage").ToLocalChecked(), IsMassStorageGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("manufacturer").ToLocalChecked(), ManufacturerGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("model").ToLocalChecked(), ModelGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("powerSource").ToLocalChecked(), PowerSourceGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("serialNumber").ToLocalChecked(), SerialNumberGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("storageMedia").ToLocalChecked(), StorageMediaGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnail").ToLocalChecked(), ThumbnailGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("type").ToLocalChecked(), TypeGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        func = Nan::GetFunction(Nan::New<FunctionTemplate>(FromIdAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("fromIdAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(FromFolderAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("fromFolderAsync").ToLocalChecked(), func);


        Nan::Set(exports, Nan::New<String>("PhotoImportSource").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportSource(::Windows::Media::Import::PhotoImportSource^ 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::Import::PhotoImportSource^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportSource^) 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());

      PhotoImportSource *wrapperInstance = new PhotoImportSource(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::Import::PhotoImportSource^>(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::Import::PhotoImportSource^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportSource^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportSource(winRtInstance));
    }


    static void CreateImportSession(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Media::Import::PhotoImportSession^ result;
          result = wrapper->_instance->CreateImportSession();
          info.GetReturnValue().Set(WrapPhotoImportSession(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 FromIdAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Media::Import::PhotoImportSource^>^ op;


      if (info.Length() == 2
          && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
            
          op = ::Windows::Media::Import::PhotoImportSource::FromIdAsync(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::Import::PhotoImportSource^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapPhotoImportSource(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 FromFolderAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Media::Import::PhotoImportSource^>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFolder^>(info[0]))
      {
        try
        {
          ::Windows::Storage::IStorageFolder^ arg0 = dynamic_cast<::Windows::Storage::IStorageFolder^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Media::Import::PhotoImportSource::FromFolderAsync(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::Import::PhotoImportSource^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapPhotoImportSource(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 BatteryLevelPercentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Platform::IBox<unsigned int>^ result = wrapper->_instance->BatteryLevelPercent;
        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 ConnectionProtocolGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->ConnectionProtocol;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ConnectionTransportGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportConnectionTransport result = wrapper->_instance->ConnectionTransport;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DateTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Platform::IBox<::Windows::Foundation::DateTime>^ result = wrapper->_instance->DateTime;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(NodeRT::Utils::DateTimeToJS(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Description;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(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 IdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(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 IsLockedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Platform::IBox<bool>^ result = wrapper->_instance->IsLocked;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Boolean>(result->Value)) : Undefined());
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsMassStorageGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        bool result = wrapper->_instance->IsMassStorage;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ManufacturerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Manufacturer;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ModelGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Model;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PowerSourceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportPowerSource result = wrapper->_instance->PowerSource;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SerialNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->SerialNumber;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StorageMediaGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportStorageMedium^>^ result = wrapper->_instance->StorageMedia;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportStorageMedium^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportStorageMedium^ val) -> Local<Value> {
              return WrapPhotoImportStorageMedium(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportStorageMedium^ {
              return UnwrapPhotoImportStorageMedium(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ThumbnailGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Windows::Storage::Streams::IRandomAccessStreamReference^ result = wrapper->_instance->Thumbnail;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage.Streams", "IRandomAccessStreamReference", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TypeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(info.This())) {
        return;
      }

      PhotoImportSource *wrapper = PhotoImportSource::Unwrap<PhotoImportSource>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSourceType result = wrapper->_instance->Type;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportSource^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportSource(::Windows::Media::Import::PhotoImportSource^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportSource^ UnwrapPhotoImportSource(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportSource::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportSource(::Windows::Media::Import::PhotoImportSource^ 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>(PhotoImportSource::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportSource^ UnwrapPhotoImportSource(Local<Value> value) {
     return PhotoImportSource::Unwrap<PhotoImportSource>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportSource(Local<Object> exports) {
    PhotoImportSource::Init(exports);
  }

  class PhotoImportOperation : 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>("PhotoImportOperation").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("continueDeletingImportedItemsFromSourceAsync").ToLocalChecked(), ContinueDeletingImportedItemsFromSourceAsyncGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("continueFindingItemsAsync").ToLocalChecked(), ContinueFindingItemsAsyncGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("continueImportingItemsAsync").ToLocalChecked(), ContinueImportingItemsAsyncGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("session").ToLocalChecked(), SessionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("stage").ToLocalChecked(), StageGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportOperation").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportOperation(::Windows::Media::Import::PhotoImportOperation^ 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::Import::PhotoImportOperation^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportOperation^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportOperation^) 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());

      PhotoImportOperation *wrapperInstance = new PhotoImportOperation(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::Import::PhotoImportOperation^>(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::Import::PhotoImportOperation^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportOperation^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportOperation(winRtInstance));
    }





    static void ContinueDeletingImportedItemsFromSourceAsyncGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportOperation^>(info.This())) {
        return;
      }

      PhotoImportOperation *wrapper = PhotoImportOperation::Unwrap<PhotoImportOperation>(info.This());

      try  {
        ::Windows::Foundation::IAsyncOperationWithProgress<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^, double>^ result = wrapper->_instance->ContinueDeletingImportedItemsFromSourceAsync;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "IAsyncOperationWithProgress`2", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ContinueFindingItemsAsyncGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportOperation^>(info.This())) {
        return;
      }

      PhotoImportOperation *wrapper = PhotoImportOperation::Unwrap<PhotoImportOperation>(info.This());

      try  {
        ::Windows::Foundation::IAsyncOperationWithProgress<::Windows::Media::Import::PhotoImportFindItemsResult^, unsigned int>^ result = wrapper->_instance->ContinueFindingItemsAsync;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "IAsyncOperationWithProgress`2", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ContinueImportingItemsAsyncGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportOperation^>(info.This())) {
        return;
      }

      PhotoImportOperation *wrapper = PhotoImportOperation::Unwrap<PhotoImportOperation>(info.This());

      try  {
        ::Windows::Foundation::IAsyncOperationWithProgress<::Windows::Media::Import::PhotoImportImportItemsResult^, ::Windows::Media::Import::PhotoImportProgress>^ result = wrapper->_instance->ContinueImportingItemsAsync;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "IAsyncOperationWithProgress`2", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SessionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportOperation^>(info.This())) {
        return;
      }

      PhotoImportOperation *wrapper = PhotoImportOperation::Unwrap<PhotoImportOperation>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSession^ result = wrapper->_instance->Session;
        info.GetReturnValue().Set(WrapPhotoImportSession(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StageGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportOperation^>(info.This())) {
        return;
      }

      PhotoImportOperation *wrapper = PhotoImportOperation::Unwrap<PhotoImportOperation>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportStage result = wrapper->_instance->Stage;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportOperation^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportOperation(::Windows::Media::Import::PhotoImportOperation^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportOperation^ UnwrapPhotoImportOperation(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportOperation::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportOperation(::Windows::Media::Import::PhotoImportOperation^ 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>(PhotoImportOperation::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportOperation^ UnwrapPhotoImportOperation(Local<Value> value) {
     return PhotoImportOperation::Unwrap<PhotoImportOperation>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportOperation(Local<Object> exports) {
    PhotoImportOperation::Init(exports);
  }

  class PhotoImportManager : 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>("PhotoImportManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;





        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "getPendingOperations", GetPendingOperations);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(IsSupportedAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("isSupportedAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(FindAllSourcesAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("findAllSourcesAsync").ToLocalChecked(), func);


        Nan::Set(exports, Nan::New<String>("PhotoImportManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportManager(::Windows::Media::Import::PhotoImportManager^ 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::Import::PhotoImportManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportManager^) 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());

      PhotoImportManager *wrapperInstance = new PhotoImportManager(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::Import::PhotoImportManager^>(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::Import::PhotoImportManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportManager(winRtInstance));
    }




    static void IsSupportedAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<bool>^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = ::Windows::Media::Import::PhotoImportManager::IsSupportedAsync();
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<bool> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<Boolean>(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void FindAllSourcesAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportSource^>^>^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = ::Windows::Media::Import::PhotoImportManager::FindAllSourcesAsync();
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportSource^>^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportSource^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportSource^ val) -> Local<Value> {
              return WrapPhotoImportSource(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSource^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportSource^ {
              return UnwrapPhotoImportSource(value);
            }
          );
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }


    static void GetPendingOperations(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportOperation^>^ result;
          result = ::Windows::Media::Import::PhotoImportManager::GetPendingOperations();
          info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportOperation^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportOperation^ val) -> Local<Value> {
              return WrapPhotoImportOperation(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportOperation^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportOperation^ {
              return UnwrapPhotoImportOperation(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;
      }
    }



    private:
      ::Windows::Media::Import::PhotoImportManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportManager(::Windows::Media::Import::PhotoImportManager^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportManager^ UnwrapPhotoImportManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportManager(::Windows::Media::Import::PhotoImportManager^ 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>(PhotoImportManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportManager^ UnwrapPhotoImportManager(Local<Value> value) {
     return PhotoImportManager::Unwrap<PhotoImportManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportManager(Local<Object> exports) {
    PhotoImportManager::Init(exports);
  }

  class PhotoImportSession : 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>("PhotoImportSession").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "close", Close);
          

          
            Nan::SetPrototypeMethod(localRef, "findItemsAsync", FindItemsAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("subfolderCreationMode").ToLocalChecked(), SubfolderCreationModeGetter, SubfolderCreationModeSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("destinationFolder").ToLocalChecked(), DestinationFolderGetter, DestinationFolderSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("destinationFileNamePrefix").ToLocalChecked(), DestinationFileNamePrefixGetter, DestinationFileNamePrefixSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("appendSessionDateToDestinationFolder").ToLocalChecked(), AppendSessionDateToDestinationFolderGetter, AppendSessionDateToDestinationFolderSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sessionId").ToLocalChecked(), SessionIdGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("source").ToLocalChecked(), SourceGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("subfolderDateFormat").ToLocalChecked(), SubfolderDateFormatGetter, SubfolderDateFormatSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("rememberDeselectedItems").ToLocalChecked(), RememberDeselectedItemsGetter, RememberDeselectedItemsSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportSession").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportSession(::Windows::Media::Import::PhotoImportSession^ 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::Import::PhotoImportSession^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportSession^) 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());

      PhotoImportSession *wrapperInstance = new PhotoImportSession(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::Import::PhotoImportSession^>(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::Import::PhotoImportSession^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportSession^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportSession(winRtInstance));
    }

    static void FindItemsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(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;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      ::Windows::Foundation::IAsyncOperationWithProgress<::Windows::Media::Import::PhotoImportFindItemsResult^, unsigned int>^ op;


      if (info.Length() == 3
        && info[0]->IsInt32()
        && info[1]->IsInt32())
      {
        try
        {
          ::Windows::Media::Import::PhotoImportContentTypeFilter arg0 = static_cast<::Windows::Media::Import::PhotoImportContentTypeFilter>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          ::Windows::Media::Import::PhotoImportItemSelectionMode arg1 = static_cast<::Windows::Media::Import::PhotoImportItemSelectionMode>(Nan::To<int32_t>(info[1]).FromMaybe(0));
          
          op = wrapper->_instance->FindItemsAsync(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<::Windows::Media::Import::PhotoImportFindItemsResult^> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapPhotoImportFindItemsResult(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 Close(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      if (info.Length() == 0) {
        try {
          delete wrapper->_instance;
          wrapper->_instance = nullptr;
          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 SubfolderCreationModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSubfolderCreationMode result = wrapper->_instance->SubfolderCreationMode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SubfolderCreationModeSetter(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::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try {

        ::Windows::Media::Import::PhotoImportSubfolderCreationMode winRtValue = static_cast<::Windows::Media::Import::PhotoImportSubfolderCreationMode>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->SubfolderCreationMode = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DestinationFolderGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        ::Windows::Storage::IStorageFolder^ result = wrapper->_instance->DestinationFolder;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage", "IStorageFolder", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DestinationFolderSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFolder^>(value)) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try {

        ::Windows::Storage::IStorageFolder^ winRtValue = dynamic_cast<::Windows::Storage::IStorageFolder^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->DestinationFolder = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DestinationFileNamePrefixGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->DestinationFileNamePrefix;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DestinationFileNamePrefixSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
      HandleScope scope;

      if (!value->IsString()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->DestinationFileNamePrefix = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void AppendSessionDateToDestinationFolderGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        bool result = wrapper->_instance->AppendSessionDateToDestinationFolder;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AppendSessionDateToDestinationFolderSetter(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::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AppendSessionDateToDestinationFolder = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void SessionIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        ::Platform::Guid result = wrapper->_instance->SessionId;
        info.GetReturnValue().Set(NodeRT::Utils::GuidToJs(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SourceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSource^ result = wrapper->_instance->Source;
        info.GetReturnValue().Set(WrapPhotoImportSource(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SubfolderDateFormatGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSubfolderDateFormat result = wrapper->_instance->SubfolderDateFormat;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SubfolderDateFormatSetter(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::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try {

        ::Windows::Media::Import::PhotoImportSubfolderDateFormat winRtValue = static_cast<::Windows::Media::Import::PhotoImportSubfolderDateFormat>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->SubfolderDateFormat = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void RememberDeselectedItemsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try  {
        bool result = wrapper->_instance->RememberDeselectedItems;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void RememberDeselectedItemsSetter(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::Import::PhotoImportSession^>(info.This())) {
        return;
      }

      PhotoImportSession *wrapper = PhotoImportSession::Unwrap<PhotoImportSession>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->RememberDeselectedItems = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportSession^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportSession(::Windows::Media::Import::PhotoImportSession^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportSession^ UnwrapPhotoImportSession(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportSession::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportSession(::Windows::Media::Import::PhotoImportSession^ 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>(PhotoImportSession::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportSession^ UnwrapPhotoImportSession(Local<Value> value) {
     return PhotoImportSession::Unwrap<PhotoImportSession>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportSession(Local<Object> exports) {
    PhotoImportSession::Init(exports);
  }

  class PhotoImportFindItemsResult : 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>("PhotoImportFindItemsResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;

          
            Nan::SetPrototypeMethod(localRef, "selectAll", SelectAll);
            Nan::SetPrototypeMethod(localRef, "selectNone", SelectNone);
            Nan::SetPrototypeMethod(localRef, "setImportMode", SetImportMode);
            Nan::SetPrototypeMethod(localRef, "addItemsInDateRangeToSelection", AddItemsInDateRangeToSelection);
          

          
            Nan::SetPrototypeMethod(localRef, "selectNewAsync", SelectNewAsync);
            Nan::SetPrototypeMethod(localRef, "importItemsAsync", ImportItemsAsync);
          

          
          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>("foundItems").ToLocalChecked(), FoundItemsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hasSucceeded").ToLocalChecked(), HasSucceededGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("importMode").ToLocalChecked(), ImportModeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photosCount").ToLocalChecked(), PhotosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photosSizeInBytes").ToLocalChecked(), PhotosSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedPhotosCount").ToLocalChecked(), SelectedPhotosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedPhotosSizeInBytes").ToLocalChecked(), SelectedPhotosSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedSiblingsCount").ToLocalChecked(), SelectedSiblingsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedSiblingsSizeInBytes").ToLocalChecked(), SelectedSiblingsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedSidecarsCount").ToLocalChecked(), SelectedSidecarsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedSidecarsSizeInBytes").ToLocalChecked(), SelectedSidecarsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedTotalCount").ToLocalChecked(), SelectedTotalCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedTotalSizeInBytes").ToLocalChecked(), SelectedTotalSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedVideosCount").ToLocalChecked(), SelectedVideosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("selectedVideosSizeInBytes").ToLocalChecked(), SelectedVideosSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("session").ToLocalChecked(), SessionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("siblingsCount").ToLocalChecked(), SiblingsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("siblingsSizeInBytes").ToLocalChecked(), SiblingsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecarsCount").ToLocalChecked(), SidecarsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecarsSizeInBytes").ToLocalChecked(), SidecarsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("totalCount").ToLocalChecked(), TotalCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("totalSizeInBytes").ToLocalChecked(), TotalSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("videosCount").ToLocalChecked(), VideosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("videosSizeInBytes").ToLocalChecked(), VideosSizeInBytesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportFindItemsResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportFindItemsResult(::Windows::Media::Import::PhotoImportFindItemsResult^ 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::Import::PhotoImportFindItemsResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportFindItemsResult^) 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());

      PhotoImportFindItemsResult *wrapperInstance = new PhotoImportFindItemsResult(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::Import::PhotoImportFindItemsResult^>(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::Import::PhotoImportFindItemsResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportFindItemsResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportFindItemsResult(winRtInstance));
    }

    static void SelectNewAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(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;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->SelectNewAsync();
        }
        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 ImportItemsAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(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;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      ::Windows::Foundation::IAsyncOperationWithProgress<::Windows::Media::Import::PhotoImportImportItemsResult^, ::Windows::Media::Import::PhotoImportProgress>^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->ImportItemsAsync();
        }
        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::Import::PhotoImportImportItemsResult^> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapPhotoImportImportItemsResult(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 SelectAll(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->SelectAll();
          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 SelectNone(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->SelectNone();
          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 SetImportMode(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      if (info.Length() == 1
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::Media::Import::PhotoImportImportMode arg0 = static_cast<::Windows::Media::Import::PhotoImportImportMode>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          wrapper->_instance->SetImportMode(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 AddItemsInDateRangeToSelection(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      if (info.Length() == 2
        && info[0]->IsDate()
        && info[1]->IsNumber())
      {
        try
        {
          ::Windows::Foundation::DateTime arg0 = NodeRT::Utils::DateTimeFromJSDate(info[0]);
          ::Windows::Foundation::TimeSpan arg1 = NodeRT::Utils::TimeSpanFromMilli(Nan::To<int64_t>(info[1]).FromMaybe(0));
          
          wrapper->_instance->AddItemsInDateRangeToSelection(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 FoundItemsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportItem^>^ result = wrapper->_instance->FoundItems;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportItem^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportItem^ val) -> Local<Value> {
              return WrapPhotoImportItem(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportItem^ {
              return UnwrapPhotoImportItem(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void HasSucceededGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        bool result = wrapper->_instance->HasSucceeded;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ImportModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportImportMode result = wrapper->_instance->ImportMode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->PhotosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->PhotosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedPhotosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SelectedPhotosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedPhotosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SelectedPhotosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedSiblingsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SelectedSiblingsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedSiblingsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SelectedSiblingsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedSidecarsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SelectedSidecarsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedSidecarsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SelectedSidecarsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedTotalCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SelectedTotalCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedTotalSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SelectedTotalSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedVideosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SelectedVideosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SelectedVideosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SelectedVideosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SessionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSession^ result = wrapper->_instance->Session;
        info.GetReturnValue().Set(WrapPhotoImportSession(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SiblingsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SiblingsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SidecarsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SidecarsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TotalCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->TotalCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TotalSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->TotalSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VideosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->VideosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VideosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(info.This())) {
        return;
      }

      PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->VideosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(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"itemImported", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(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;
        }
        PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(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->ItemImported::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Media::Import::PhotoImportFindItemsResult^, ::Windows::Media::Import::PhotoImportItemImportedEventArgs^>(
            [callbackObjPtr](::Windows::Media::Import::PhotoImportFindItemsResult^ arg0, ::Windows::Media::Import::PhotoImportItemImportedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapPhotoImportFindItemsResult(arg0);
                  wrappedArg1 = WrapPhotoImportItemImportedEventArgs(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"selectionChanged", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(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;
        }
        PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(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->SelectionChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::Media::Import::PhotoImportFindItemsResult^, ::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^>(
            [callbackObjPtr](::Windows::Media::Import::PhotoImportFindItemsResult^ arg0, ::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = WrapPhotoImportFindItemsResult(arg0);
                  wrappedArg1 = WrapPhotoImportSelectionChangedEventArgs(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"itemImported", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"selectionChanged", 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"itemImported", str)) {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(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;
          }
          PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());
          wrapper->_instance->ItemImported::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"selectionChanged", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportFindItemsResult^>(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;
          }
          PhotoImportFindItemsResult *wrapper = PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(info.This());
          wrapper->_instance->SelectionChanged::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::Import::PhotoImportFindItemsResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportFindItemsResult(::Windows::Media::Import::PhotoImportFindItemsResult^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportFindItemsResult^ UnwrapPhotoImportFindItemsResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportFindItemsResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportFindItemsResult(::Windows::Media::Import::PhotoImportFindItemsResult^ 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>(PhotoImportFindItemsResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportFindItemsResult^ UnwrapPhotoImportFindItemsResult(Local<Value> value) {
     return PhotoImportFindItemsResult::Unwrap<PhotoImportFindItemsResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportFindItemsResult(Local<Object> exports) {
    PhotoImportFindItemsResult::Init(exports);
  }

  class PhotoImportImportItemsResult : 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>("PhotoImportImportItemsResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;


          
            Nan::SetPrototypeMethod(localRef, "deleteImportedItemsFromSourceAsync", DeleteImportedItemsFromSourceAsync);
          


          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hasSucceeded").ToLocalChecked(), HasSucceededGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("importedItems").ToLocalChecked(), ImportedItemsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photosCount").ToLocalChecked(), PhotosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photosSizeInBytes").ToLocalChecked(), PhotosSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("session").ToLocalChecked(), SessionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("siblingsCount").ToLocalChecked(), SiblingsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("siblingsSizeInBytes").ToLocalChecked(), SiblingsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecarsCount").ToLocalChecked(), SidecarsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecarsSizeInBytes").ToLocalChecked(), SidecarsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("totalCount").ToLocalChecked(), TotalCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("totalSizeInBytes").ToLocalChecked(), TotalSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("videosCount").ToLocalChecked(), VideosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("videosSizeInBytes").ToLocalChecked(), VideosSizeInBytesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportImportItemsResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportImportItemsResult(::Windows::Media::Import::PhotoImportImportItemsResult^ 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::Import::PhotoImportImportItemsResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportImportItemsResult^) 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());

      PhotoImportImportItemsResult *wrapperInstance = new PhotoImportImportItemsResult(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::Import::PhotoImportImportItemsResult^>(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::Import::PhotoImportImportItemsResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportImportItemsResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportImportItemsResult(winRtInstance));
    }

    static void DeleteImportedItemsFromSourceAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(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;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      ::Windows::Foundation::IAsyncOperationWithProgress<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^, double>^ op;


      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->DeleteImportedItemsFromSourceAsync();
        }
        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::Import::PhotoImportDeleteImportedItemsFromSourceResult^> t) {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapPhotoImportDeleteImportedItemsFromSourceResult(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 HasSucceededGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        bool result = wrapper->_instance->HasSucceeded;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ImportedItemsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportItem^>^ result = wrapper->_instance->ImportedItems;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportItem^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportItem^ val) -> Local<Value> {
              return WrapPhotoImportItem(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportItem^ {
              return UnwrapPhotoImportItem(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->PhotosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->PhotosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SessionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSession^ result = wrapper->_instance->Session;
        info.GetReturnValue().Set(WrapPhotoImportSession(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SiblingsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SiblingsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SidecarsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SidecarsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TotalCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->TotalCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TotalSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->TotalSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VideosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->VideosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VideosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportImportItemsResult^>(info.This())) {
        return;
      }

      PhotoImportImportItemsResult *wrapper = PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->VideosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportImportItemsResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportImportItemsResult(::Windows::Media::Import::PhotoImportImportItemsResult^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportImportItemsResult^ UnwrapPhotoImportImportItemsResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportImportItemsResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportImportItemsResult(::Windows::Media::Import::PhotoImportImportItemsResult^ 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>(PhotoImportImportItemsResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportImportItemsResult^ UnwrapPhotoImportImportItemsResult(Local<Value> value) {
     return PhotoImportImportItemsResult::Unwrap<PhotoImportImportItemsResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportImportItemsResult(Local<Object> exports) {
    PhotoImportImportItemsResult::Init(exports);
  }

  class PhotoImportDeleteImportedItemsFromSourceResult : 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>("PhotoImportDeleteImportedItemsFromSourceResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("deletedItems").ToLocalChecked(), DeletedItemsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hasSucceeded").ToLocalChecked(), HasSucceededGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photosCount").ToLocalChecked(), PhotosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("photosSizeInBytes").ToLocalChecked(), PhotosSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("session").ToLocalChecked(), SessionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("siblingsCount").ToLocalChecked(), SiblingsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("siblingsSizeInBytes").ToLocalChecked(), SiblingsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecarsCount").ToLocalChecked(), SidecarsCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecarsSizeInBytes").ToLocalChecked(), SidecarsSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("totalCount").ToLocalChecked(), TotalCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("totalSizeInBytes").ToLocalChecked(), TotalSizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("videosCount").ToLocalChecked(), VideosCountGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("videosSizeInBytes").ToLocalChecked(), VideosSizeInBytesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportDeleteImportedItemsFromSourceResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportDeleteImportedItemsFromSourceResult(::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ 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::Import::PhotoImportDeleteImportedItemsFromSourceResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^) 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());

      PhotoImportDeleteImportedItemsFromSourceResult *wrapperInstance = new PhotoImportDeleteImportedItemsFromSourceResult(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::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(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::Import::PhotoImportDeleteImportedItemsFromSourceResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportDeleteImportedItemsFromSourceResult(winRtInstance));
    }





    static void DeletedItemsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportItem^>^ result = wrapper->_instance->DeletedItems;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportItem^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportItem^ val) -> Local<Value> {
              return WrapPhotoImportItem(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportItem^ {
              return UnwrapPhotoImportItem(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void HasSucceededGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        bool result = wrapper->_instance->HasSucceeded;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->PhotosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void PhotosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->PhotosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SessionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSession^ result = wrapper->_instance->Session;
        info.GetReturnValue().Set(WrapPhotoImportSession(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SiblingsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SiblingsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->SidecarsCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SidecarsSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TotalCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->TotalCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TotalSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->TotalSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VideosCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned int result = wrapper->_instance->VideosCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VideosSizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^>(info.This())) {
        return;
      }

      PhotoImportDeleteImportedItemsFromSourceResult *wrapper = PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->VideosSizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportDeleteImportedItemsFromSourceResult(::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ UnwrapPhotoImportDeleteImportedItemsFromSourceResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportDeleteImportedItemsFromSourceResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportDeleteImportedItemsFromSourceResult(::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ 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>(PhotoImportDeleteImportedItemsFromSourceResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportDeleteImportedItemsFromSourceResult^ UnwrapPhotoImportDeleteImportedItemsFromSourceResult(Local<Value> value) {
     return PhotoImportDeleteImportedItemsFromSourceResult::Unwrap<PhotoImportDeleteImportedItemsFromSourceResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportDeleteImportedItemsFromSourceResult(Local<Object> exports) {
    PhotoImportDeleteImportedItemsFromSourceResult::Init(exports);
  }

  class PhotoImportStorageMedium : 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>("PhotoImportStorageMedium").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "refresh", Refresh);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("availableSpaceInBytes").ToLocalChecked(), AvailableSpaceInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("capacityInBytes").ToLocalChecked(), CapacityInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("description").ToLocalChecked(), DescriptionGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("name").ToLocalChecked(), NameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("serialNumber").ToLocalChecked(), SerialNumberGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("storageMediumType").ToLocalChecked(), StorageMediumTypeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("supportedAccessMode").ToLocalChecked(), SupportedAccessModeGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportStorageMedium").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportStorageMedium(::Windows::Media::Import::PhotoImportStorageMedium^ 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::Import::PhotoImportStorageMedium^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportStorageMedium^) 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());

      PhotoImportStorageMedium *wrapperInstance = new PhotoImportStorageMedium(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::Import::PhotoImportStorageMedium^>(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::Import::PhotoImportStorageMedium^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportStorageMedium^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportStorageMedium(winRtInstance));
    }


    static void Refresh(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Refresh();
          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 AvailableSpaceInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->AvailableSpaceInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void CapacityInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->CapacityInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Description;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void NameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Name;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SerialNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->SerialNumber;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StorageMediumTypeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportStorageMediumType result = wrapper->_instance->StorageMediumType;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SupportedAccessModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportStorageMedium^>(info.This())) {
        return;
      }

      PhotoImportStorageMedium *wrapper = PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportAccessMode result = wrapper->_instance->SupportedAccessMode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportStorageMedium^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportStorageMedium(::Windows::Media::Import::PhotoImportStorageMedium^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportStorageMedium^ UnwrapPhotoImportStorageMedium(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportStorageMedium::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportStorageMedium(::Windows::Media::Import::PhotoImportStorageMedium^ 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>(PhotoImportStorageMedium::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportStorageMedium^ UnwrapPhotoImportStorageMedium(Local<Value> value) {
     return PhotoImportStorageMedium::Unwrap<PhotoImportStorageMedium>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportStorageMedium(Local<Object> exports) {
    PhotoImportStorageMedium::Init(exports);
  }

  class PhotoImportSidecar : 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>("PhotoImportSidecar").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("date").ToLocalChecked(), DateGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("name").ToLocalChecked(), NameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sizeInBytes").ToLocalChecked(), SizeInBytesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportSidecar").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportSidecar(::Windows::Media::Import::PhotoImportSidecar^ 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::Import::PhotoImportSidecar^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSidecar^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportSidecar^) 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());

      PhotoImportSidecar *wrapperInstance = new PhotoImportSidecar(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::Import::PhotoImportSidecar^>(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::Import::PhotoImportSidecar^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportSidecar^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportSidecar(winRtInstance));
    }





    static void DateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSidecar^>(info.This())) {
        return;
      }

      PhotoImportSidecar *wrapper = PhotoImportSidecar::Unwrap<PhotoImportSidecar>(info.This());

      try  {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Date;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void NameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSidecar^>(info.This())) {
        return;
      }

      PhotoImportSidecar *wrapper = PhotoImportSidecar::Unwrap<PhotoImportSidecar>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Name;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSidecar^>(info.This())) {
        return;
      }

      PhotoImportSidecar *wrapper = PhotoImportSidecar::Unwrap<PhotoImportSidecar>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportSidecar^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportSidecar(::Windows::Media::Import::PhotoImportSidecar^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportSidecar^ UnwrapPhotoImportSidecar(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportSidecar::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportSidecar(::Windows::Media::Import::PhotoImportSidecar^ 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>(PhotoImportSidecar::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportSidecar^ UnwrapPhotoImportSidecar(Local<Value> value) {
     return PhotoImportSidecar::Unwrap<PhotoImportSidecar>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportSidecar(Local<Object> exports) {
    PhotoImportSidecar::Init(exports);
  }

  class PhotoImportVideoSegment : 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>("PhotoImportVideoSegment").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("date").ToLocalChecked(), DateGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("name").ToLocalChecked(), NameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sibling").ToLocalChecked(), SiblingGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecars").ToLocalChecked(), SidecarsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sizeInBytes").ToLocalChecked(), SizeInBytesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportVideoSegment").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportVideoSegment(::Windows::Media::Import::PhotoImportVideoSegment^ 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::Import::PhotoImportVideoSegment^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportVideoSegment^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportVideoSegment^) 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());

      PhotoImportVideoSegment *wrapperInstance = new PhotoImportVideoSegment(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::Import::PhotoImportVideoSegment^>(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::Import::PhotoImportVideoSegment^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportVideoSegment^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportVideoSegment(winRtInstance));
    }





    static void DateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportVideoSegment^>(info.This())) {
        return;
      }

      PhotoImportVideoSegment *wrapper = PhotoImportVideoSegment::Unwrap<PhotoImportVideoSegment>(info.This());

      try  {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Date;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void NameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportVideoSegment^>(info.This())) {
        return;
      }

      PhotoImportVideoSegment *wrapper = PhotoImportVideoSegment::Unwrap<PhotoImportVideoSegment>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Name;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportVideoSegment^>(info.This())) {
        return;
      }

      PhotoImportVideoSegment *wrapper = PhotoImportVideoSegment::Unwrap<PhotoImportVideoSegment>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSidecar^ result = wrapper->_instance->Sibling;
        info.GetReturnValue().Set(WrapPhotoImportSidecar(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportVideoSegment^>(info.This())) {
        return;
      }

      PhotoImportVideoSegment *wrapper = PhotoImportVideoSegment::Unwrap<PhotoImportVideoSegment>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportSidecar^>^ result = wrapper->_instance->Sidecars;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportSidecar^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportSidecar^ val) -> Local<Value> {
              return WrapPhotoImportSidecar(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSidecar^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportSidecar^ {
              return UnwrapPhotoImportSidecar(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportVideoSegment^>(info.This())) {
        return;
      }

      PhotoImportVideoSegment *wrapper = PhotoImportVideoSegment::Unwrap<PhotoImportVideoSegment>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportVideoSegment^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportVideoSegment(::Windows::Media::Import::PhotoImportVideoSegment^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportVideoSegment^ UnwrapPhotoImportVideoSegment(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportVideoSegment::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportVideoSegment(::Windows::Media::Import::PhotoImportVideoSegment^ 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>(PhotoImportVideoSegment::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportVideoSegment^ UnwrapPhotoImportVideoSegment(Local<Value> value) {
     return PhotoImportVideoSegment::Unwrap<PhotoImportVideoSegment>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportVideoSegment(Local<Object> exports) {
    PhotoImportVideoSegment::Init(exports);
  }

  class PhotoImportItem : 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>("PhotoImportItem").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isSelected").ToLocalChecked(), IsSelectedGetter, IsSelectedSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("contentType").ToLocalChecked(), ContentTypeGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("date").ToLocalChecked(), DateGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("deletedFileNames").ToLocalChecked(), DeletedFileNamesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("importedFileNames").ToLocalChecked(), ImportedFileNamesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("itemKey").ToLocalChecked(), ItemKeyGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("name").ToLocalChecked(), NameGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sibling").ToLocalChecked(), SiblingGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sidecars").ToLocalChecked(), SidecarsGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sizeInBytes").ToLocalChecked(), SizeInBytesGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnail").ToLocalChecked(), ThumbnailGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("videoSegments").ToLocalChecked(), VideoSegmentsGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportItem").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportItem(::Windows::Media::Import::PhotoImportItem^ 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::Import::PhotoImportItem^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportItem^) 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());

      PhotoImportItem *wrapperInstance = new PhotoImportItem(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::Import::PhotoImportItem^>(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::Import::PhotoImportItem^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportItem^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportItem(winRtInstance));
    }





    static void IsSelectedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        bool result = wrapper->_instance->IsSelected;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsSelectedSetter(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::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsSelected = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ContentTypeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportContentType result = wrapper->_instance->ContentType;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Date;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DeletedFileNamesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result = wrapper->_instance->DeletedFileNames;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Platform::String^>::CreateVectorViewWrapper(result, 
            [](::Platform::String^ val) -> Local<Value> {
              return NodeRT::Utils::NewString(val->Data());
            },
            [](Local<Value> value) -> bool {
              return value->IsString();
            },
            [](Local<Value> value) -> ::Platform::String^ {
              return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ImportedFileNamesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result = wrapper->_instance->ImportedFileNames;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Platform::String^>::CreateVectorViewWrapper(result, 
            [](::Platform::String^ val) -> Local<Value> {
              return NodeRT::Utils::NewString(val->Data());
            },
            [](Local<Value> value) -> bool {
              return value->IsString();
            },
            [](Local<Value> value) -> ::Platform::String^ {
              return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ItemKeyGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->ItemKey;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void NameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Name;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SiblingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportSidecar^ result = wrapper->_instance->Sibling;
        info.GetReturnValue().Set(WrapPhotoImportSidecar(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SidecarsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportSidecar^>^ result = wrapper->_instance->Sidecars;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportSidecar^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportSidecar^ val) -> Local<Value> {
              return WrapPhotoImportSidecar(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSidecar^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportSidecar^ {
              return UnwrapPhotoImportSidecar(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SizeInBytesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        unsigned __int64 result = wrapper->_instance->SizeInBytes;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ThumbnailGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Storage::Streams::IRandomAccessStreamReference^ result = wrapper->_instance->Thumbnail;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage.Streams", "IRandomAccessStreamReference", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void VideoSegmentsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItem^>(info.This())) {
        return;
      }

      PhotoImportItem *wrapper = PhotoImportItem::Unwrap<PhotoImportItem>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Windows::Media::Import::PhotoImportVideoSegment^>^ result = wrapper->_instance->VideoSegments;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Windows::Media::Import::PhotoImportVideoSegment^>::CreateVectorViewWrapper(result, 
            [](::Windows::Media::Import::PhotoImportVideoSegment^ val) -> Local<Value> {
              return WrapPhotoImportVideoSegment(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportVideoSegment^>(value);
            },
            [](Local<Value> value) -> ::Windows::Media::Import::PhotoImportVideoSegment^ {
              return UnwrapPhotoImportVideoSegment(value);
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportItem^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportItem(::Windows::Media::Import::PhotoImportItem^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportItem^ UnwrapPhotoImportItem(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportItem::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportItem(::Windows::Media::Import::PhotoImportItem^ 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>(PhotoImportItem::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportItem^ UnwrapPhotoImportItem(Local<Value> value) {
     return PhotoImportItem::Unwrap<PhotoImportItem>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportItem(Local<Object> exports) {
    PhotoImportItem::Init(exports);
  }

  class PhotoImportSelectionChangedEventArgs : 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>("PhotoImportSelectionChangedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isSelectionEmpty").ToLocalChecked(), IsSelectionEmptyGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportSelectionChangedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportSelectionChangedEventArgs(::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ 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::Import::PhotoImportSelectionChangedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^) 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());

      PhotoImportSelectionChangedEventArgs *wrapperInstance = new PhotoImportSelectionChangedEventArgs(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::Import::PhotoImportSelectionChangedEventArgs^>(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::Import::PhotoImportSelectionChangedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportSelectionChangedEventArgs(winRtInstance));
    }





    static void IsSelectionEmptyGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^>(info.This())) {
        return;
      }

      PhotoImportSelectionChangedEventArgs *wrapper = PhotoImportSelectionChangedEventArgs::Unwrap<PhotoImportSelectionChangedEventArgs>(info.This());

      try  {
        bool result = wrapper->_instance->IsSelectionEmpty;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportSelectionChangedEventArgs(::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ UnwrapPhotoImportSelectionChangedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportSelectionChangedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportSelectionChangedEventArgs(::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ 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>(PhotoImportSelectionChangedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportSelectionChangedEventArgs^ UnwrapPhotoImportSelectionChangedEventArgs(Local<Value> value) {
     return PhotoImportSelectionChangedEventArgs::Unwrap<PhotoImportSelectionChangedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportSelectionChangedEventArgs(Local<Object> exports) {
    PhotoImportSelectionChangedEventArgs::Init(exports);
  }

  class PhotoImportItemImportedEventArgs : 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>("PhotoImportItemImportedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("importedItem").ToLocalChecked(), ImportedItemGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("PhotoImportItemImportedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      PhotoImportItemImportedEventArgs(::Windows::Media::Import::PhotoImportItemImportedEventArgs^ 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::Import::PhotoImportItemImportedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItemImportedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Media::Import::PhotoImportItemImportedEventArgs^) 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());

      PhotoImportItemImportedEventArgs *wrapperInstance = new PhotoImportItemImportedEventArgs(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::Import::PhotoImportItemImportedEventArgs^>(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::Import::PhotoImportItemImportedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Media::Import::PhotoImportItemImportedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapPhotoImportItemImportedEventArgs(winRtInstance));
    }





    static void ImportedItemGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Media::Import::PhotoImportItemImportedEventArgs^>(info.This())) {
        return;
      }

      PhotoImportItemImportedEventArgs *wrapper = PhotoImportItemImportedEventArgs::Unwrap<PhotoImportItemImportedEventArgs>(info.This());

      try  {
        ::Windows::Media::Import::PhotoImportItem^ result = wrapper->_instance->ImportedItem;
        info.GetReturnValue().Set(WrapPhotoImportItem(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Media::Import::PhotoImportItemImportedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapPhotoImportItemImportedEventArgs(::Windows::Media::Import::PhotoImportItemImportedEventArgs^ wintRtInstance);
      friend ::Windows::Media::Import::PhotoImportItemImportedEventArgs^ UnwrapPhotoImportItemImportedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> PhotoImportItemImportedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapPhotoImportItemImportedEventArgs(::Windows::Media::Import::PhotoImportItemImportedEventArgs^ 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>(PhotoImportItemImportedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Media::Import::PhotoImportItemImportedEventArgs^ UnwrapPhotoImportItemImportedEventArgs(Local<Value> value) {
     return PhotoImportItemImportedEventArgs::Unwrap<PhotoImportItemImportedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitPhotoImportItemImportedEventArgs(Local<Object> exports) {
    PhotoImportItemImportedEventArgs::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::Import::InitPhotoImportStageEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportAccessModeEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportImportModeEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportSourceTypeEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportContentTypeEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportPowerSourceEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportStorageMediumTypeEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportContentTypeFilterEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportItemSelectionModeEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportSubfolderDateFormatEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportConnectionTransportEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportSubfolderCreationModeEnum(target);
      NodeRT::Windows::Media::Import::InitPhotoImportSource(target);
      NodeRT::Windows::Media::Import::InitPhotoImportOperation(target);
      NodeRT::Windows::Media::Import::InitPhotoImportManager(target);
      NodeRT::Windows::Media::Import::InitPhotoImportSession(target);
      NodeRT::Windows::Media::Import::InitPhotoImportFindItemsResult(target);
      NodeRT::Windows::Media::Import::InitPhotoImportImportItemsResult(target);
      NodeRT::Windows::Media::Import::InitPhotoImportDeleteImportedItemsFromSourceResult(target);
      NodeRT::Windows::Media::Import::InitPhotoImportStorageMedium(target);
      NodeRT::Windows::Media::Import::InitPhotoImportSidecar(target);
      NodeRT::Windows::Media::Import::InitPhotoImportVideoSegment(target);
      NodeRT::Windows::Media::Import::InitPhotoImportItem(target);
      NodeRT::Windows::Media::Import::InitPhotoImportSelectionChangedEventArgs(target);
      NodeRT::Windows::Media::Import::InitPhotoImportItemImportedEventArgs(target);


  NodeRT::Utils::RegisterNameSpace("Windows.Media.Import", target);
}



NODE_MODULE(binding, init)
