// 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 DataTransfer { namespace DragDrop { namespace Core { 

  v8::Local<v8::Value> WrapICoreDropOperationTarget(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ wintRtInstance);
  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ UnwrapICoreDropOperationTarget(Local<Value> value);
  
  v8::Local<v8::Value> WrapCoreDragInfo(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ wintRtInstance);
  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ UnwrapCoreDragInfo(Local<Value> value);
  
  v8::Local<v8::Value> WrapCoreDragUIOverride(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ wintRtInstance);
  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ UnwrapCoreDragUIOverride(Local<Value> value);
  
  v8::Local<v8::Value> WrapCoreDragDropManager(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ wintRtInstance);
  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ UnwrapCoreDragDropManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapCoreDropOperationTargetRequestedEventArgs(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ wintRtInstance);
  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ UnwrapCoreDropOperationTargetRequestedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapCoreDragOperation(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ wintRtInstance);
  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ UnwrapCoreDragOperation(Local<Value> value);
  


  static void InitCoreDragUIContentModeEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("CoreDragUIContentMode").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("auto").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIContentMode::Auto)));
	Nan::Set(enumObject, Nan::New<String>("deferred").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIContentMode::Deferred)));
  }



  
  static bool IsPointJsObject(Local<Value> value)
  {
    if (!value->IsObject())
    {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Foundation::Point PointFromJsObject(Local<Value> value)
  {
    HandleScope scope;
    ::Windows::Foundation::Point 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> PointToJsObject(::Windows::Foundation::Point value)
  {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();

    
    return scope.Escape(obj);
  }

  
  class ICoreDropOperationTarget : 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>("ICoreDropOperationTarget").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
      Local<Function> func;
      Local<FunctionTemplate> funcTemplate;
                  
      Nan::SetPrototypeMethod(localRef, "enterAsync", EnterAsync);
      Nan::SetPrototypeMethod(localRef, "overAsync", OverAsync);
      Nan::SetPrototypeMethod(localRef, "leaveAsync", LeaveAsync);
      Nan::SetPrototypeMethod(localRef, "dropAsync", DropAsync);
      
                  
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("ICoreDropOperationTarget").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    ICoreDropOperationTarget(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ 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::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^) 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());

      ICoreDropOperationTarget *wrapperInstance = new ICoreDropOperationTarget(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::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^>(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::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapICoreDropOperationTarget(winRtInstance));
    }


    static void EnterAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^>(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;
      }

      ICoreDropOperationTarget *wrapper = ICoreDropOperationTarget::Unwrap<ICoreDropOperationTarget>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::DataTransfer::DataPackageOperation>^ op;
    

      if (info.Length() == 3
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info[0])
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info[1]))
      {
        try
        {
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ arg0 = UnwrapCoreDragInfo(info[0]);
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ arg1 = UnwrapCoreDragUIOverride(info[1]);
          
          op = wrapper->_instance->EnterAsync(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::DataTransfer::DataPackageOperation> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = Nan::New<Integer>(static_cast<int>(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 OverAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^>(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;
      }

      ICoreDropOperationTarget *wrapper = ICoreDropOperationTarget::Unwrap<ICoreDropOperationTarget>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::DataTransfer::DataPackageOperation>^ op;
    

      if (info.Length() == 3
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info[0])
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info[1]))
      {
        try
        {
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ arg0 = UnwrapCoreDragInfo(info[0]);
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ arg1 = UnwrapCoreDragUIOverride(info[1]);
          
          op = wrapper->_instance->OverAsync(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::DataTransfer::DataPackageOperation> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = Nan::New<Integer>(static_cast<int>(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 LeaveAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^>(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;
      }

      ICoreDropOperationTarget *wrapper = ICoreDropOperationTarget::Unwrap<ICoreDropOperationTarget>(info.This());

      ::Windows::Foundation::IAsyncAction^ op;
    

      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ arg0 = UnwrapCoreDragInfo(info[0]);
          
          op = wrapper->_instance->LeaveAsync(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 DropAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^>(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;
      }

      ICoreDropOperationTarget *wrapper = ICoreDropOperationTarget::Unwrap<ICoreDropOperationTarget>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::DataTransfer::DataPackageOperation>^ op;
    

      if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ arg0 = UnwrapCoreDragInfo(info[0]);
          
          op = wrapper->_instance->DropAsync(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::DataTransfer::DataPackageOperation> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = Nan::New<Integer>(static_cast<int>(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);
          });
        }  		
      });
    }
  





  private:
    ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapICoreDropOperationTarget(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ wintRtInstance);
    friend ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ UnwrapICoreDropOperationTarget(Local<Value> value);
  };
  Persistent<FunctionTemplate> ICoreDropOperationTarget::s_constructorTemplate;

  v8::Local<v8::Value> WrapICoreDropOperationTarget(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ 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>(ICoreDropOperationTarget::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ UnwrapICoreDropOperationTarget(Local<Value> value)
  {
     return ICoreDropOperationTarget::Unwrap<ICoreDropOperationTarget>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitICoreDropOperationTarget(Local<Object> exports)
  {
    ICoreDropOperationTarget::Init(exports);
  }

  class CoreDragInfo : 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>("CoreDragInfo").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("data").ToLocalChecked(), DataGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("modifiers").ToLocalChecked(), ModifiersGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("position").ToLocalChecked(), PositionGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("allowedOperations").ToLocalChecked(), AllowedOperationsGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("CoreDragInfo").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    CoreDragInfo(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ 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::DataTransfer::DragDrop::Core::CoreDragInfo^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^) 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());

      CoreDragInfo *wrapperInstance = new CoreDragInfo(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::DataTransfer::DragDrop::Core::CoreDragInfo^>(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::DataTransfer::DragDrop::Core::CoreDragInfo^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapCoreDragInfo(winRtInstance));
    }


  



    static void DataGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info.This()))
      {
        return;
      }

      CoreDragInfo *wrapper = CoreDragInfo::Unwrap<CoreDragInfo>(info.This());

      try 
      {
        ::Windows::ApplicationModel::DataTransfer::DataPackageView^ result = wrapper->_instance->Data;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.ApplicationModel.DataTransfer", "DataPackageView", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ModifiersGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info.This()))
      {
        return;
      }

      CoreDragInfo *wrapper = CoreDragInfo::Unwrap<CoreDragInfo>(info.This());

      try 
      {
        ::Windows::ApplicationModel::DataTransfer::DragDrop::DragDropModifiers result = wrapper->_instance->Modifiers;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void PositionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info.This()))
      {
        return;
      }

      CoreDragInfo *wrapper = CoreDragInfo::Unwrap<CoreDragInfo>(info.This());

      try 
      {
        ::Windows::Foundation::Point result = wrapper->_instance->Position;
        info.GetReturnValue().Set(NodeRT::Utils::PointToJs(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllowedOperationsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^>(info.This()))
      {
        return;
      }

      CoreDragInfo *wrapper = CoreDragInfo::Unwrap<CoreDragInfo>(info.This());

      try 
      {
        ::Windows::ApplicationModel::DataTransfer::DataPackageOperation result = wrapper->_instance->AllowedOperations;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapCoreDragInfo(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ wintRtInstance);
    friend ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ UnwrapCoreDragInfo(Local<Value> value);
  };
  Persistent<FunctionTemplate> CoreDragInfo::s_constructorTemplate;

  v8::Local<v8::Value> WrapCoreDragInfo(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ 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>(CoreDragInfo::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragInfo^ UnwrapCoreDragInfo(Local<Value> value)
  {
     return CoreDragInfo::Unwrap<CoreDragInfo>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitCoreDragInfo(Local<Object> exports)
  {
    CoreDragInfo::Init(exports);
  }

  class CoreDragUIOverride : 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>("CoreDragUIOverride").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
            
      Nan::SetPrototypeMethod(localRef, "setContentFromSoftwareBitmap", SetContentFromSoftwareBitmap);
      Nan::SetPrototypeMethod(localRef, "clear", Clear);
      
                        
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isGlyphVisible").ToLocalChecked(), IsGlyphVisibleGetter, IsGlyphVisibleSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isContentVisible").ToLocalChecked(), IsContentVisibleGetter, IsContentVisibleSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isCaptionVisible").ToLocalChecked(), IsCaptionVisibleGetter, IsCaptionVisibleSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("caption").ToLocalChecked(), CaptionGetter, CaptionSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("CoreDragUIOverride").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    CoreDragUIOverride(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ 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::DataTransfer::DragDrop::Core::CoreDragUIOverride^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^) 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());

      CoreDragUIOverride *wrapperInstance = new CoreDragUIOverride(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::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(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::DataTransfer::DragDrop::Core::CoreDragUIOverride^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapCoreDragUIOverride(winRtInstance));
    }


  
    static void SetContentFromSoftwareBitmap(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Graphics::Imaging::SoftwareBitmap^>(info[0]))
      {
        try
        {
          ::Windows::Graphics::Imaging::SoftwareBitmap^ arg0 = dynamic_cast<::Windows::Graphics::Imaging::SoftwareBitmap^>(NodeRT::Utils::GetObjectInstance(info[0]));
          
          wrapper->_instance->SetContentFromSoftwareBitmap(arg0);
          return;   
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Graphics::Imaging::SoftwareBitmap^>(info[0])
        && NodeRT::Utils::IsPoint(info[1]))
      {
        try
        {
          ::Windows::Graphics::Imaging::SoftwareBitmap^ arg0 = dynamic_cast<::Windows::Graphics::Imaging::SoftwareBitmap^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Foundation::Point arg1 = NodeRT::Utils::PointFromJs(info[1]);
          
          wrapper->_instance->SetContentFromSoftwareBitmap(arg0, arg1);
          return;   
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void Clear(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          wrapper->_instance->Clear();
          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 IsGlyphVisibleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsGlyphVisible;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsGlyphVisibleSetter(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::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsGlyphVisible = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IsContentVisibleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsContentVisible;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsContentVisibleSetter(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::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsContentVisible = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void IsCaptionVisibleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        bool result = wrapper->_instance->IsCaptionVisible;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void IsCaptionVisibleSetter(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::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->IsCaptionVisible = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void CaptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Caption;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void CaptionSetter(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::DataTransfer::DragDrop::Core::CoreDragUIOverride^>(info.This()))
      {
        return;
      }

      CoreDragUIOverride *wrapper = CoreDragUIOverride::Unwrap<CoreDragUIOverride>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Caption = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapCoreDragUIOverride(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ wintRtInstance);
    friend ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ UnwrapCoreDragUIOverride(Local<Value> value);
  };
  Persistent<FunctionTemplate> CoreDragUIOverride::s_constructorTemplate;

  v8::Local<v8::Value> WrapCoreDragUIOverride(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ 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>(CoreDragUIOverride::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIOverride^ UnwrapCoreDragUIOverride(Local<Value> value)
  {
     return CoreDragUIOverride::Unwrap<CoreDragUIOverride>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitCoreDragUIOverride(Local<Object> exports)
  {
    CoreDragUIOverride::Init(exports);
  }

  class CoreDragDropManager : 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>("CoreDragDropManager").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                        
      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>("areConcurrentOperationsEnabled").ToLocalChecked(), AreConcurrentOperationsEnabledGetter, AreConcurrentOperationsEnabledSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);

      Nan::SetMethod(constructor, "getForCurrentView", GetForCurrentView);

      Nan::Set(exports, Nan::New<String>("CoreDragDropManager").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    CoreDragDropManager(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ 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::DataTransfer::DragDrop::Core::CoreDragDropManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^) 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());

      CoreDragDropManager *wrapperInstance = new CoreDragDropManager(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::DataTransfer::DragDrop::Core::CoreDragDropManager^>(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::DataTransfer::DragDrop::Core::CoreDragDropManager^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapCoreDragDropManager(winRtInstance));
    }


  


    static void GetForCurrentView(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ result;
          result = ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager::GetForCurrentView();
          info.GetReturnValue().Set(WrapCoreDragDropManager(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 AreConcurrentOperationsEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^>(info.This()))
      {
        return;
      }

      CoreDragDropManager *wrapper = CoreDragDropManager::Unwrap<CoreDragDropManager>(info.This());

      try 
      {
        bool result = wrapper->_instance->AreConcurrentOperationsEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AreConcurrentOperationsEnabledSetter(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::DataTransfer::DragDrop::Core::CoreDragDropManager^>(info.This()))
      {
        return;
      }

      CoreDragDropManager *wrapper = CoreDragDropManager::Unwrap<CoreDragDropManager>(info.This());

      try 
      {
        
        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->AreConcurrentOperationsEnabled = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


    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"targetRequested", str))
      {
        if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^>(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;
        }
        CoreDragDropManager *wrapper = CoreDragDropManager::Unwrap<CoreDragDropManager>(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->TargetRequested::add(
            ref new ::Windows::Foundation::TypedEventHandler<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^, ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^>(
            [callbackObjPtr](::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ arg0, ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
           	    HandleScope scope;
                TryCatch tryCatch;
              
                Local<Value> error;

                Local<Value> wrappedArg0 = WrapCoreDragDropManager(arg0);
                Local<Value> wrappedArg1 = WrapCoreDropOperationTargetRequestedEventArgs(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"targetRequested", 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"targetRequested", str))
        {
          if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^>(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;
          }
          CoreDragDropManager *wrapper = CoreDragDropManager::Unwrap<CoreDragDropManager>(info.This());
          wrapper->_instance->TargetRequested::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::DataTransfer::DragDrop::Core::CoreDragDropManager^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapCoreDragDropManager(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ wintRtInstance);
    friend ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ UnwrapCoreDragDropManager(Local<Value> value);
  };
  Persistent<FunctionTemplate> CoreDragDropManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapCoreDragDropManager(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ 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>(CoreDragDropManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragDropManager^ UnwrapCoreDragDropManager(Local<Value> value)
  {
     return CoreDragDropManager::Unwrap<CoreDragDropManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitCoreDragDropManager(Local<Object> exports)
  {
    CoreDragDropManager::Init(exports);
  }

  class CoreDropOperationTargetRequestedEventArgs : 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>("CoreDropOperationTargetRequestedEventArgs").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
            
      Nan::SetPrototypeMethod(localRef, "setTarget", SetTarget);
      
                        
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("CoreDropOperationTargetRequestedEventArgs").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    CoreDropOperationTargetRequestedEventArgs(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ 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::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^) 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());

      CoreDropOperationTargetRequestedEventArgs *wrapperInstance = new CoreDropOperationTargetRequestedEventArgs(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::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^>(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::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapCoreDropOperationTargetRequestedEventArgs(winRtInstance));
    }


  
    static void SetTarget(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^>(info.This()))
      {
        return;
      }

      CoreDropOperationTargetRequestedEventArgs *wrapper = CoreDropOperationTargetRequestedEventArgs::Unwrap<CoreDropOperationTargetRequestedEventArgs>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^>(info[0]))
      {
        try
        {
          ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::ICoreDropOperationTarget^ arg0 = UnwrapICoreDropOperationTarget(info[0]);
          
          wrapper->_instance->SetTarget(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::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapCoreDropOperationTargetRequestedEventArgs(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ wintRtInstance);
    friend ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ UnwrapCoreDropOperationTargetRequestedEventArgs(Local<Value> value);
  };
  Persistent<FunctionTemplate> CoreDropOperationTargetRequestedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapCoreDropOperationTargetRequestedEventArgs(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ 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>(CoreDropOperationTargetRequestedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDropOperationTargetRequestedEventArgs^ UnwrapCoreDropOperationTargetRequestedEventArgs(Local<Value> value)
  {
     return CoreDropOperationTargetRequestedEventArgs::Unwrap<CoreDropOperationTargetRequestedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitCoreDropOperationTargetRequestedEventArgs(Local<Object> exports)
  {
    CoreDropOperationTargetRequestedEventArgs::Init(exports);
  }

  class CoreDragOperation : 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>("CoreDragOperation").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
      Local<Function> func;
      Local<FunctionTemplate> funcTemplate;
            
      Nan::SetPrototypeMethod(localRef, "setPointerId", SetPointerId);
      Nan::SetPrototypeMethod(localRef, "setDragUIContentFromSoftwareBitmap", SetDragUIContentFromSoftwareBitmap);
      
            
      Nan::SetPrototypeMethod(localRef, "startAsync", StartAsync);
      
                  
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("dragUIContentMode").ToLocalChecked(), DragUIContentModeGetter, DragUIContentModeSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("data").ToLocalChecked(), DataGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("allowedOperations").ToLocalChecked(), AllowedOperationsGetter, AllowedOperationsSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("CoreDragOperation").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    CoreDragOperation(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ 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::DataTransfer::DragDrop::Core::CoreDragOperation^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^) 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::DataTransfer::DragDrop::Core::CoreDragOperation();
        }
        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());

      CoreDragOperation *wrapperInstance = new CoreDragOperation(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::DataTransfer::DragDrop::Core::CoreDragOperation^>(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::DataTransfer::DragDrop::Core::CoreDragOperation^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapCoreDragOperation(winRtInstance));
    }


    static void StartAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^>(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;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      ::Windows::Foundation::IAsyncOperation<::Windows::ApplicationModel::DataTransfer::DataPackageOperation>^ op;
    

      if (info.Length() == 1)
      {
        try
        {
          op = wrapper->_instance->StartAsync();
        }
        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::DataTransfer::DataPackageOperation> t) 
      {	
        try
        {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            TryCatch tryCatch;
            Local<Value> error; 
            Local<Value> arg1 = Nan::New<Integer>(static_cast<int>(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 SetPointerId(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^>(info.This()))
      {
        return;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      if (info.Length() == 1
        && info[0]->IsUint32())
      {
        try
        {
          unsigned int arg0 = static_cast<unsigned int>(Nan::To<uint32_t>(info[0]).FromMaybe(0));
          
          wrapper->_instance->SetPointerId(arg0);
          return;   
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }
    static void SetDragUIContentFromSoftwareBitmap(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^>(info.This()))
      {
        return;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      if (info.Length() == 1
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Graphics::Imaging::SoftwareBitmap^>(info[0]))
      {
        try
        {
          ::Windows::Graphics::Imaging::SoftwareBitmap^ arg0 = dynamic_cast<::Windows::Graphics::Imaging::SoftwareBitmap^>(NodeRT::Utils::GetObjectInstance(info[0]));
          
          wrapper->_instance->SetDragUIContentFromSoftwareBitmap(arg0);
          return;   
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 2
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Graphics::Imaging::SoftwareBitmap^>(info[0])
        && NodeRT::Utils::IsPoint(info[1]))
      {
        try
        {
          ::Windows::Graphics::Imaging::SoftwareBitmap^ arg0 = dynamic_cast<::Windows::Graphics::Imaging::SoftwareBitmap^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Foundation::Point arg1 = NodeRT::Utils::PointFromJs(info[1]);
          
          wrapper->_instance->SetDragUIContentFromSoftwareBitmap(arg0, arg1);
          return;   
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }



    static void DragUIContentModeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^>(info.This()))
      {
        return;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      try 
      {
        ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIContentMode result = wrapper->_instance->DragUIContentMode;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DragUIContentModeSetter(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::DataTransfer::DragDrop::Core::CoreDragOperation^>(info.This()))
      {
        return;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIContentMode winRtValue = static_cast<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragUIContentMode>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->DragUIContentMode = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DataGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^>(info.This()))
      {
        return;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      try 
      {
        ::Windows::ApplicationModel::DataTransfer::DataPackage^ result = wrapper->_instance->Data;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.ApplicationModel.DataTransfer", "DataPackage", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllowedOperationsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^>(info.This()))
      {
        return;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      try 
      {
        ::Windows::ApplicationModel::DataTransfer::DataPackageOperation result = wrapper->_instance->AllowedOperations;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void AllowedOperationsSetter(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::DataTransfer::DragDrop::Core::CoreDragOperation^>(info.This()))
      {
        return;
      }

      CoreDragOperation *wrapper = CoreDragOperation::Unwrap<CoreDragOperation>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::DataTransfer::DataPackageOperation winRtValue = static_cast<::Windows::ApplicationModel::DataTransfer::DataPackageOperation>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->AllowedOperations = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapCoreDragOperation(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ wintRtInstance);
    friend ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ UnwrapCoreDragOperation(Local<Value> value);
  };
  Persistent<FunctionTemplate> CoreDragOperation::s_constructorTemplate;

  v8::Local<v8::Value> WrapCoreDragOperation(::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ 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>(CoreDragOperation::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::DataTransfer::DragDrop::Core::CoreDragOperation^ UnwrapCoreDragOperation(Local<Value> value)
  {
     return CoreDragOperation::Unwrap<CoreDragOperation>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitCoreDragOperation(Local<Object> exports)
  {
    CoreDragOperation::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::DataTransfer::DragDrop::Core::InitCoreDragUIContentModeEnum(target);
  NodeRT::Windows::ApplicationModel::DataTransfer::DragDrop::Core::InitICoreDropOperationTarget(target);
  NodeRT::Windows::ApplicationModel::DataTransfer::DragDrop::Core::InitCoreDragInfo(target);
  NodeRT::Windows::ApplicationModel::DataTransfer::DragDrop::Core::InitCoreDragUIOverride(target);
  NodeRT::Windows::ApplicationModel::DataTransfer::DragDrop::Core::InitCoreDragDropManager(target);
  NodeRT::Windows::ApplicationModel::DataTransfer::DragDrop::Core::InitCoreDropOperationTargetRequestedEventArgs(target);
  NodeRT::Windows::ApplicationModel::DataTransfer::DragDrop::Core::InitCoreDragOperation(target);

  NodeRT::Utils::RegisterNameSpace("Windows.ApplicationModel.DataTransfer.DragDrop.Core", target);
}


NODE_MODULE(binding, init)