// Copyright (c) Microsoft Corporation
// 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::Handle;
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 ApplicationModel { namespace Appointments { 

  v8::Local<v8::Value> WrapAppointment(::Windows::ApplicationModel::Appointments::Appointment^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::Appointment^ UnwrapAppointment(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentStore(::Windows::ApplicationModel::Appointments::AppointmentStore^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentStore^ UnwrapAppointmentStore(Local<Value> value);
  
  v8::Local<v8::Value> WrapIAppointmentParticipant(::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ UnwrapIAppointmentParticipant(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentOrganizer(::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ UnwrapAppointmentOrganizer(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentInvitee(::Windows::ApplicationModel::Appointments::AppointmentInvitee^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentInvitee^ UnwrapAppointmentInvitee(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentRecurrence(::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ UnwrapAppointmentRecurrence(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentManager(::Windows::ApplicationModel::Appointments::AppointmentManager^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentManager^ UnwrapAppointmentManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapFindAppointmentsOptions(::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ UnwrapFindAppointmentsOptions(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentException(::Windows::ApplicationModel::Appointments::AppointmentException^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentException^ UnwrapAppointmentException(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentCalendarSyncManager(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ UnwrapAppointmentCalendarSyncManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentCalendar(::Windows::ApplicationModel::Appointments::AppointmentCalendar^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentCalendar^ UnwrapAppointmentCalendar(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentStoreChange(::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ UnwrapAppointmentStoreChange(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentStoreChangeReader(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ UnwrapAppointmentStoreChangeReader(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentStoreChangedDeferral(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ UnwrapAppointmentStoreChangedDeferral(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentStoreChangeTracker(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ UnwrapAppointmentStoreChangeTracker(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentConflictResult(::Windows::ApplicationModel::Appointments::AppointmentConflictResult^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentConflictResult^ UnwrapAppointmentConflictResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentStoreChangedEventArgs(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ UnwrapAppointmentStoreChangedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentProperties(::Windows::ApplicationModel::Appointments::AppointmentProperties^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentProperties^ UnwrapAppointmentProperties(Local<Value> value);
  
  v8::Local<v8::Value> WrapAppointmentStoreNotificationTriggerDetails(::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ wintRtInstance);
  ::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ UnwrapAppointmentStoreNotificationTriggerDetails(Local<Value> value);
  


  static void InitAppointmentStoreAccessTypeEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentStoreAccessType").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("appCalendarsReadWrite").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreAccessType::AppCalendarsReadWrite)));
	Nan::Set(enumObject, Nan::New<String>("allCalendarsReadOnly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreAccessType::AllCalendarsReadOnly)));
	Nan::Set(enumObject, Nan::New<String>("allCalendarsReadWrite").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreAccessType::AllCalendarsReadWrite)));
  }


  static void InitAppointmentSensitivityEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentSensitivity").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("public").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentSensitivity::Public)));
	Nan::Set(enumObject, Nan::New<String>("private").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentSensitivity::Private)));
  }


  static void InitAppointmentBusyStatusEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentBusyStatus").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("busy").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentBusyStatus::Busy)));
	Nan::Set(enumObject, Nan::New<String>("tentative").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentBusyStatus::Tentative)));
	Nan::Set(enumObject, Nan::New<String>("free").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentBusyStatus::Free)));
	Nan::Set(enumObject, Nan::New<String>("outOfOffice").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentBusyStatus::OutOfOffice)));
	Nan::Set(enumObject, Nan::New<String>("workingElsewhere").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentBusyStatus::WorkingElsewhere)));
  }


  static void InitAppointmentParticipantResponseEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentParticipantResponse").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse::None)));
	Nan::Set(enumObject, Nan::New<String>("tentative").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse::Tentative)));
	Nan::Set(enumObject, Nan::New<String>("accepted").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse::Accepted)));
	Nan::Set(enumObject, Nan::New<String>("declined").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse::Declined)));
	Nan::Set(enumObject, Nan::New<String>("unknown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse::Unknown)));
  }


  static void InitAppointmentParticipantRoleEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentParticipantRole").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("requiredAttendee").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantRole::RequiredAttendee)));
	Nan::Set(enumObject, Nan::New<String>("optionalAttendee").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantRole::OptionalAttendee)));
	Nan::Set(enumObject, Nan::New<String>("resource").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentParticipantRole::Resource)));
  }


  static void InitAppointmentRecurrenceUnitEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentRecurrenceUnit").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("daily").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit::Daily)));
	Nan::Set(enumObject, Nan::New<String>("weekly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit::Weekly)));
	Nan::Set(enumObject, Nan::New<String>("monthly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit::Monthly)));
	Nan::Set(enumObject, Nan::New<String>("monthlyOnDay").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit::MonthlyOnDay)));
	Nan::Set(enumObject, Nan::New<String>("yearly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit::Yearly)));
	Nan::Set(enumObject, Nan::New<String>("yearlyOnDay").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit::YearlyOnDay)));
  }


  static void InitAppointmentDaysOfWeekEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentDaysOfWeek").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::None)));
	Nan::Set(enumObject, Nan::New<String>("sunday").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::Sunday)));
	Nan::Set(enumObject, Nan::New<String>("monday").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::Monday)));
	Nan::Set(enumObject, Nan::New<String>("tuesday").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::Tuesday)));
	Nan::Set(enumObject, Nan::New<String>("wednesday").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::Wednesday)));
	Nan::Set(enumObject, Nan::New<String>("thursday").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::Thursday)));
	Nan::Set(enumObject, Nan::New<String>("friday").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::Friday)));
	Nan::Set(enumObject, Nan::New<String>("saturday").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek::Saturday)));
  }


  static void InitAppointmentWeekOfMonthEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentWeekOfMonth").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("first").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth::First)));
	Nan::Set(enumObject, Nan::New<String>("second").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth::Second)));
	Nan::Set(enumObject, Nan::New<String>("third").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth::Third)));
	Nan::Set(enumObject, Nan::New<String>("fourth").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth::Fourth)));
	Nan::Set(enumObject, Nan::New<String>("last").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth::Last)));
  }


  static void InitAppointmentCalendarSyncStatusEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentCalendarSyncStatus").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("idle").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus::Idle)));
	Nan::Set(enumObject, Nan::New<String>("syncing").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus::Syncing)));
	Nan::Set(enumObject, Nan::New<String>("upToDate").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus::UpToDate)));
	Nan::Set(enumObject, Nan::New<String>("authenticationError").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus::AuthenticationError)));
	Nan::Set(enumObject, Nan::New<String>("policyError").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus::PolicyError)));
	Nan::Set(enumObject, Nan::New<String>("unknownError").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus::UnknownError)));
	Nan::Set(enumObject, Nan::New<String>("manualAccountRemovalRequired").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus::ManualAccountRemovalRequired)));
  }


  static void InitRecurrenceTypeEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("RecurrenceType").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("master").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::RecurrenceType::Master)));
	Nan::Set(enumObject, Nan::New<String>("instance").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::RecurrenceType::Instance)));
	Nan::Set(enumObject, Nan::New<String>("exceptionInstance").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::RecurrenceType::ExceptionInstance)));
  }


  static void InitAppointmentDetailsKindEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentDetailsKind").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("plainText").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDetailsKind::PlainText)));
	Nan::Set(enumObject, Nan::New<String>("html").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentDetailsKind::Html)));
  }


  static void InitFindAppointmentCalendarsOptionsEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("FindAppointmentCalendarsOptions").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::FindAppointmentCalendarsOptions::None)));
	Nan::Set(enumObject, Nan::New<String>("includeHidden").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::FindAppointmentCalendarsOptions::IncludeHidden)));
  }


  static void InitAppointmentSummaryCardViewEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentSummaryCardView").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("system").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentSummaryCardView::System)));
	Nan::Set(enumObject, Nan::New<String>("app").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentSummaryCardView::App)));
  }


  static void InitAppointmentCalendarOtherAppReadAccessEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentCalendarOtherAppReadAccess").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("systemOnly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppReadAccess::SystemOnly)));
	Nan::Set(enumObject, Nan::New<String>("limited").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppReadAccess::Limited)));
	Nan::Set(enumObject, Nan::New<String>("full").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppReadAccess::Full)));
  }


  static void InitAppointmentCalendarOtherAppWriteAccessEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentCalendarOtherAppWriteAccess").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppWriteAccess::None)));
	Nan::Set(enumObject, Nan::New<String>("systemOnly").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppWriteAccess::SystemOnly)));
  }


  static void InitAppointmentConflictTypeEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentConflictType").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("none").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentConflictType::None)));
	Nan::Set(enumObject, Nan::New<String>("adjacent").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentConflictType::Adjacent)));
	Nan::Set(enumObject, Nan::New<String>("overlap").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentConflictType::Overlap)));
  }


  static void InitAppointmentStoreChangeTypeEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("AppointmentStoreChangeType").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("appointmentCreated").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType::AppointmentCreated)));
	Nan::Set(enumObject, Nan::New<String>("appointmentModified").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType::AppointmentModified)));
	Nan::Set(enumObject, Nan::New<String>("appointmentDeleted").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType::AppointmentDeleted)));
	Nan::Set(enumObject, Nan::New<String>("changeTrackingLost").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType::ChangeTrackingLost)));
	Nan::Set(enumObject, Nan::New<String>("calendarCreated").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType::CalendarCreated)));
	Nan::Set(enumObject, Nan::New<String>("calendarModified").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType::CalendarModified)));
	Nan::Set(enumObject, Nan::New<String>("calendarDeleted").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType::CalendarDeleted)));
  }



  
  static bool IsRectJsObject(Local<Value> value)
  {
    if (!value->IsObject())
    {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Foundation::Rect RectFromJsObject(Local<Value> value)
  {
    HandleScope scope;
    ::Windows::Foundation::Rect returnValue;
    
    if (!value->IsObject())
    {
      Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object")));
      return returnValue;
    }

    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();
    Local<String> symbol;

    return returnValue;
  }

  Local<Value> RectToJsObject(::Windows::Foundation::Rect value)
  {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();

    
    return scope.Escape(obj);
  }

  
  static bool IsColorJsObject(Local<Value> value)
  {
    if (!value->IsObject())
    {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::UI::Color ColorFromJsObject(Local<Value> value)
  {
    HandleScope scope;
    ::Windows::UI::Color returnValue;
    
    if (!value->IsObject())
    {
      Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object")));
      return returnValue;
    }

    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();
    Local<String> symbol;

    return returnValue;
  }

  Local<Value> ColorToJsObject(::Windows::UI::Color value)
  {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();

    
    return scope.Escape(obj);
  }

  
  class Appointment : 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>("Appointment").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("location").ToLocalChecked(), LocationGetter, LocationSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("allDay").ToLocalChecked(), AllDayGetter, AllDaySetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("organizer").ToLocalChecked(), OrganizerGetter, OrganizerSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("duration").ToLocalChecked(), DurationGetter, DurationSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("details").ToLocalChecked(), DetailsGetter, DetailsSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("uri").ToLocalChecked(), UriGetter, UriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("busyStatus").ToLocalChecked(), BusyStatusGetter, BusyStatusSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("recurrence").ToLocalChecked(), RecurrenceGetter, RecurrenceSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("subject").ToLocalChecked(), SubjectGetter, SubjectSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("startTime").ToLocalChecked(), StartTimeGetter, StartTimeSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sensitivity").ToLocalChecked(), SensitivityGetter, SensitivitySetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("reminder").ToLocalChecked(), ReminderGetter, ReminderSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("invitees").ToLocalChecked(), InviteesGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("allowNewTimeProposal").ToLocalChecked(), AllowNewTimeProposalGetter, AllowNewTimeProposalSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("userResponse").ToLocalChecked(), UserResponseGetter, UserResponseSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("roamingId").ToLocalChecked(), RoamingIdGetter, RoamingIdSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("replyTime").ToLocalChecked(), ReplyTimeGetter, ReplyTimeSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isResponseRequested").ToLocalChecked(), IsResponseRequestedGetter, IsResponseRequestedSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isOrganizedByUser").ToLocalChecked(), IsOrganizedByUserGetter, IsOrganizedByUserSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isCanceledMeeting").ToLocalChecked(), IsCanceledMeetingGetter, IsCanceledMeetingSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("onlineMeetingLink").ToLocalChecked(), OnlineMeetingLinkGetter, OnlineMeetingLinkSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("hasInvitees").ToLocalChecked(), HasInviteesGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("calendarId").ToLocalChecked(), CalendarIdGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("localId").ToLocalChecked(), LocalIdGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("originalStartTime").ToLocalChecked(), OriginalStartTimeGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("remoteChangeNumber").ToLocalChecked(), RemoteChangeNumberGetter, RemoteChangeNumberSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("detailsKind").ToLocalChecked(), DetailsKindGetter, DetailsKindSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("changeNumber").ToLocalChecked(), ChangeNumberGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("Appointment").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    Appointment(::Windows::ApplicationModel::Appointments::Appointment^ 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::ApplicationModel::Appointments::Appointment^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::Appointment^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::Appointments::Appointment();
        }
        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());

      Appointment *wrapperInstance = new Appointment(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::ApplicationModel::Appointments::Appointment^>(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::ApplicationModel::Appointments::Appointment^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::Appointment^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointment(winRtInstance));
    }


  



    static void LocationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Location;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void LocationSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Location = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void AllDayGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        bool result = wrapper->_instance->AllDay;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllDaySetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AllDay = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void OrganizerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ result = wrapper->_instance->Organizer;
        info.GetReturnValue().Set(WrapAppointmentOrganizer(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OrganizerSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentOrganizer^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ winRtValue = dynamic_cast<::Windows::ApplicationModel::Appointments::AppointmentOrganizer^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->Organizer = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DurationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::Foundation::TimeSpan result = wrapper->_instance->Duration;
        info.GetReturnValue().Set(Nan::New<Number>(result.Duration/10000.0));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DurationSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsNumber())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::Foundation::TimeSpan winRtValue = NodeRT::Utils::TimeSpanFromMilli(Nan::To<int64_t>(value).FromMaybe(0));

        wrapper->_instance->Duration = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DetailsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Details;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DetailsSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Details = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void UriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->Uri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void UriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->Uri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void BusyStatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentBusyStatus result = wrapper->_instance->BusyStatus;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void BusyStatusSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentBusyStatus winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentBusyStatus>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->BusyStatus = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void RecurrenceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ result = wrapper->_instance->Recurrence;
        info.GetReturnValue().Set(WrapAppointmentRecurrence(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RecurrenceSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ winRtValue = dynamic_cast<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->Recurrence = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void SubjectGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Subject;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SubjectSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Subject = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void StartTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::Foundation::DateTime result = wrapper->_instance->StartTime;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void StartTimeSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsDate())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::Foundation::DateTime winRtValue = NodeRT::Utils::DateTimeFromJSDate(value);

        wrapper->_instance->StartTime = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void SensitivityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentSensitivity result = wrapper->_instance->Sensitivity;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SensitivitySetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentSensitivity winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentSensitivity>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Sensitivity = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ReminderGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Platform::IBox<::Windows::Foundation::TimeSpan>^ result = wrapper->_instance->Reminder;
        info.GetReturnValue().Set(result ? static_cast<Local<Value>>(Nan::New<Number>(result->Value.Duration/10000.0)) : Undefined());
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ReminderSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsNumber())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Platform::IBox<::Windows::Foundation::TimeSpan>^ winRtValue = ref new ::Platform::Box<::Windows::Foundation::TimeSpan>(NodeRT::Utils::TimeSpanFromMilli(Nan::To<int64_t>(value).FromMaybe(0)));

        wrapper->_instance->Reminder = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void InviteesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::Foundation::Collections::IVector<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>^ result = wrapper->_instance->Invitees;
        info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>::CreateVectorWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::AppointmentInvitee^ val) -> Local<Value> {
              return WrapAppointmentInvitee(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::AppointmentInvitee^ {
              return UnwrapAppointmentInvitee(value);
            }
          ));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllowNewTimeProposalGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        bool result = wrapper->_instance->AllowNewTimeProposal;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllowNewTimeProposalSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AllowNewTimeProposal = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void UserResponseGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse result = wrapper->_instance->UserResponse;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void UserResponseSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->UserResponse = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void RoamingIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->RoamingId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RoamingIdSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->RoamingId = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ReplyTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Platform::IBox<::Windows::Foundation::DateTime>^ result = wrapper->_instance->ReplyTime;
        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 ReplyTimeSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsDate())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Platform::IBox<::Windows::Foundation::DateTime>^ winRtValue = ref new ::Platform::Box<::Windows::Foundation::DateTime>(NodeRT::Utils::DateTimeFromJSDate(value));

        wrapper->_instance->ReplyTime = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IsResponseRequestedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsResponseRequested;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsResponseRequestedSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsResponseRequested = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IsOrganizedByUserGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsOrganizedByUser;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsOrganizedByUserSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsOrganizedByUser = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IsCanceledMeetingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsCanceledMeeting;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsCanceledMeetingSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsCanceledMeeting = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void OnlineMeetingLinkGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->OnlineMeetingLink;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OnlineMeetingLinkSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->OnlineMeetingLink = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void HasInviteesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        bool result = wrapper->_instance->HasInvitees;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CalendarIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->CalendarId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void LocalIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->LocalId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OriginalStartTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Platform::IBox<::Windows::Foundation::DateTime>^ result = wrapper->_instance->OriginalStartTime;
        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 RemoteChangeNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        unsigned __int64 result = wrapper->_instance->RemoteChangeNumber;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RemoteChangeNumberSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsNumber())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        unsigned __int64 winRtValue = static_cast<unsigned __int64>(Nan::To<int64_t>(value).FromMaybe(0));

        wrapper->_instance->RemoteChangeNumber = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DetailsKindGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentDetailsKind result = wrapper->_instance->DetailsKind;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DetailsKindSetter(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::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentDetailsKind winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentDetailsKind>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->DetailsKind = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ChangeNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info.This()))
      {
        return;
      }

      Appointment *wrapper = Appointment::Unwrap<Appointment>(info.This());

      try 
      {
        unsigned __int64 result = wrapper->_instance->ChangeNumber;
        info.GetReturnValue().Set(Nan::New<Number>(static_cast<double>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::Appointment^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointment(::Windows::ApplicationModel::Appointments::Appointment^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::Appointment^ UnwrapAppointment(Local<Value> value);
  };
  Persistent<FunctionTemplate> Appointment::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointment(::Windows::ApplicationModel::Appointments::Appointment^ 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>(Appointment::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::Appointment^ UnwrapAppointment(Local<Value> value)
  {
     return Appointment::Unwrap<Appointment>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointment(Local<Object> exports)
  {
    Appointment::Init(exports);
  }

  class AppointmentStore : 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>("AppointmentStore").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
      Local<Function> func;
      Local<FunctionTemplate> funcTemplate;
                  
      Nan::SetPrototypeMethod(localRef, "createAppointmentCalendarAsync", CreateAppointmentCalendarAsync);
      Nan::SetPrototypeMethod(localRef, "getAppointmentCalendarAsync", GetAppointmentCalendarAsync);
      Nan::SetPrototypeMethod(localRef, "getAppointmentAsync", GetAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "getAppointmentInstanceAsync", GetAppointmentInstanceAsync);
      Nan::SetPrototypeMethod(localRef, "findAppointmentCalendarsAsync", FindAppointmentCalendarsAsync);
      Nan::SetPrototypeMethod(localRef, "findAppointmentsAsync", FindAppointmentsAsync);
      Nan::SetPrototypeMethod(localRef, "findConflictAsync", FindConflictAsync);
      Nan::SetPrototypeMethod(localRef, "moveAppointmentAsync", MoveAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "showAddAppointmentAsync", ShowAddAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "showReplaceAppointmentAsync", ShowReplaceAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "showRemoveAppointmentAsync", ShowRemoveAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "showAppointmentDetailsAsync", ShowAppointmentDetailsAsync);
      Nan::SetPrototypeMethod(localRef, "showEditNewAppointmentAsync", ShowEditNewAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "findLocalIdsFromRoamingIdAsync", FindLocalIdsFromRoamingIdAsync);
      
            
      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>("changeTracker").ToLocalChecked(), ChangeTrackerGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentStore").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentStore(::Windows::ApplicationModel::Appointments::AppointmentStore^ 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::ApplicationModel::Appointments::AppointmentStore^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStore^) 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());

      AppointmentStore *wrapperInstance = new AppointmentStore(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::ApplicationModel::Appointments::AppointmentStore^>(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::ApplicationModel::Appointments::AppointmentStore^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStore^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentStore(winRtInstance));
    }


    static void CreateAppointmentCalendarAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->CreateAppointmentCalendarAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 3
        && info[0]->IsString()
        && info[1]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[1])));
          
          op = wrapper->_instance->CreateAppointmentCalendarAsync(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::ApplicationModel::Appointments::AppointmentCalendar^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointmentCalendar(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 GetAppointmentCalendarAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->GetAppointmentCalendarAsync(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::ApplicationModel::Appointments::AppointmentCalendar^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointmentCalendar(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 GetAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::Appointments::Appointment^>^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->GetAppointmentAsync(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::ApplicationModel::Appointments::Appointment^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointment(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 GetAppointmentInstanceAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::Appointments::Appointment^>^ op;
    

      if (info.Length() == 3
        && info[0]->IsString()
        && info[1]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          
          op = wrapper->_instance->GetAppointmentInstanceAsync(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::ApplicationModel::Appointments::Appointment^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointment(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 FindAppointmentCalendarsAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>^>^ op;
    

      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->FindAppointmentCalendarsAsync();
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 2
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::FindAppointmentCalendarsOptions arg0 = static_cast<::Windows::ApplicationModel::Appointments::FindAppointmentCalendarsOptions>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          op = wrapper->_instance->FindAppointmentCalendarsAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>::CreateVectorViewWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::AppointmentCalendar^ val) -> Local<Value> {
              return WrapAppointmentCalendar(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::AppointmentCalendar^ {
              return UnwrapAppointmentCalendar(value);
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 FindAppointmentsAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::Appointment^>^>^ op;
    

      if (info.Length() == 3
        && 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));
          
          op = wrapper->_instance->FindAppointmentsAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 4
        && info[0]->IsDate()
        && info[1]->IsNumber()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info[2]))
      {
        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));
          ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ arg2 = UnwrapFindAppointmentsOptions(info[2]);
          
          op = wrapper->_instance->FindAppointmentsAsync(arg0,arg1,arg2);
        }
        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::ApplicationModel::Appointments::Appointment^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::ApplicationModel::Appointments::Appointment^>::CreateVectorViewWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::Appointment^ val) -> Local<Value> {
              return WrapAppointment(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::Appointment^ {
              return UnwrapAppointment(value);
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 FindConflictAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::Appointments::AppointmentConflictResult^>^ op;
    

      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          
          op = wrapper->_instance->FindConflictAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 3
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && info[1]->IsDate())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          
          op = wrapper->_instance->FindConflictAsync(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::ApplicationModel::Appointments::AppointmentConflictResult^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointmentConflictResult(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 MoveAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 3
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info[1]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::ApplicationModel::Appointments::AppointmentCalendar^ arg1 = UnwrapAppointmentCalendar(info[1]);
          
          op = wrapper->_instance->MoveAppointmentAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};

		    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
             
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }
    static void ShowAddAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Platform::String^>^ op;
    

      if (info.Length() == 3
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && NodeRT::Utils::IsRect(info[1]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          
          op = wrapper->_instance->ShowAddAppointmentAsync(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<::Platform::String^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Utils::NewString(result->Data());
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 ShowReplaceAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Platform::String^>^ op;
    

      if (info.Length() == 4
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[1])
        && NodeRT::Utils::IsRect(info[2]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::ApplicationModel::Appointments::Appointment^ arg1 = UnwrapAppointment(info[1]);
          ::Windows::Foundation::Rect arg2 = NodeRT::Utils::RectFromJs(info[2]);
          
          op = wrapper->_instance->ShowReplaceAppointmentAsync(arg0,arg1,arg2);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 6
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[1])
        && NodeRT::Utils::IsRect(info[2])
        && info[3]->IsInt32()
        && info[4]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::ApplicationModel::Appointments::Appointment^ arg1 = UnwrapAppointment(info[1]);
          ::Windows::Foundation::Rect arg2 = NodeRT::Utils::RectFromJs(info[2]);
          ::Windows::UI::Popups::Placement arg3 = static_cast<::Windows::UI::Popups::Placement>(Nan::To<int32_t>(info[3]).FromMaybe(0));
          ::Windows::Foundation::DateTime arg4 = NodeRT::Utils::DateTimeFromJSDate(info[4]);
          
          op = wrapper->_instance->ShowReplaceAppointmentAsync(arg0,arg1,arg2,arg3,arg4);
        }
        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<::Platform::String^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Utils::NewString(result->Data());
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 ShowRemoveAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;
    

      if (info.Length() == 3
        && info[0]->IsString()
        && NodeRT::Utils::IsRect(info[1]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          
          op = wrapper->_instance->ShowRemoveAppointmentAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 5
        && info[0]->IsString()
        && NodeRT::Utils::IsRect(info[1])
        && info[2]->IsInt32()
        && info[3]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          ::Windows::UI::Popups::Placement arg2 = static_cast<::Windows::UI::Popups::Placement>(Nan::To<int32_t>(info[2]).FromMaybe(0));
          ::Windows::Foundation::DateTime arg3 = NodeRT::Utils::DateTimeFromJSDate(info[3]);
          
          op = wrapper->_instance->ShowRemoveAppointmentAsync(arg0,arg1,arg2,arg3);
        }
        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) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 ShowAppointmentDetailsAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->ShowAppointmentDetailsAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 3
        && info[0]->IsString()
        && info[1]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          
          op = wrapper->_instance->ShowAppointmentDetailsAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};

		    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
             
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }
    static void ShowEditNewAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Platform::String^>^ op;
    

      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          
          op = wrapper->_instance->ShowEditNewAppointmentAsync(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<::Platform::String^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Utils::NewString(result->Data());
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 FindLocalIdsFromRoamingIdAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Platform::String^>^>^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->FindLocalIdsFromRoamingIdAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Foundation::Collections::IVectorView<::Platform::String^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = 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(value)));
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 ChangeTrackerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(info.This()))
      {
        return;
      }

      AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ result = wrapper->_instance->ChangeTracker;
        info.GetReturnValue().Set(WrapAppointmentStoreChangeTracker(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(info[0]);
      auto str = *eventName;
      
      Local<Function> callback = info[1].As<Function>();
      
      ::Windows::Foundation::EventRegistrationToken registrationToken;
      if (NodeRT::Utils::CaseInsenstiveEquals(L"storeChanged", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
        }
        AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(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->StoreChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::ApplicationModel::Appointments::AppointmentStore^, ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^>(
            [callbackObjPtr](::Windows::ApplicationModel::Appointments::AppointmentStore^ arg0, ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
           	    HandleScope scope;
                TryCatch tryCatch;
              
                Local<Value> error;

                Local<Value> wrappedArg0 = WrapAppointmentStore(arg0);
                Local<Value> wrappedArg1 = WrapAppointmentStoreChangedEventArgs(arg1);

                if (tryCatch.HasCaught())
                {
                  error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
                }
                else 
                {
                  error = Undefined();
                }

				// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
				// can be fixed by wrapping the conversion code in a function and calling it on the fly
				// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
				tryCatch.~TryCatch();


                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(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(info[0]);
      auto str = *eventName;

      if ((NodeRT::Utils::CaseInsenstiveEquals(L"storeChanged", str)))
      {
        Nan::ThrowError(Nan::Error(String::Concat(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"storeChanged", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStore^>(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;
          }
          AppointmentStore *wrapper = AppointmentStore::Unwrap<AppointmentStore>(info.This());
          wrapper->_instance->StoreChanged::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::ApplicationModel::Appointments::AppointmentStore^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentStore(::Windows::ApplicationModel::Appointments::AppointmentStore^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentStore^ UnwrapAppointmentStore(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentStore::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentStore(::Windows::ApplicationModel::Appointments::AppointmentStore^ 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>(AppointmentStore::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentStore^ UnwrapAppointmentStore(Local<Value> value)
  {
     return AppointmentStore::Unwrap<AppointmentStore>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentStore(Local<Object> exports)
  {
    AppointmentStore::Init(exports);
  }

  class IAppointmentParticipant : 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>("IAppointmentParticipant").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("address").ToLocalChecked(), AddressGetter, AddressSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter, DisplayNameSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("IAppointmentParticipant").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    IAppointmentParticipant(::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ 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::ApplicationModel::Appointments::IAppointmentParticipant^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::IAppointmentParticipant^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::IAppointmentParticipant^) 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());

      IAppointmentParticipant *wrapperInstance = new IAppointmentParticipant(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::ApplicationModel::Appointments::IAppointmentParticipant^>(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::ApplicationModel::Appointments::IAppointmentParticipant^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::IAppointmentParticipant^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapIAppointmentParticipant(winRtInstance));
    }


  



    static void AddressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::IAppointmentParticipant^>(info.This()))
      {
        return;
      }

      IAppointmentParticipant *wrapper = IAppointmentParticipant::Unwrap<IAppointmentParticipant>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Address;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AddressSetter(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::ApplicationModel::Appointments::IAppointmentParticipant^>(info.This()))
      {
        return;
      }

      IAppointmentParticipant *wrapper = IAppointmentParticipant::Unwrap<IAppointmentParticipant>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Address = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::IAppointmentParticipant^>(info.This()))
      {
        return;
      }

      IAppointmentParticipant *wrapper = IAppointmentParticipant::Unwrap<IAppointmentParticipant>(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 DisplayNameSetter(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::ApplicationModel::Appointments::IAppointmentParticipant^>(info.This()))
      {
        return;
      }

      IAppointmentParticipant *wrapper = IAppointmentParticipant::Unwrap<IAppointmentParticipant>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->DisplayName = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapIAppointmentParticipant(::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ UnwrapIAppointmentParticipant(Local<Value> value);
  };
  Persistent<FunctionTemplate> IAppointmentParticipant::s_constructorTemplate;

  v8::Local<v8::Value> WrapIAppointmentParticipant(::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ 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>(IAppointmentParticipant::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::IAppointmentParticipant^ UnwrapIAppointmentParticipant(Local<Value> value)
  {
     return IAppointmentParticipant::Unwrap<IAppointmentParticipant>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitIAppointmentParticipant(Local<Object> exports)
  {
    IAppointmentParticipant::Init(exports);
  }

  class AppointmentOrganizer : 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>("AppointmentOrganizer").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter, DisplayNameSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("address").ToLocalChecked(), AddressGetter, AddressSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentOrganizer").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentOrganizer(::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ 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::ApplicationModel::Appointments::AppointmentOrganizer^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentOrganizer^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentOrganizer^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::Appointments::AppointmentOrganizer();
        }
        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());

      AppointmentOrganizer *wrapperInstance = new AppointmentOrganizer(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::ApplicationModel::Appointments::AppointmentOrganizer^>(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::ApplicationModel::Appointments::AppointmentOrganizer^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentOrganizer^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentOrganizer(winRtInstance));
    }


  



    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentOrganizer^>(info.This()))
      {
        return;
      }

      AppointmentOrganizer *wrapper = AppointmentOrganizer::Unwrap<AppointmentOrganizer>(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 DisplayNameSetter(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::ApplicationModel::Appointments::AppointmentOrganizer^>(info.This()))
      {
        return;
      }

      AppointmentOrganizer *wrapper = AppointmentOrganizer::Unwrap<AppointmentOrganizer>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->DisplayName = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void AddressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentOrganizer^>(info.This()))
      {
        return;
      }

      AppointmentOrganizer *wrapper = AppointmentOrganizer::Unwrap<AppointmentOrganizer>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Address;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AddressSetter(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::ApplicationModel::Appointments::AppointmentOrganizer^>(info.This()))
      {
        return;
      }

      AppointmentOrganizer *wrapper = AppointmentOrganizer::Unwrap<AppointmentOrganizer>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Address = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentOrganizer(::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ UnwrapAppointmentOrganizer(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentOrganizer::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentOrganizer(::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ 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>(AppointmentOrganizer::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentOrganizer^ UnwrapAppointmentOrganizer(Local<Value> value)
  {
     return AppointmentOrganizer::Unwrap<AppointmentOrganizer>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentOrganizer(Local<Object> exports)
  {
    AppointmentOrganizer::Init(exports);
  }

  class AppointmentInvitee : 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>("AppointmentInvitee").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("role").ToLocalChecked(), RoleGetter, RoleSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("response").ToLocalChecked(), ResponseGetter, ResponseSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter, DisplayNameSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("address").ToLocalChecked(), AddressGetter, AddressSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentInvitee").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentInvitee(::Windows::ApplicationModel::Appointments::AppointmentInvitee^ 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::ApplicationModel::Appointments::AppointmentInvitee^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentInvitee^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::Appointments::AppointmentInvitee();
        }
        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());

      AppointmentInvitee *wrapperInstance = new AppointmentInvitee(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::ApplicationModel::Appointments::AppointmentInvitee^>(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::ApplicationModel::Appointments::AppointmentInvitee^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentInvitee^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentInvitee(winRtInstance));
    }


  



    static void RoleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentParticipantRole result = wrapper->_instance->Role;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RoleSetter(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::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentParticipantRole winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentParticipantRole>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Role = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ResponseGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse result = wrapper->_instance->Response;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ResponseSetter(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::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Response = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(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 DisplayNameSetter(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::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->DisplayName = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void AddressGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Address;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AddressSetter(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::ApplicationModel::Appointments::AppointmentInvitee^>(info.This()))
      {
        return;
      }

      AppointmentInvitee *wrapper = AppointmentInvitee::Unwrap<AppointmentInvitee>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Address = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::AppointmentInvitee^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentInvitee(::Windows::ApplicationModel::Appointments::AppointmentInvitee^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentInvitee^ UnwrapAppointmentInvitee(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentInvitee::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentInvitee(::Windows::ApplicationModel::Appointments::AppointmentInvitee^ 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>(AppointmentInvitee::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentInvitee^ UnwrapAppointmentInvitee(Local<Value> value)
  {
     return AppointmentInvitee::Unwrap<AppointmentInvitee>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentInvitee(Local<Object> exports)
  {
    AppointmentInvitee::Init(exports);
  }

  class AppointmentRecurrence : 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>("AppointmentRecurrence").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("unit").ToLocalChecked(), UnitGetter, UnitSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("occurrences").ToLocalChecked(), OccurrencesGetter, OccurrencesSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("month").ToLocalChecked(), MonthGetter, MonthSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("interval").ToLocalChecked(), IntervalGetter, IntervalSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("daysOfWeek").ToLocalChecked(), DaysOfWeekGetter, DaysOfWeekSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("day").ToLocalChecked(), DayGetter, DaySetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("weekOfMonth").ToLocalChecked(), WeekOfMonthGetter, WeekOfMonthSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("until").ToLocalChecked(), UntilGetter, UntilSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("timeZone").ToLocalChecked(), TimeZoneGetter, TimeZoneSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("recurrenceType").ToLocalChecked(), RecurrenceTypeGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("calendarIdentifier").ToLocalChecked(), CalendarIdentifierGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentRecurrence").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentRecurrence(::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ 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::ApplicationModel::Appointments::AppointmentRecurrence^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentRecurrence^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::Appointments::AppointmentRecurrence();
        }
        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());

      AppointmentRecurrence *wrapperInstance = new AppointmentRecurrence(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::ApplicationModel::Appointments::AppointmentRecurrence^>(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::ApplicationModel::Appointments::AppointmentRecurrence^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentRecurrence^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentRecurrence(winRtInstance));
    }


  



    static void UnitGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit result = wrapper->_instance->Unit;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void UnitSetter(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::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentRecurrenceUnit>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Unit = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void OccurrencesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        ::Platform::IBox<unsigned int>^ result = wrapper->_instance->Occurrences;
        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 OccurrencesSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsUint32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        ::Platform::IBox<unsigned int>^ winRtValue = ref new ::Platform::Box<unsigned int>(static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0)));

        wrapper->_instance->Occurrences = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void MonthGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        unsigned int result = wrapper->_instance->Month;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void MonthSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsUint32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->Month = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IntervalGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        unsigned int result = wrapper->_instance->Interval;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IntervalSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsUint32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->Interval = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DaysOfWeekGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek result = wrapper->_instance->DaysOfWeek;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DaysOfWeekSetter(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::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentDaysOfWeek>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->DaysOfWeek = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DayGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        unsigned int result = wrapper->_instance->Day;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DaySetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsUint32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->Day = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void WeekOfMonthGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth result = wrapper->_instance->WeekOfMonth;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void WeekOfMonthSetter(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::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentWeekOfMonth>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->WeekOfMonth = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void UntilGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        ::Platform::IBox<::Windows::Foundation::DateTime>^ result = wrapper->_instance->Until;
        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 UntilSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsDate())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        ::Platform::IBox<::Windows::Foundation::DateTime>^ winRtValue = ref new ::Platform::Box<::Windows::Foundation::DateTime>(NodeRT::Utils::DateTimeFromJSDate(value));

        wrapper->_instance->Until = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void TimeZoneGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->TimeZone;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TimeZoneSetter(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::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->TimeZone = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void RecurrenceTypeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::RecurrenceType result = wrapper->_instance->RecurrenceType;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CalendarIdentifierGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentRecurrence^>(info.This()))
      {
        return;
      }

      AppointmentRecurrence *wrapper = AppointmentRecurrence::Unwrap<AppointmentRecurrence>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->CalendarIdentifier;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentRecurrence(::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ UnwrapAppointmentRecurrence(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentRecurrence::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentRecurrence(::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ 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>(AppointmentRecurrence::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentRecurrence^ UnwrapAppointmentRecurrence(Local<Value> value)
  {
     return AppointmentRecurrence::Unwrap<AppointmentRecurrence>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentRecurrence(Local<Object> exports)
  {
    AppointmentRecurrence::Init(exports);
  }

  class AppointmentManager : 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>("AppointmentManager").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);

      func = Nan::GetFunction(Nan::New<FunctionTemplate>(ShowAppointmentDetailsAsync)).ToLocalChecked();
      Nan::Set(constructor, Nan::New<String>("showAppointmentDetailsAsync").ToLocalChecked(), func);
      func = Nan::GetFunction(Nan::New<FunctionTemplate>(ShowEditNewAppointmentAsync)).ToLocalChecked();
      Nan::Set(constructor, Nan::New<String>("showEditNewAppointmentAsync").ToLocalChecked(), func);
      func = Nan::GetFunction(Nan::New<FunctionTemplate>(RequestStoreAsync)).ToLocalChecked();
      Nan::Set(constructor, Nan::New<String>("requestStoreAsync").ToLocalChecked(), func);
      func = Nan::GetFunction(Nan::New<FunctionTemplate>(ShowAddAppointmentAsync)).ToLocalChecked();
      Nan::Set(constructor, Nan::New<String>("showAddAppointmentAsync").ToLocalChecked(), func);
      func = Nan::GetFunction(Nan::New<FunctionTemplate>(ShowReplaceAppointmentAsync)).ToLocalChecked();
      Nan::Set(constructor, Nan::New<String>("showReplaceAppointmentAsync").ToLocalChecked(), func);
      func = Nan::GetFunction(Nan::New<FunctionTemplate>(ShowRemoveAppointmentAsync)).ToLocalChecked();
      Nan::Set(constructor, Nan::New<String>("showRemoveAppointmentAsync").ToLocalChecked(), func);
      func = Nan::GetFunction(Nan::New<FunctionTemplate>(ShowTimeFrameAsync)).ToLocalChecked();
      Nan::Set(constructor, Nan::New<String>("showTimeFrameAsync").ToLocalChecked(), func);

      Nan::Set(exports, Nan::New<String>("AppointmentManager").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentManager(::Windows::ApplicationModel::Appointments::AppointmentManager^ 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::ApplicationModel::Appointments::AppointmentManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentManager^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentManager^) 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());

      AppointmentManager *wrapperInstance = new AppointmentManager(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::ApplicationModel::Appointments::AppointmentManager^>(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::ApplicationModel::Appointments::AppointmentManager^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentManager^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentManager(winRtInstance));
    }


  

    static void ShowAppointmentDetailsAsync(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::IAsyncAction^ op;
      

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowAppointmentDetailsAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 3
        && info[0]->IsString()
        && info[1]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowAppointmentDetailsAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            
            Local<Value> args[] = {Undefined()};

	  	    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
          
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }
    static void ShowEditNewAppointmentAsync(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<::Platform::String^>^ op;
      

      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowEditNewAppointmentAsync(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<::Platform::String^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            
            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Utils::NewString(result->Data());
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

	  	    
            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 RequestStoreAsync(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::ApplicationModel::Appointments::AppointmentStore^>^ op;
      

      if (info.Length() == 2
        && info[0]->IsInt32())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::AppointmentStoreAccessType arg0 = static_cast<::Windows::ApplicationModel::Appointments::AppointmentStoreAccessType>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::RequestStoreAsync(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::ApplicationModel::Appointments::AppointmentStore^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            
            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointmentStore(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

	  	    
            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 ShowAddAppointmentAsync(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<::Platform::String^>^ op;
      

      if (info.Length() == 3
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && NodeRT::Utils::IsRect(info[1]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowAddAppointmentAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 4
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && NodeRT::Utils::IsRect(info[1])
        && info[2]->IsInt32())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          ::Windows::UI::Popups::Placement arg2 = static_cast<::Windows::UI::Popups::Placement>(Nan::To<int32_t>(info[2]).FromMaybe(0));
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowAddAppointmentAsync(arg0,arg1,arg2);
        }
        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<::Platform::String^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            
            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Utils::NewString(result->Data());
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

	  	    
            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 ShowReplaceAppointmentAsync(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<::Platform::String^>^ op;
      

      if (info.Length() == 4
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[1])
        && NodeRT::Utils::IsRect(info[2]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::ApplicationModel::Appointments::Appointment^ arg1 = UnwrapAppointment(info[1]);
          ::Windows::Foundation::Rect arg2 = NodeRT::Utils::RectFromJs(info[2]);
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowReplaceAppointmentAsync(arg0,arg1,arg2);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 5
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[1])
        && NodeRT::Utils::IsRect(info[2])
        && info[3]->IsInt32())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::ApplicationModel::Appointments::Appointment^ arg1 = UnwrapAppointment(info[1]);
          ::Windows::Foundation::Rect arg2 = NodeRT::Utils::RectFromJs(info[2]);
          ::Windows::UI::Popups::Placement arg3 = static_cast<::Windows::UI::Popups::Placement>(Nan::To<int32_t>(info[3]).FromMaybe(0));
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowReplaceAppointmentAsync(arg0,arg1,arg2,arg3);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 6
        && info[0]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[1])
        && NodeRT::Utils::IsRect(info[2])
        && info[3]->IsInt32()
        && info[4]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::ApplicationModel::Appointments::Appointment^ arg1 = UnwrapAppointment(info[1]);
          ::Windows::Foundation::Rect arg2 = NodeRT::Utils::RectFromJs(info[2]);
          ::Windows::UI::Popups::Placement arg3 = static_cast<::Windows::UI::Popups::Placement>(Nan::To<int32_t>(info[3]).FromMaybe(0));
          ::Windows::Foundation::DateTime arg4 = NodeRT::Utils::DateTimeFromJSDate(info[4]);
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowReplaceAppointmentAsync(arg0,arg1,arg2,arg3,arg4);
        }
        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<::Platform::String^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            
            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Utils::NewString(result->Data());
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

	  	    
            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 ShowRemoveAppointmentAsync(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() == 3
        && info[0]->IsString()
        && NodeRT::Utils::IsRect(info[1]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowRemoveAppointmentAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 4
        && info[0]->IsString()
        && NodeRT::Utils::IsRect(info[1])
        && info[2]->IsInt32())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          ::Windows::UI::Popups::Placement arg2 = static_cast<::Windows::UI::Popups::Placement>(Nan::To<int32_t>(info[2]).FromMaybe(0));
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowRemoveAppointmentAsync(arg0,arg1,arg2);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 5
        && info[0]->IsString()
        && NodeRT::Utils::IsRect(info[1])
        && info[2]->IsInt32()
        && info[3]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::Rect arg1 = NodeRT::Utils::RectFromJs(info[1]);
          ::Windows::UI::Popups::Placement arg2 = static_cast<::Windows::UI::Popups::Placement>(Nan::To<int32_t>(info[2]).FromMaybe(0));
          ::Windows::Foundation::DateTime arg3 = NodeRT::Utils::DateTimeFromJSDate(info[3]);
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowRemoveAppointmentAsync(arg0,arg1,arg2,arg3);
        }
        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) {

            
            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

	  	    
            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 ShowTimeFrameAsync(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::IAsyncAction^ op;
      

      if (info.Length() == 3
        && 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));
          
          op = ::Windows::ApplicationModel::Appointments::AppointmentManager::ShowTimeFrameAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            
            Local<Value> args[] = {Undefined()};

	  	    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
          
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }




  private:
    ::Windows::ApplicationModel::Appointments::AppointmentManager^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentManager(::Windows::ApplicationModel::Appointments::AppointmentManager^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentManager^ UnwrapAppointmentManager(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentManager(::Windows::ApplicationModel::Appointments::AppointmentManager^ 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>(AppointmentManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentManager^ UnwrapAppointmentManager(Local<Value> value)
  {
     return AppointmentManager::Unwrap<AppointmentManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentManager(Local<Object> exports)
  {
    AppointmentManager::Init(exports);
  }

  class FindAppointmentsOptions : 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>("FindAppointmentsOptions").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("maxCount").ToLocalChecked(), MaxCountGetter, MaxCountSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("includeHidden").ToLocalChecked(), IncludeHiddenGetter, IncludeHiddenSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("calendarIds").ToLocalChecked(), CalendarIdsGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("fetchProperties").ToLocalChecked(), FetchPropertiesGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("FindAppointmentsOptions").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    FindAppointmentsOptions(::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ 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::ApplicationModel::Appointments::FindAppointmentsOptions^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions();
        }
        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());

      FindAppointmentsOptions *wrapperInstance = new FindAppointmentsOptions(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::ApplicationModel::Appointments::FindAppointmentsOptions^>(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::ApplicationModel::Appointments::FindAppointmentsOptions^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapFindAppointmentsOptions(winRtInstance));
    }


  



    static void MaxCountGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info.This()))
      {
        return;
      }

      FindAppointmentsOptions *wrapper = FindAppointmentsOptions::Unwrap<FindAppointmentsOptions>(info.This());

      try 
      {
        unsigned int result = wrapper->_instance->MaxCount;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void MaxCountSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsUint32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info.This()))
      {
        return;
      }

      FindAppointmentsOptions *wrapper = FindAppointmentsOptions::Unwrap<FindAppointmentsOptions>(info.This());

      try 
      {
        
        unsigned int winRtValue = static_cast<unsigned int>(Nan::To<uint32_t>(value).FromMaybe(0));

        wrapper->_instance->MaxCount = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IncludeHiddenGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info.This()))
      {
        return;
      }

      FindAppointmentsOptions *wrapper = FindAppointmentsOptions::Unwrap<FindAppointmentsOptions>(info.This());

      try 
      {
        bool result = wrapper->_instance->IncludeHidden;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IncludeHiddenSetter(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::ApplicationModel::Appointments::FindAppointmentsOptions^>(info.This()))
      {
        return;
      }

      FindAppointmentsOptions *wrapper = FindAppointmentsOptions::Unwrap<FindAppointmentsOptions>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IncludeHidden = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void CalendarIdsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info.This()))
      {
        return;
      }

      FindAppointmentsOptions *wrapper = FindAppointmentsOptions::Unwrap<FindAppointmentsOptions>(info.This());

      try 
      {
        ::Windows::Foundation::Collections::IVector<::Platform::String^>^ result = wrapper->_instance->CalendarIds;
        info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Platform::String^>::CreateVectorWrapper(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(value)));
            }
          ));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void FetchPropertiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info.This()))
      {
        return;
      }

      FindAppointmentsOptions *wrapper = FindAppointmentsOptions::Unwrap<FindAppointmentsOptions>(info.This());

      try 
      {
        ::Windows::Foundation::Collections::IVector<::Platform::String^>^ result = wrapper->_instance->FetchProperties;
        info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Platform::String^>::CreateVectorWrapper(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(value)));
            }
          ));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapFindAppointmentsOptions(::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ UnwrapFindAppointmentsOptions(Local<Value> value);
  };
  Persistent<FunctionTemplate> FindAppointmentsOptions::s_constructorTemplate;

  v8::Local<v8::Value> WrapFindAppointmentsOptions(::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ 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>(FindAppointmentsOptions::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ UnwrapFindAppointmentsOptions(Local<Value> value)
  {
     return FindAppointmentsOptions::Unwrap<FindAppointmentsOptions>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFindAppointmentsOptions(Local<Object> exports)
  {
    FindAppointmentsOptions::Init(exports);
  }

  class AppointmentException : 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>("AppointmentException").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("appointment").ToLocalChecked(), AppointmentGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("exceptionProperties").ToLocalChecked(), ExceptionPropertiesGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isDeleted").ToLocalChecked(), IsDeletedGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentException").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentException(::Windows::ApplicationModel::Appointments::AppointmentException^ 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::ApplicationModel::Appointments::AppointmentException^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentException^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentException^) 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());

      AppointmentException *wrapperInstance = new AppointmentException(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::ApplicationModel::Appointments::AppointmentException^>(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::ApplicationModel::Appointments::AppointmentException^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentException^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentException(winRtInstance));
    }


  



    static void AppointmentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentException^>(info.This()))
      {
        return;
      }

      AppointmentException *wrapper = AppointmentException::Unwrap<AppointmentException>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::Appointment^ result = wrapper->_instance->Appointment;
        info.GetReturnValue().Set(WrapAppointment(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ExceptionPropertiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentException^>(info.This()))
      {
        return;
      }

      AppointmentException *wrapper = AppointmentException::Unwrap<AppointmentException>(info.This());

      try 
      {
        ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result = wrapper->_instance->ExceptionProperties;
        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(value)));
            }
          ));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsDeletedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentException^>(info.This()))
      {
        return;
      }

      AppointmentException *wrapper = AppointmentException::Unwrap<AppointmentException>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsDeleted;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::AppointmentException^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentException(::Windows::ApplicationModel::Appointments::AppointmentException^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentException^ UnwrapAppointmentException(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentException::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentException(::Windows::ApplicationModel::Appointments::AppointmentException^ 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>(AppointmentException::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentException^ UnwrapAppointmentException(Local<Value> value)
  {
     return AppointmentException::Unwrap<AppointmentException>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentException(Local<Object> exports)
  {
    AppointmentException::Init(exports);
  }

  class AppointmentCalendarSyncManager : 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>("AppointmentCalendarSyncManager").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
      Local<Function> func;
      Local<FunctionTemplate> funcTemplate;
                  
      Nan::SetPrototypeMethod(localRef, "syncAsync", SyncAsync);
      
            
      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>("lastAttemptedSyncTime").ToLocalChecked(), LastAttemptedSyncTimeGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("lastSuccessfulSyncTime").ToLocalChecked(), LastSuccessfulSyncTimeGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentCalendarSyncManager").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentCalendarSyncManager(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ 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::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^) 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());

      AppointmentCalendarSyncManager *wrapperInstance = new AppointmentCalendarSyncManager(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::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(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::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentCalendarSyncManager(winRtInstance));
    }


    static void SyncAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(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;
      }

      AppointmentCalendarSyncManager *wrapper = AppointmentCalendarSyncManager::Unwrap<AppointmentCalendarSyncManager>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;
    

      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->SyncAsync();
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<bool> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 LastAttemptedSyncTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(info.This()))
      {
        return;
      }

      AppointmentCalendarSyncManager *wrapper = AppointmentCalendarSyncManager::Unwrap<AppointmentCalendarSyncManager>(info.This());

      try 
      {
        ::Windows::Foundation::DateTime result = wrapper->_instance->LastAttemptedSyncTime;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void LastSuccessfulSyncTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(info.This()))
      {
        return;
      }

      AppointmentCalendarSyncManager *wrapper = AppointmentCalendarSyncManager::Unwrap<AppointmentCalendarSyncManager>(info.This());

      try 
      {
        ::Windows::Foundation::DateTime result = wrapper->_instance->LastSuccessfulSyncTime;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(info.This()))
      {
        return;
      }

      AppointmentCalendarSyncManager *wrapper = AppointmentCalendarSyncManager::Unwrap<AppointmentCalendarSyncManager>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


    static void 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(info[0]);
      auto str = *eventName;
      
      Local<Function> callback = info[1].As<Function>();
      
      ::Windows::Foundation::EventRegistrationToken registrationToken;
      if (NodeRT::Utils::CaseInsenstiveEquals(L"syncStatusChanged", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(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;
        }
        AppointmentCalendarSyncManager *wrapper = AppointmentCalendarSyncManager::Unwrap<AppointmentCalendarSyncManager>(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->SyncStatusChanged::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^, ::Platform::Object^>(
            [callbackObjPtr](::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ arg0, ::Platform::Object^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
           	    HandleScope scope;
                TryCatch tryCatch;
              
                Local<Value> error;

                Local<Value> wrappedArg0 = WrapAppointmentCalendarSyncManager(arg0);
                Local<Value> wrappedArg1 = CreateOpaqueWrapper(arg1);

                if (tryCatch.HasCaught())
                {
                  error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
                }
                else 
                {
                  error = Undefined();
                }

				// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
				// can be fixed by wrapping the conversion code in a function and calling it on the fly
				// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
				tryCatch.~TryCatch();


                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(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(info[0]);
      auto str = *eventName;

      if ((NodeRT::Utils::CaseInsenstiveEquals(L"syncStatusChanged", str)))
      {
        Nan::ThrowError(Nan::Error(String::Concat(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"syncStatusChanged", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^>(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;
          }
          AppointmentCalendarSyncManager *wrapper = AppointmentCalendarSyncManager::Unwrap<AppointmentCalendarSyncManager>(info.This());
          wrapper->_instance->SyncStatusChanged::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::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentCalendarSyncManager(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ UnwrapAppointmentCalendarSyncManager(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentCalendarSyncManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentCalendarSyncManager(::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ 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>(AppointmentCalendarSyncManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ UnwrapAppointmentCalendarSyncManager(Local<Value> value)
  {
     return AppointmentCalendarSyncManager::Unwrap<AppointmentCalendarSyncManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentCalendarSyncManager(Local<Object> exports)
  {
    AppointmentCalendarSyncManager::Init(exports);
  }

  class AppointmentCalendar : 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>("AppointmentCalendar").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
      Local<Function> func;
      Local<FunctionTemplate> funcTemplate;
                  
      Nan::SetPrototypeMethod(localRef, "findAppointmentsAsync", FindAppointmentsAsync);
      Nan::SetPrototypeMethod(localRef, "findExceptionsFromMasterAsync", FindExceptionsFromMasterAsync);
      Nan::SetPrototypeMethod(localRef, "findAllInstancesAsync", FindAllInstancesAsync);
      Nan::SetPrototypeMethod(localRef, "getAppointmentAsync", GetAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "getAppointmentInstanceAsync", GetAppointmentInstanceAsync);
      Nan::SetPrototypeMethod(localRef, "findUnexpandedAppointmentsAsync", FindUnexpandedAppointmentsAsync);
      Nan::SetPrototypeMethod(localRef, "deleteAsync", DeleteAsync);
      Nan::SetPrototypeMethod(localRef, "saveAsync", SaveAsync);
      Nan::SetPrototypeMethod(localRef, "deleteAppointmentAsync", DeleteAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "deleteAppointmentInstanceAsync", DeleteAppointmentInstanceAsync);
      Nan::SetPrototypeMethod(localRef, "saveAppointmentAsync", SaveAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "tryCreateOrUpdateAppointmentAsync", TryCreateOrUpdateAppointmentAsync);
      Nan::SetPrototypeMethod(localRef, "tryCancelMeetingAsync", TryCancelMeetingAsync);
      Nan::SetPrototypeMethod(localRef, "tryForwardMeetingAsync", TryForwardMeetingAsync);
      Nan::SetPrototypeMethod(localRef, "tryProposeNewTimeForMeetingAsync", TryProposeNewTimeForMeetingAsync);
      Nan::SetPrototypeMethod(localRef, "tryUpdateMeetingResponseAsync", TryUpdateMeetingResponseAsync);
      
                  
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("summaryCardView").ToLocalChecked(), SummaryCardViewGetter, SummaryCardViewSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("otherAppWriteAccess").ToLocalChecked(), OtherAppWriteAccessGetter, OtherAppWriteAccessSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayColor").ToLocalChecked(), DisplayColorGetter, DisplayColorSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isHidden").ToLocalChecked(), IsHiddenGetter, IsHiddenSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter, DisplayNameSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("otherAppReadAccess").ToLocalChecked(), OtherAppReadAccessGetter, OtherAppReadAccessSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("localId").ToLocalChecked(), LocalIdGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sourceDisplayName").ToLocalChecked(), SourceDisplayNameGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("canCancelMeetings").ToLocalChecked(), CanCancelMeetingsGetter, CanCancelMeetingsSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("canNotifyInvitees").ToLocalChecked(), CanNotifyInviteesGetter, CanNotifyInviteesSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("remoteId").ToLocalChecked(), RemoteIdGetter, RemoteIdSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("mustNofityInvitees").ToLocalChecked(), MustNofityInviteesGetter, MustNofityInviteesSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("canUpdateMeetingResponses").ToLocalChecked(), CanUpdateMeetingResponsesGetter, CanUpdateMeetingResponsesSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("canProposeNewTimeForMeetings").ToLocalChecked(), CanProposeNewTimeForMeetingsGetter, CanProposeNewTimeForMeetingsSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("canCreateOrUpdateAppointments").ToLocalChecked(), CanCreateOrUpdateAppointmentsGetter, CanCreateOrUpdateAppointmentsSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("canForwardMeetings").ToLocalChecked(), CanForwardMeetingsGetter, CanForwardMeetingsSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("syncManager").ToLocalChecked(), SyncManagerGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("userDataAccountId").ToLocalChecked(), UserDataAccountIdGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentCalendar").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentCalendar(::Windows::ApplicationModel::Appointments::AppointmentCalendar^ 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::ApplicationModel::Appointments::AppointmentCalendar^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentCalendar^) 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());

      AppointmentCalendar *wrapperInstance = new AppointmentCalendar(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::ApplicationModel::Appointments::AppointmentCalendar^>(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::ApplicationModel::Appointments::AppointmentCalendar^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentCalendar^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentCalendar(winRtInstance));
    }


    static void FindAppointmentsAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::Appointment^>^>^ op;
    

      if (info.Length() == 3
        && 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));
          
          op = wrapper->_instance->FindAppointmentsAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 4
        && info[0]->IsDate()
        && info[1]->IsNumber()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info[2]))
      {
        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));
          ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ arg2 = UnwrapFindAppointmentsOptions(info[2]);
          
          op = wrapper->_instance->FindAppointmentsAsync(arg0,arg1,arg2);
        }
        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::ApplicationModel::Appointments::Appointment^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::ApplicationModel::Appointments::Appointment^>::CreateVectorViewWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::Appointment^ val) -> Local<Value> {
              return WrapAppointment(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::Appointment^ {
              return UnwrapAppointment(value);
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 FindExceptionsFromMasterAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::AppointmentException^>^>^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->FindExceptionsFromMasterAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::AppointmentException^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::ApplicationModel::Appointments::AppointmentException^>::CreateVectorViewWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::AppointmentException^ val) -> Local<Value> {
              return WrapAppointmentException(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentException^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::AppointmentException^ {
              return UnwrapAppointmentException(value);
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 FindAllInstancesAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::Appointment^>^>^ op;
    

      if (info.Length() == 4
        && info[0]->IsString()
        && info[1]->IsDate()
        && info[2]->IsNumber())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          ::Windows::Foundation::TimeSpan arg2 = NodeRT::Utils::TimeSpanFromMilli(Nan::To<int64_t>(info[2]).FromMaybe(0));
          
          op = wrapper->_instance->FindAllInstancesAsync(arg0,arg1,arg2);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 5
        && info[0]->IsString()
        && info[1]->IsDate()
        && info[2]->IsNumber()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info[3]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          ::Windows::Foundation::TimeSpan arg2 = NodeRT::Utils::TimeSpanFromMilli(Nan::To<int64_t>(info[2]).FromMaybe(0));
          ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ arg3 = UnwrapFindAppointmentsOptions(info[3]);
          
          op = wrapper->_instance->FindAllInstancesAsync(arg0,arg1,arg2,arg3);
        }
        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::ApplicationModel::Appointments::Appointment^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::ApplicationModel::Appointments::Appointment^>::CreateVectorViewWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::Appointment^ val) -> Local<Value> {
              return WrapAppointment(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::Appointment^ {
              return UnwrapAppointment(value);
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 GetAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::Appointments::Appointment^>^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->GetAppointmentAsync(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::ApplicationModel::Appointments::Appointment^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointment(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 GetAppointmentInstanceAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::Appointments::Appointment^>^ op;
    

      if (info.Length() == 3
        && info[0]->IsString()
        && info[1]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          
          op = wrapper->_instance->GetAppointmentInstanceAsync(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::ApplicationModel::Appointments::Appointment^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = WrapAppointment(result);
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 FindUnexpandedAppointmentsAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::Appointment^>^>^ op;
    

      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->FindUnexpandedAppointmentsAsync();
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::FindAppointmentsOptions^ arg0 = UnwrapFindAppointmentsOptions(info[0]);
          
          op = wrapper->_instance->FindUnexpandedAppointmentsAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::Appointment^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::ApplicationModel::Appointments::Appointment^>::CreateVectorViewWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::Appointment^ val) -> Local<Value> {
              return WrapAppointment(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::Appointment^ {
              return UnwrapAppointment(value);
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 DeleteAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->DeleteAsync();
        }
        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 SaveAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->SaveAsync();
        }
        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 DeleteAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 2
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          
          op = wrapper->_instance->DeleteAppointmentAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};

		    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
             
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }
    static void DeleteAppointmentInstanceAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 3
        && info[0]->IsString()
        && info[1]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          
          op = wrapper->_instance->DeleteAppointmentInstanceAsync(arg0,arg1);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};

		    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
             
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }
    static void SaveAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          
          op = wrapper->_instance->SaveAppointmentAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};

		    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
             
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }
    static void TryCreateOrUpdateAppointmentAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;
    

      if (info.Length() == 3
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && info[1]->IsBoolean())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          bool arg1 = Nan::To<bool>(info[1]).FromMaybe(false);
          
          op = wrapper->_instance->TryCreateOrUpdateAppointmentAsync(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<bool> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 TryCancelMeetingAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;
    

      if (info.Length() == 5
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && info[1]->IsString()
        && info[2]->IsString()
        && info[3]->IsBoolean())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[1])));
          Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[2])));
          bool arg3 = Nan::To<bool>(info[3]).FromMaybe(false);
          
          op = wrapper->_instance->TryCancelMeetingAsync(arg0,arg1,arg2,arg3);
        }
        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) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 TryForwardMeetingAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;
    

      if (info.Length() == 6
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>^>(info[1]) || info[1]->IsArray())
        && info[2]->IsString()
        && info[3]->IsString()
        && info[4]->IsString())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::Foundation::Collections::IIterable<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>^ arg1 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::AppointmentInvitee^ {
                   return UnwrapAppointmentInvitee(value);
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::ApplicationModel::Appointments::AppointmentInvitee^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[1]);
          Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[2])));
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[3])));
          Platform::String^ arg4 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[4])));
          
          op = wrapper->_instance->TryForwardMeetingAsync(arg0,arg1,arg2,arg3,arg4);
        }
        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) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 TryProposeNewTimeForMeetingAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;
    

      if (info.Length() == 6
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && info[1]->IsDate()
        && info[2]->IsNumber()
        && info[3]->IsString()
        && info[4]->IsString())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          ::Windows::Foundation::TimeSpan arg2 = NodeRT::Utils::TimeSpanFromMilli(Nan::To<int64_t>(info[2]).FromMaybe(0));
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[3])));
          Platform::String^ arg4 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[4])));
          
          op = wrapper->_instance->TryProposeNewTimeForMeetingAsync(arg0,arg1,arg2,arg3,arg4);
        }
        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) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 TryUpdateMeetingResponseAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(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;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      ::Windows::Foundation::IAsyncOperation<bool>^ op;
    

      if (info.Length() == 6
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::Appointment^>(info[0])
        && info[1]->IsInt32()
        && info[2]->IsString()
        && info[3]->IsString()
        && info[4]->IsBoolean())
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::Appointment^ arg0 = UnwrapAppointment(info[0]);
          ::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse arg1 = static_cast<::Windows::ApplicationModel::Appointments::AppointmentParticipantResponse>(Nan::To<int32_t>(info[1]).FromMaybe(0));
          Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[2])));
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(info[3])));
          bool arg4 = Nan::To<bool>(info[4]).FromMaybe(false);
          
          op = wrapper->_instance->TryUpdateMeetingResponseAsync(arg0,arg1,arg2,arg3,arg4);
        }
        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) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> 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};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 SummaryCardViewGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentSummaryCardView result = wrapper->_instance->SummaryCardView;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SummaryCardViewSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentSummaryCardView winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentSummaryCardView>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->SummaryCardView = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void OtherAppWriteAccessGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppWriteAccess result = wrapper->_instance->OtherAppWriteAccess;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OtherAppWriteAccessSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppWriteAccess winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppWriteAccess>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->OtherAppWriteAccess = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DisplayColorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        ::Windows::UI::Color result = wrapper->_instance->DisplayColor;
        info.GetReturnValue().Set(NodeRT::Utils::ColorToJs(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DisplayColorSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsColor(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        ::Windows::UI::Color winRtValue = NodeRT::Utils::ColorFromJs(value);

        wrapper->_instance->DisplayColor = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IsHiddenGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsHidden;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsHiddenSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsHidden = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(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 DisplayNameSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->DisplayName = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void OtherAppReadAccessGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppReadAccess result = wrapper->_instance->OtherAppReadAccess;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OtherAppReadAccessSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppReadAccess winRtValue = static_cast<::Windows::ApplicationModel::Appointments::AppointmentCalendarOtherAppReadAccess>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->OtherAppReadAccess = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void LocalIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->LocalId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SourceDisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->SourceDisplayName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CanCancelMeetingsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->CanCancelMeetings;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CanCancelMeetingsSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->CanCancelMeetings = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void CanNotifyInviteesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->CanNotifyInvitees;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CanNotifyInviteesSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->CanNotifyInvitees = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void RemoteIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->RemoteId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RemoteIdSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->RemoteId = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void MustNofityInviteesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->MustNofityInvitees;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void MustNofityInviteesSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->MustNofityInvitees = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void CanUpdateMeetingResponsesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->CanUpdateMeetingResponses;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CanUpdateMeetingResponsesSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->CanUpdateMeetingResponses = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void CanProposeNewTimeForMeetingsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->CanProposeNewTimeForMeetings;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CanProposeNewTimeForMeetingsSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->CanProposeNewTimeForMeetings = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void CanCreateOrUpdateAppointmentsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->CanCreateOrUpdateAppointments;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CanCreateOrUpdateAppointmentsSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->CanCreateOrUpdateAppointments = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void CanForwardMeetingsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        bool result = wrapper->_instance->CanForwardMeetings;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CanForwardMeetingsSetter(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::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->CanForwardMeetings = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void SyncManagerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentCalendarSyncManager^ result = wrapper->_instance->SyncManager;
        info.GetReturnValue().Set(WrapAppointmentCalendarSyncManager(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void UserDataAccountIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentCalendar^>(info.This()))
      {
        return;
      }

      AppointmentCalendar *wrapper = AppointmentCalendar::Unwrap<AppointmentCalendar>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->UserDataAccountId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::AppointmentCalendar^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentCalendar(::Windows::ApplicationModel::Appointments::AppointmentCalendar^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentCalendar^ UnwrapAppointmentCalendar(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentCalendar::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentCalendar(::Windows::ApplicationModel::Appointments::AppointmentCalendar^ 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>(AppointmentCalendar::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentCalendar^ UnwrapAppointmentCalendar(Local<Value> value)
  {
     return AppointmentCalendar::Unwrap<AppointmentCalendar>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentCalendar(Local<Object> exports)
  {
    AppointmentCalendar::Init(exports);
  }

  class AppointmentStoreChange : 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>("AppointmentStoreChange").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("appointment").ToLocalChecked(), AppointmentGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("changeType").ToLocalChecked(), ChangeTypeGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("appointmentCalendar").ToLocalChecked(), AppointmentCalendarGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentStoreChange").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentStoreChange(::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ 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::ApplicationModel::Appointments::AppointmentStoreChange^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChange^) 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());

      AppointmentStoreChange *wrapperInstance = new AppointmentStoreChange(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::ApplicationModel::Appointments::AppointmentStoreChange^>(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::ApplicationModel::Appointments::AppointmentStoreChange^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChange^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentStoreChange(winRtInstance));
    }


  



    static void AppointmentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>(info.This()))
      {
        return;
      }

      AppointmentStoreChange *wrapper = AppointmentStoreChange::Unwrap<AppointmentStoreChange>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::Appointment^ result = wrapper->_instance->Appointment;
        info.GetReturnValue().Set(WrapAppointment(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ChangeTypeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>(info.This()))
      {
        return;
      }

      AppointmentStoreChange *wrapper = AppointmentStoreChange::Unwrap<AppointmentStoreChange>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeType result = wrapper->_instance->ChangeType;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AppointmentCalendarGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>(info.This()))
      {
        return;
      }

      AppointmentStoreChange *wrapper = AppointmentStoreChange::Unwrap<AppointmentStoreChange>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentCalendar^ result = wrapper->_instance->AppointmentCalendar;
        info.GetReturnValue().Set(WrapAppointmentCalendar(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentStoreChange(::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ UnwrapAppointmentStoreChange(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentStoreChange::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentStoreChange(::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ 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>(AppointmentStoreChange::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ UnwrapAppointmentStoreChange(Local<Value> value)
  {
     return AppointmentStoreChange::Unwrap<AppointmentStoreChange>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentStoreChange(Local<Object> exports)
  {
    AppointmentStoreChange::Init(exports);
  }

  class AppointmentStoreChangeReader : 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>("AppointmentStoreChangeReader").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
      Local<Function> func;
      Local<FunctionTemplate> funcTemplate;
            
      Nan::SetPrototypeMethod(localRef, "acceptChanges", AcceptChanges);
      Nan::SetPrototypeMethod(localRef, "acceptChangesThrough", AcceptChangesThrough);
      
            
      Nan::SetPrototypeMethod(localRef, "readBatchAsync", ReadBatchAsync);
      
                  
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentStoreChangeReader").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentStoreChangeReader(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ 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::ApplicationModel::Appointments::AppointmentStoreChangeReader^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^) 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());

      AppointmentStoreChangeReader *wrapperInstance = new AppointmentStoreChangeReader(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::ApplicationModel::Appointments::AppointmentStoreChangeReader^>(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::ApplicationModel::Appointments::AppointmentStoreChangeReader^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentStoreChangeReader(winRtInstance));
    }


    static void ReadBatchAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^>(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;
      }

      AppointmentStoreChangeReader *wrapper = AppointmentStoreChangeReader::Unwrap<AppointmentStoreChangeReader>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::Foundation::Collections::IVectorView<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>^>^ op;
    

      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->ReadBatchAsync();
        }
        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::ApplicationModel::Appointments::AppointmentStoreChange^>^> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = NodeRT::Collections::VectorViewWrapper<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>::CreateVectorViewWrapper(result, 
            [](::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ val) -> Local<Value> {
              return WrapAppointmentStoreChange(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ {
              return UnwrapAppointmentStoreChange(value);
            }
          );
            if (tryCatch.HasCaught())
            {
              error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
            }
            else 
            {
              error = Undefined();
            }
            if (arg1.IsEmpty()) arg1 = Undefined();
            Local<Value> args[] = {error, arg1};
			// TODO: this is ugly! Needed due to the possibility of expception occuring inside object convertors
			// can be fixed by wrapping the conversion code in a function and calling it on the fly
			// we must clear the try catch block here so the invoked inner method exception won't get swollen (issue #52) 
			tryCatch.~TryCatch();

		    
            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 AcceptChanges(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^>(info.This()))
      {
        return;
      }

      AppointmentStoreChangeReader *wrapper = AppointmentStoreChangeReader::Unwrap<AppointmentStoreChangeReader>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->AcceptChanges();
          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 AcceptChangesThrough(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^>(info.This()))
      {
        return;
      }

      AppointmentStoreChangeReader *wrapper = AppointmentStoreChangeReader::Unwrap<AppointmentStoreChangeReader>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChange^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::AppointmentStoreChange^ arg0 = UnwrapAppointmentStoreChange(info[0]);
          
          wrapper->_instance->AcceptChangesThrough(arg0);
          return;   
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }





  private:
    ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentStoreChangeReader(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ UnwrapAppointmentStoreChangeReader(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentStoreChangeReader::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentStoreChangeReader(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ 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>(AppointmentStoreChangeReader::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ UnwrapAppointmentStoreChangeReader(Local<Value> value)
  {
     return AppointmentStoreChangeReader::Unwrap<AppointmentStoreChangeReader>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentStoreChangeReader(Local<Object> exports)
  {
    AppointmentStoreChangeReader::Init(exports);
  }

  class AppointmentStoreChangedDeferral : 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>("AppointmentStoreChangedDeferral").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
            
      Nan::SetPrototypeMethod(localRef, "complete", Complete);
      
                        
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentStoreChangedDeferral").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentStoreChangedDeferral(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ 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::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^) 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());

      AppointmentStoreChangedDeferral *wrapperInstance = new AppointmentStoreChangedDeferral(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::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^>(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::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentStoreChangedDeferral(winRtInstance));
    }


  
    static void Complete(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^>(info.This()))
      {
        return;
      }

      AppointmentStoreChangedDeferral *wrapper = AppointmentStoreChangedDeferral::Unwrap<AppointmentStoreChangedDeferral>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Complete();
          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::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentStoreChangedDeferral(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ UnwrapAppointmentStoreChangedDeferral(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentStoreChangedDeferral::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentStoreChangedDeferral(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ 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>(AppointmentStoreChangedDeferral::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ UnwrapAppointmentStoreChangedDeferral(Local<Value> value)
  {
     return AppointmentStoreChangedDeferral::Unwrap<AppointmentStoreChangedDeferral>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentStoreChangedDeferral(Local<Object> exports)
  {
    AppointmentStoreChangedDeferral::Init(exports);
  }

  class AppointmentStoreChangeTracker : 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>("AppointmentStoreChangeTracker").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
            
      Nan::SetPrototypeMethod(localRef, "getChangeReader", GetChangeReader);
      Nan::SetPrototypeMethod(localRef, "enable", Enable);
      Nan::SetPrototypeMethod(localRef, "reset", Reset);
      
                        
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentStoreChangeTracker").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentStoreChangeTracker(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ 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::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^) 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());

      AppointmentStoreChangeTracker *wrapperInstance = new AppointmentStoreChangeTracker(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::ApplicationModel::Appointments::AppointmentStoreChangeTracker^>(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::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentStoreChangeTracker(winRtInstance));
    }


  
    static void GetChangeReader(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^>(info.This()))
      {
        return;
      }

      AppointmentStoreChangeTracker *wrapper = AppointmentStoreChangeTracker::Unwrap<AppointmentStoreChangeTracker>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeReader^ result;
          result = wrapper->_instance->GetChangeReader();
          info.GetReturnValue().Set(WrapAppointmentStoreChangeReader(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 Enable(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^>(info.This()))
      {
        return;
      }

      AppointmentStoreChangeTracker *wrapper = AppointmentStoreChangeTracker::Unwrap<AppointmentStoreChangeTracker>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Enable();
          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 Reset(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^>(info.This()))
      {
        return;
      }

      AppointmentStoreChangeTracker *wrapper = AppointmentStoreChangeTracker::Unwrap<AppointmentStoreChangeTracker>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Reset();
          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::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentStoreChangeTracker(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ UnwrapAppointmentStoreChangeTracker(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentStoreChangeTracker::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentStoreChangeTracker(::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ 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>(AppointmentStoreChangeTracker::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangeTracker^ UnwrapAppointmentStoreChangeTracker(Local<Value> value)
  {
     return AppointmentStoreChangeTracker::Unwrap<AppointmentStoreChangeTracker>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentStoreChangeTracker(Local<Object> exports)
  {
    AppointmentStoreChangeTracker::Init(exports);
  }

  class AppointmentConflictResult : 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>("AppointmentConflictResult").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("date").ToLocalChecked(), DateGetter);
      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);


      Nan::Set(exports, Nan::New<String>("AppointmentConflictResult").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentConflictResult(::Windows::ApplicationModel::Appointments::AppointmentConflictResult^ 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::ApplicationModel::Appointments::AppointmentConflictResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentConflictResult^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentConflictResult^) 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());

      AppointmentConflictResult *wrapperInstance = new AppointmentConflictResult(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::ApplicationModel::Appointments::AppointmentConflictResult^>(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::ApplicationModel::Appointments::AppointmentConflictResult^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentConflictResult^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentConflictResult(winRtInstance));
    }


  



    static void DateGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentConflictResult^>(info.This()))
      {
        return;
      }

      AppointmentConflictResult *wrapper = AppointmentConflictResult::Unwrap<AppointmentConflictResult>(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 TypeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentConflictResult^>(info.This()))
      {
        return;
      }

      AppointmentConflictResult *wrapper = AppointmentConflictResult::Unwrap<AppointmentConflictResult>(info.This());

      try 
      {
        ::Windows::ApplicationModel::Appointments::AppointmentConflictType 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::ApplicationModel::Appointments::AppointmentConflictResult^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentConflictResult(::Windows::ApplicationModel::Appointments::AppointmentConflictResult^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentConflictResult^ UnwrapAppointmentConflictResult(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentConflictResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentConflictResult(::Windows::ApplicationModel::Appointments::AppointmentConflictResult^ 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>(AppointmentConflictResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentConflictResult^ UnwrapAppointmentConflictResult(Local<Value> value)
  {
     return AppointmentConflictResult::Unwrap<AppointmentConflictResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentConflictResult(Local<Object> exports)
  {
    AppointmentConflictResult::Init(exports);
  }

  class AppointmentStoreChangedEventArgs : 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>("AppointmentStoreChangedEventArgs").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
            
      Nan::SetPrototypeMethod(localRef, "getDeferral", GetDeferral);
      
                        
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentStoreChangedEventArgs").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentStoreChangedEventArgs(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ 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::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^) 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());

      AppointmentStoreChangedEventArgs *wrapperInstance = new AppointmentStoreChangedEventArgs(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::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^>(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::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentStoreChangedEventArgs(winRtInstance));
    }


  
    static void GetDeferral(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^>(info.This()))
      {
        return;
      }

      AppointmentStoreChangedEventArgs *wrapper = AppointmentStoreChangedEventArgs::Unwrap<AppointmentStoreChangedEventArgs>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedDeferral^ result;
          result = wrapper->_instance->GetDeferral();
          info.GetReturnValue().Set(WrapAppointmentStoreChangedDeferral(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }





  private:
    ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentStoreChangedEventArgs(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ UnwrapAppointmentStoreChangedEventArgs(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentStoreChangedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentStoreChangedEventArgs(::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ 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>(AppointmentStoreChangedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentStoreChangedEventArgs^ UnwrapAppointmentStoreChangedEventArgs(Local<Value> value)
  {
     return AppointmentStoreChangedEventArgs::Unwrap<AppointmentStoreChangedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentStoreChangedEventArgs(Local<Object> exports)
  {
    AppointmentStoreChangedEventArgs::Init(exports);
  }

  class AppointmentProperties : 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>("AppointmentProperties").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);

      Nan::SetAccessor(constructor, Nan::New<String>("hasInvitees").ToLocalChecked(), HasInviteesGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("allDay").ToLocalChecked(), AllDayGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("allowNewTimeProposal").ToLocalChecked(), AllowNewTimeProposalGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("busyStatus").ToLocalChecked(), BusyStatusGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("defaultProperties").ToLocalChecked(), DefaultPropertiesGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("details").ToLocalChecked(), DetailsGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("duration").ToLocalChecked(), DurationGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("recurrence").ToLocalChecked(), RecurrenceGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("invitees").ToLocalChecked(), InviteesGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("isCanceledMeeting").ToLocalChecked(), IsCanceledMeetingGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("isOrganizedByUser").ToLocalChecked(), IsOrganizedByUserGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("isResponseRequested").ToLocalChecked(), IsResponseRequestedGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("location").ToLocalChecked(), LocationGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("onlineMeetingLink").ToLocalChecked(), OnlineMeetingLinkGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("organizer").ToLocalChecked(), OrganizerGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("originalStartTime").ToLocalChecked(), OriginalStartTimeGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("reminder").ToLocalChecked(), ReminderGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("replyTime").ToLocalChecked(), ReplyTimeGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("sensitivity").ToLocalChecked(), SensitivityGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("startTime").ToLocalChecked(), StartTimeGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("subject").ToLocalChecked(), SubjectGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("uri").ToLocalChecked(), UriGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("userResponse").ToLocalChecked(), UserResponseGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("detailsKind").ToLocalChecked(), DetailsKindGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("remoteChangeNumber").ToLocalChecked(), RemoteChangeNumberGetter);
      Nan::SetAccessor(constructor, Nan::New<String>("changeNumber").ToLocalChecked(), ChangeNumberGetter);

      Nan::Set(exports, Nan::New<String>("AppointmentProperties").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentProperties(::Windows::ApplicationModel::Appointments::AppointmentProperties^ 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::ApplicationModel::Appointments::AppointmentProperties^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentProperties^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentProperties^) 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());

      AppointmentProperties *wrapperInstance = new AppointmentProperties(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::ApplicationModel::Appointments::AppointmentProperties^>(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::ApplicationModel::Appointments::AppointmentProperties^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentProperties^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentProperties(winRtInstance));
    }


  




    static void HasInviteesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::HasInvitees;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllDayGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::AllDay;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllowNewTimeProposalGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::AllowNewTimeProposal;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void BusyStatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::BusyStatus;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DefaultPropertiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        ::Windows::Foundation::Collections::IVector<::Platform::String^>^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::DefaultProperties;
        info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Platform::String^>::CreateVectorWrapper(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(value)));
            }
          ));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DetailsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Details;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DurationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Duration;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RecurrenceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Recurrence;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void InviteesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Invitees;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsCanceledMeetingGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::IsCanceledMeeting;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsOrganizedByUserGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::IsOrganizedByUser;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsResponseRequestedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::IsResponseRequested;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void LocationGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Location;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OnlineMeetingLinkGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::OnlineMeetingLink;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OrganizerGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Organizer;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OriginalStartTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::OriginalStartTime;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ReminderGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Reminder;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ReplyTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::ReplyTime;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SensitivityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Sensitivity;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void StartTimeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::StartTime;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SubjectGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Subject;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void UriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::Uri;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void UserResponseGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::UserResponse;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DetailsKindGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::DetailsKind;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RemoteChangeNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::RemoteChangeNumber;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ChangeNumberGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;

      try 
      {
        Platform::String^ result = ::Windows::ApplicationModel::Appointments::AppointmentProperties::ChangeNumber;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    

  private:
    ::Windows::ApplicationModel::Appointments::AppointmentProperties^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentProperties(::Windows::ApplicationModel::Appointments::AppointmentProperties^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentProperties^ UnwrapAppointmentProperties(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentProperties::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentProperties(::Windows::ApplicationModel::Appointments::AppointmentProperties^ 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>(AppointmentProperties::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentProperties^ UnwrapAppointmentProperties(Local<Value> value)
  {
     return AppointmentProperties::Unwrap<AppointmentProperties>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentProperties(Local<Object> exports)
  {
    AppointmentProperties::Init(exports);
  }

  class AppointmentStoreNotificationTriggerDetails : 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>("AppointmentStoreNotificationTriggerDetails").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("AppointmentStoreNotificationTriggerDetails").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    AppointmentStoreNotificationTriggerDetails(::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ 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::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^) 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());

      AppointmentStoreNotificationTriggerDetails *wrapperInstance = new AppointmentStoreNotificationTriggerDetails(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::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^>(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::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapAppointmentStoreNotificationTriggerDetails(winRtInstance));
    }


  





  private:
    ::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapAppointmentStoreNotificationTriggerDetails(::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ wintRtInstance);
    friend ::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ UnwrapAppointmentStoreNotificationTriggerDetails(Local<Value> value);
  };
  Persistent<FunctionTemplate> AppointmentStoreNotificationTriggerDetails::s_constructorTemplate;

  v8::Local<v8::Value> WrapAppointmentStoreNotificationTriggerDetails(::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ 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>(AppointmentStoreNotificationTriggerDetails::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::Appointments::AppointmentStoreNotificationTriggerDetails^ UnwrapAppointmentStoreNotificationTriggerDetails(Local<Value> value)
  {
     return AppointmentStoreNotificationTriggerDetails::Unwrap<AppointmentStoreNotificationTriggerDetails>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitAppointmentStoreNotificationTriggerDetails(Local<Object> exports)
  {
    AppointmentStoreNotificationTriggerDetails::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::ApplicationModel::Appointments::InitAppointmentStoreAccessTypeEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentSensitivityEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentBusyStatusEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentParticipantResponseEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentParticipantRoleEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentRecurrenceUnitEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentDaysOfWeekEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentWeekOfMonthEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentCalendarSyncStatusEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitRecurrenceTypeEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentDetailsKindEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitFindAppointmentCalendarsOptionsEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentSummaryCardViewEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentCalendarOtherAppReadAccessEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentCalendarOtherAppWriteAccessEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentConflictTypeEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStoreChangeTypeEnum(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointment(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStore(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitIAppointmentParticipant(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentOrganizer(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentInvitee(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentRecurrence(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentManager(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitFindAppointmentsOptions(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentException(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentCalendarSyncManager(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentCalendar(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStoreChange(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStoreChangeReader(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStoreChangedDeferral(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStoreChangeTracker(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentConflictResult(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStoreChangedEventArgs(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentProperties(target);
  NodeRT::Windows::ApplicationModel::Appointments::InitAppointmentStoreNotificationTriggerDetails(target);

  NodeRT::Utils::RegisterNameSpace("Windows.ApplicationModel.Appointments", target);
}


NODE_MODULE(binding, init)