// Copyright (c) The NodeRT Contributors
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the ""License""); you may
// not use this file except in compliance with the License. You may obtain a
// copy of the License at http://www.apache.org/licenses/LICENSE-2.0
//
// THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY
// IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
//
// See the Apache Version 2.0 License for specific language governing permissions
// and limitations under the License.

// TODO: Verify that this is is still needed..
#define NTDDI_VERSION 0x06010000

#include <v8.h>
#include "nan.h"
#include <string>
#include <ppltasks.h>
#include "CollectionsConverter.h"
#include "CollectionsWrap.h"
#include "node-async.h"
#include "NodeRtUtils.h"
#include "OpaqueWrapper.h"
#include "WrapperBase.h"

#using <Windows.WinMD>

// this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search
// Some of the node header files brings windows definitions with the same names as some of the WinRT methods
#undef DocumentProperties
#undef GetObject
#undef CreateEvent
#undef FindText
#undef SendMessage

const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__";

using v8::Array;
using v8::String;
using v8::Value;
using v8::Boolean;
using v8::Integer;
using v8::FunctionTemplate;
using v8::Object;
using v8::Local;
using v8::Function;
using v8::Date;
using v8::Number;
using v8::PropertyAttribute;
using v8::Primitive;
using Nan::HandleScope;
using Nan::Persistent;
using Nan::Undefined;
using Nan::True;
using Nan::False;
using Nan::Null;
using Nan::MaybeLocal;
using Nan::EscapableHandleScope;
using Nan::HandleScope;
using Nan::TryCatch;
using namespace concurrency;

namespace NodeRT { namespace Windows { namespace Security { namespace EnterpriseData { 
  v8::Local<v8::Value> WrapBufferProtectUnprotectResult(::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ wintRtInstance);
  ::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ UnwrapBufferProtectUnprotectResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapDataProtectionInfo(::Windows::Security::EnterpriseData::DataProtectionInfo^ wintRtInstance);
  ::Windows::Security::EnterpriseData::DataProtectionInfo^ UnwrapDataProtectionInfo(Local<Value> value);
  
  v8::Local<v8::Value> WrapDataProtectionManager(::Windows::Security::EnterpriseData::DataProtectionManager^ wintRtInstance);
  ::Windows::Security::EnterpriseData::DataProtectionManager^ UnwrapDataProtectionManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapFileProtectionInfo(::Windows::Security::EnterpriseData::FileProtectionInfo^ wintRtInstance);
  ::Windows::Security::EnterpriseData::FileProtectionInfo^ UnwrapFileProtectionInfo(Local<Value> value);
  
  v8::Local<v8::Value> WrapFileProtectionManager(::Windows::Security::EnterpriseData::FileProtectionManager^ wintRtInstance);
  ::Windows::Security::EnterpriseData::FileProtectionManager^ UnwrapFileProtectionManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapFileRevocationManager(::Windows::Security::EnterpriseData::FileRevocationManager^ wintRtInstance);
  ::Windows::Security::EnterpriseData::FileRevocationManager^ UnwrapFileRevocationManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapFileUnprotectOptions(::Windows::Security::EnterpriseData::FileUnprotectOptions^ wintRtInstance);
  ::Windows::Security::EnterpriseData::FileUnprotectOptions^ UnwrapFileUnprotectOptions(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectedAccessResumedEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ UnwrapProtectedAccessResumedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectedAccessSuspendingEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ UnwrapProtectedAccessSuspendingEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectedContainerExportResult(::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ UnwrapProtectedContainerExportResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectedContainerImportResult(::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ UnwrapProtectedContainerImportResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectedContentRevokedEventArgs(::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ UnwrapProtectedContentRevokedEventArgs(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectedFileCreateResult(::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ UnwrapProtectedFileCreateResult(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectionPolicyAuditInfo(::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ UnwrapProtectionPolicyAuditInfo(Local<Value> value);
  
  v8::Local<v8::Value> WrapProtectionPolicyManager(::Windows::Security::EnterpriseData::ProtectionPolicyManager^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ProtectionPolicyManager^ UnwrapProtectionPolicyManager(Local<Value> value);
  
  v8::Local<v8::Value> WrapThreadNetworkContext(::Windows::Security::EnterpriseData::ThreadNetworkContext^ wintRtInstance);
  ::Windows::Security::EnterpriseData::ThreadNetworkContext^ UnwrapThreadNetworkContext(Local<Value> value);
  



  static void InitDataProtectionStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("DataProtectionStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("protectedToOtherIdentity").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::DataProtectionStatus::ProtectedToOtherIdentity)));
    Nan::Set(enumObject, Nan::New<String>("protected").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::DataProtectionStatus::Protected)));
    Nan::Set(enumObject, Nan::New<String>("revoked").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::DataProtectionStatus::Revoked)));
    Nan::Set(enumObject, Nan::New<String>("unprotected").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::DataProtectionStatus::Unprotected)));
    Nan::Set(enumObject, Nan::New<String>("licenseExpired").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::DataProtectionStatus::LicenseExpired)));
    Nan::Set(enumObject, Nan::New<String>("accessSuspended").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::DataProtectionStatus::AccessSuspended)));
  }

  static void InitEnforcementLevelEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("EnforcementLevel").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("noProtection").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::EnforcementLevel::NoProtection)));
    Nan::Set(enumObject, Nan::New<String>("silent").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::EnforcementLevel::Silent)));
    Nan::Set(enumObject, Nan::New<String>("override").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::EnforcementLevel::Override)));
    Nan::Set(enumObject, Nan::New<String>("block").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::EnforcementLevel::Block)));
  }

  static void InitFileProtectionStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("FileProtectionStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("undetermined").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::Undetermined)));
    Nan::Set(enumObject, Nan::New<String>("unknown").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::Unknown)));
    Nan::Set(enumObject, Nan::New<String>("unprotected").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::Unprotected)));
    Nan::Set(enumObject, Nan::New<String>("revoked").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::Revoked)));
    Nan::Set(enumObject, Nan::New<String>("protected").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::Protected)));
    Nan::Set(enumObject, Nan::New<String>("protectedByOtherUser").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::ProtectedByOtherUser)));
    Nan::Set(enumObject, Nan::New<String>("protectedToOtherEnterprise").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::ProtectedToOtherEnterprise)));
    Nan::Set(enumObject, Nan::New<String>("notProtectable").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::NotProtectable)));
    Nan::Set(enumObject, Nan::New<String>("protectedToOtherIdentity").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::ProtectedToOtherIdentity)));
    Nan::Set(enumObject, Nan::New<String>("licenseExpired").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::LicenseExpired)));
    Nan::Set(enumObject, Nan::New<String>("accessSuspended").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::AccessSuspended)));
    Nan::Set(enumObject, Nan::New<String>("fileInUse").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::FileProtectionStatus::FileInUse)));
  }

  static void InitProtectedImportExportStatusEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ProtectedImportExportStatus").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("ok").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::Ok)));
    Nan::Set(enumObject, Nan::New<String>("undetermined").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::Undetermined)));
    Nan::Set(enumObject, Nan::New<String>("unprotected").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::Unprotected)));
    Nan::Set(enumObject, Nan::New<String>("revoked").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::Revoked)));
    Nan::Set(enumObject, Nan::New<String>("notRoamable").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::NotRoamable)));
    Nan::Set(enumObject, Nan::New<String>("protectedToOtherIdentity").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::ProtectedToOtherIdentity)));
    Nan::Set(enumObject, Nan::New<String>("licenseExpired").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::LicenseExpired)));
    Nan::Set(enumObject, Nan::New<String>("accessSuspended").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectedImportExportStatus::AccessSuspended)));
  }

  static void InitProtectionPolicyAuditActionEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ProtectionPolicyAuditAction").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("decrypt").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction::Decrypt)));
    Nan::Set(enumObject, Nan::New<String>("copyToLocation").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction::CopyToLocation)));
    Nan::Set(enumObject, Nan::New<String>("sendToRecipient").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction::SendToRecipient)));
    Nan::Set(enumObject, Nan::New<String>("other").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction::Other)));
  }

  static void InitProtectionPolicyEvaluationResultEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ProtectionPolicyEvaluationResult").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("allowed").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult::Allowed)));
    Nan::Set(enumObject, Nan::New<String>("blocked").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult::Blocked)));
    Nan::Set(enumObject, Nan::New<String>("consentRequired").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult::ConsentRequired)));
  }

  static void InitProtectionPolicyRequestAccessBehaviorEnum(const Local<Object> exports) {
    HandleScope scope;

    Local<Object> enumObject = Nan::New<Object>();

    Nan::Set(exports, Nan::New<String>("ProtectionPolicyRequestAccessBehavior").ToLocalChecked(), enumObject);
    Nan::Set(enumObject, Nan::New<String>("decrypt").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior::Decrypt)));
    Nan::Set(enumObject, Nan::New<String>("treatOverridePolicyAsBlock").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior::TreatOverridePolicyAsBlock)));
  }

  static bool IsEnterpriseDataContractJsObject(Local<Value> value) {
    if (!value->IsObject()) {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::Security::EnterpriseData::EnterpriseDataContract EnterpriseDataContractFromJsObject(Local<Value> value) {
    HandleScope scope;
    ::Windows::Security::EnterpriseData::EnterpriseDataContract 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> EnterpriseDataContractToJsObject(::Windows::Security::EnterpriseData::EnterpriseDataContract value) {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();


    return scope.Escape(obj);
  }


  class BufferProtectUnprotectResult : 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>("BufferProtectUnprotectResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("buffer").ToLocalChecked(), BufferGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("protectionInfo").ToLocalChecked(), ProtectionInfoGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("BufferProtectUnprotectResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      BufferProtectUnprotectResult(::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ 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::Security::EnterpriseData::BufferProtectUnprotectResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^) 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());

      BufferProtectUnprotectResult *wrapperInstance = new BufferProtectUnprotectResult(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::Security::EnterpriseData::BufferProtectUnprotectResult^>(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::Security::EnterpriseData::BufferProtectUnprotectResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapBufferProtectUnprotectResult(winRtInstance));
    }





    static void BufferGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^>(info.This())) {
        return;
      }

      BufferProtectUnprotectResult *wrapper = BufferProtectUnprotectResult::Unwrap<BufferProtectUnprotectResult>(info.This());

      try  {
        ::Windows::Storage::Streams::IBuffer^ result = wrapper->_instance->Buffer;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage.Streams", "IBuffer", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ProtectionInfoGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^>(info.This())) {
        return;
      }

      BufferProtectUnprotectResult *wrapper = BufferProtectUnprotectResult::Unwrap<BufferProtectUnprotectResult>(info.This());

      try  {
        ::Windows::Security::EnterpriseData::DataProtectionInfo^ result = wrapper->_instance->ProtectionInfo;
        info.GetReturnValue().Set(WrapDataProtectionInfo(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapBufferProtectUnprotectResult(::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ UnwrapBufferProtectUnprotectResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> BufferProtectUnprotectResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapBufferProtectUnprotectResult(::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ 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>(BufferProtectUnprotectResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^ UnwrapBufferProtectUnprotectResult(Local<Value> value) {
     return BufferProtectUnprotectResult::Unwrap<BufferProtectUnprotectResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitBufferProtectUnprotectResult(Local<Object> exports) {
    BufferProtectUnprotectResult::Init(exports);
  }

  class DataProtectionInfo : 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>("DataProtectionInfo").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("identity").ToLocalChecked(), IdentityGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("DataProtectionInfo").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      DataProtectionInfo(::Windows::Security::EnterpriseData::DataProtectionInfo^ 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::Security::EnterpriseData::DataProtectionInfo^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::DataProtectionInfo^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::DataProtectionInfo^) 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());

      DataProtectionInfo *wrapperInstance = new DataProtectionInfo(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::Security::EnterpriseData::DataProtectionInfo^>(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::Security::EnterpriseData::DataProtectionInfo^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::DataProtectionInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapDataProtectionInfo(winRtInstance));
    }





    static void IdentityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::DataProtectionInfo^>(info.This())) {
        return;
      }

      DataProtectionInfo *wrapper = DataProtectionInfo::Unwrap<DataProtectionInfo>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Identity;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::DataProtectionInfo^>(info.This())) {
        return;
      }

      DataProtectionInfo *wrapper = DataProtectionInfo::Unwrap<DataProtectionInfo>(info.This());

      try  {
        ::Windows::Security::EnterpriseData::DataProtectionStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::DataProtectionInfo^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapDataProtectionInfo(::Windows::Security::EnterpriseData::DataProtectionInfo^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::DataProtectionInfo^ UnwrapDataProtectionInfo(Local<Value> value);
  };

  Persistent<FunctionTemplate> DataProtectionInfo::s_constructorTemplate;

  v8::Local<v8::Value> WrapDataProtectionInfo(::Windows::Security::EnterpriseData::DataProtectionInfo^ 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>(DataProtectionInfo::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::DataProtectionInfo^ UnwrapDataProtectionInfo(Local<Value> value) {
     return DataProtectionInfo::Unwrap<DataProtectionInfo>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitDataProtectionInfo(Local<Object> exports) {
    DataProtectionInfo::Init(exports);
  }

  class DataProtectionManager : 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>("DataProtectionManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;





        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        func = Nan::GetFunction(Nan::New<FunctionTemplate>(ProtectAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("protectAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(UnprotectAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("unprotectAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(ProtectStreamAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("protectStreamAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(UnprotectStreamAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("unprotectStreamAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetProtectionInfoAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getProtectionInfoAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetStreamProtectionInfoAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getStreamProtectionInfoAsync").ToLocalChecked(), func);


        Nan::Set(exports, Nan::New<String>("DataProtectionManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      DataProtectionManager(::Windows::Security::EnterpriseData::DataProtectionManager^ 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::Security::EnterpriseData::DataProtectionManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::DataProtectionManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::DataProtectionManager^) 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());

      DataProtectionManager *wrapperInstance = new DataProtectionManager(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::Security::EnterpriseData::DataProtectionManager^>(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::Security::EnterpriseData::DataProtectionManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::DataProtectionManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapDataProtectionManager(winRtInstance));
    }




    static void ProtectAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IBuffer^>(info[0])
          && info[1]->IsString())
      {
        try
        {
          ::Windows::Storage::Streams::IBuffer^ arg0 = dynamic_cast<::Windows::Storage::Streams::IBuffer^>(NodeRT::Utils::GetObjectInstance(info[0]));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
            
          op = ::Windows::Security::EnterpriseData::DataProtectionManager::ProtectAsync(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::Security::EnterpriseData::BufferProtectUnprotectResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapBufferProtectUnprotectResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void UnprotectAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::BufferProtectUnprotectResult^>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IBuffer^>(info[0]))
      {
        try
        {
          ::Windows::Storage::Streams::IBuffer^ arg0 = dynamic_cast<::Windows::Storage::Streams::IBuffer^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::DataProtectionManager::UnprotectAsync(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::Security::EnterpriseData::BufferProtectUnprotectResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapBufferProtectUnprotectResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void ProtectStreamAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::DataProtectionInfo^>^ op;


      if (info.Length() == 4
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IInputStream^>(info[0])
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IOutputStream^>(info[2]))
      {
        try
        {
          ::Windows::Storage::Streams::IInputStream^ arg0 = dynamic_cast<::Windows::Storage::Streams::IInputStream^>(NodeRT::Utils::GetObjectInstance(info[0]));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Storage::Streams::IOutputStream^ arg2 = dynamic_cast<::Windows::Storage::Streams::IOutputStream^>(NodeRT::Utils::GetObjectInstance(info[2]));
            
          op = ::Windows::Security::EnterpriseData::DataProtectionManager::ProtectStreamAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Security::EnterpriseData::DataProtectionInfo^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapDataProtectionInfo(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void UnprotectStreamAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::DataProtectionInfo^>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IInputStream^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IOutputStream^>(info[1]))
      {
        try
        {
          ::Windows::Storage::Streams::IInputStream^ arg0 = dynamic_cast<::Windows::Storage::Streams::IInputStream^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Storage::Streams::IOutputStream^ arg1 = dynamic_cast<::Windows::Storage::Streams::IOutputStream^>(NodeRT::Utils::GetObjectInstance(info[1]));
            
          op = ::Windows::Security::EnterpriseData::DataProtectionManager::UnprotectStreamAsync(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::Security::EnterpriseData::DataProtectionInfo^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapDataProtectionInfo(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetProtectionInfoAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::DataProtectionInfo^>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IBuffer^>(info[0]))
      {
        try
        {
          ::Windows::Storage::Streams::IBuffer^ arg0 = dynamic_cast<::Windows::Storage::Streams::IBuffer^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::DataProtectionManager::GetProtectionInfoAsync(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::Security::EnterpriseData::DataProtectionInfo^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapDataProtectionInfo(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetStreamProtectionInfoAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::DataProtectionInfo^>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::Streams::IInputStream^>(info[0]))
      {
        try
        {
          ::Windows::Storage::Streams::IInputStream^ arg0 = dynamic_cast<::Windows::Storage::Streams::IInputStream^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::DataProtectionManager::GetStreamProtectionInfoAsync(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::Security::EnterpriseData::DataProtectionInfo^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapDataProtectionInfo(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }




    private:
      ::Windows::Security::EnterpriseData::DataProtectionManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapDataProtectionManager(::Windows::Security::EnterpriseData::DataProtectionManager^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::DataProtectionManager^ UnwrapDataProtectionManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> DataProtectionManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapDataProtectionManager(::Windows::Security::EnterpriseData::DataProtectionManager^ 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>(DataProtectionManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::DataProtectionManager^ UnwrapDataProtectionManager(Local<Value> value) {
     return DataProtectionManager::Unwrap<DataProtectionManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitDataProtectionManager(Local<Object> exports) {
    DataProtectionManager::Init(exports);
  }

  class FileProtectionInfo : 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>("FileProtectionInfo").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("identity").ToLocalChecked(), IdentityGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isRoamable").ToLocalChecked(), IsRoamableGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("isProtectWhileOpenSupported").ToLocalChecked(), IsProtectWhileOpenSupportedGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("FileProtectionInfo").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      FileProtectionInfo(::Windows::Security::EnterpriseData::FileProtectionInfo^ 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::Security::EnterpriseData::FileProtectionInfo^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileProtectionInfo^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::FileProtectionInfo^) 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());

      FileProtectionInfo *wrapperInstance = new FileProtectionInfo(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::Security::EnterpriseData::FileProtectionInfo^>(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::Security::EnterpriseData::FileProtectionInfo^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::FileProtectionInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapFileProtectionInfo(winRtInstance));
    }





    static void IdentityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileProtectionInfo^>(info.This())) {
        return;
      }

      FileProtectionInfo *wrapper = FileProtectionInfo::Unwrap<FileProtectionInfo>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Identity;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsRoamableGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileProtectionInfo^>(info.This())) {
        return;
      }

      FileProtectionInfo *wrapper = FileProtectionInfo::Unwrap<FileProtectionInfo>(info.This());

      try  {
        bool result = wrapper->_instance->IsRoamable;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileProtectionInfo^>(info.This())) {
        return;
      }

      FileProtectionInfo *wrapper = FileProtectionInfo::Unwrap<FileProtectionInfo>(info.This());

      try  {
        ::Windows::Security::EnterpriseData::FileProtectionStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IsProtectWhileOpenSupportedGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileProtectionInfo^>(info.This())) {
        return;
      }

      FileProtectionInfo *wrapper = FileProtectionInfo::Unwrap<FileProtectionInfo>(info.This());

      try  {
        bool result = wrapper->_instance->IsProtectWhileOpenSupported;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::FileProtectionInfo^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapFileProtectionInfo(::Windows::Security::EnterpriseData::FileProtectionInfo^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::FileProtectionInfo^ UnwrapFileProtectionInfo(Local<Value> value);
  };

  Persistent<FunctionTemplate> FileProtectionInfo::s_constructorTemplate;

  v8::Local<v8::Value> WrapFileProtectionInfo(::Windows::Security::EnterpriseData::FileProtectionInfo^ 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>(FileProtectionInfo::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::FileProtectionInfo^ UnwrapFileProtectionInfo(Local<Value> value) {
     return FileProtectionInfo::Unwrap<FileProtectionInfo>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFileProtectionInfo(Local<Object> exports) {
    FileProtectionInfo::Init(exports);
  }

  class FileProtectionManager : 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>("FileProtectionManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;





        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        func = Nan::GetFunction(Nan::New<FunctionTemplate>(UnprotectAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("unprotectAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(IsContainerAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("isContainerAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(LoadFileFromContainerAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("loadFileFromContainerAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(SaveFileAsContainerAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("saveFileAsContainerAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(ProtectAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("protectAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(CopyProtectionAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("copyProtectionAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetProtectionInfoAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getProtectionInfoAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(CreateProtectedAndOpenAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("createProtectedAndOpenAsync").ToLocalChecked(), func);


        Nan::Set(exports, Nan::New<String>("FileProtectionManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      FileProtectionManager(::Windows::Security::EnterpriseData::FileProtectionManager^ 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::Security::EnterpriseData::FileProtectionManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileProtectionManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::FileProtectionManager^) 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());

      FileProtectionManager *wrapperInstance = new FileProtectionManager(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::Security::EnterpriseData::FileProtectionManager^>(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::Security::EnterpriseData::FileProtectionManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::FileProtectionManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapFileProtectionManager(winRtInstance));
    }




    static void UnprotectAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::FileProtectionInfo^>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0]))
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::UnprotectAsync(arg0);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileUnprotectOptions^>(info[1]))
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Security::EnterpriseData::FileUnprotectOptions^ arg1 = UnwrapFileUnprotectOptions(info[1]);
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::UnprotectAsync(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::Security::EnterpriseData::FileProtectionInfo^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapFileProtectionInfo(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void IsContainerAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<bool>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFile^>(info[0]))
      {
        try
        {
          ::Windows::Storage::IStorageFile^ arg0 = dynamic_cast<::Windows::Storage::IStorageFile^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::IsContainerAsync(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<bool> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<Boolean>(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void LoadFileFromContainerAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::ProtectedContainerImportResult^>^ op;


      if (info.Length() == 4
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFile^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[1])
          && info[2]->IsInt32())
      {
        try
        {
          ::Windows::Storage::IStorageFile^ arg0 = dynamic_cast<::Windows::Storage::IStorageFile^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Storage::IStorageItem^ arg1 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[1]));
          ::Windows::Storage::NameCollisionOption arg2 = static_cast<::Windows::Storage::NameCollisionOption>(Nan::To<int32_t>(info[2]).FromMaybe(0));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::LoadFileFromContainerAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFile^>(info[0]))
      {
        try
        {
          ::Windows::Storage::IStorageFile^ arg0 = dynamic_cast<::Windows::Storage::IStorageFile^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::LoadFileFromContainerAsync(arg0);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFile^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[1]))
      {
        try
        {
          ::Windows::Storage::IStorageFile^ arg0 = dynamic_cast<::Windows::Storage::IStorageFile^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Storage::IStorageItem^ arg1 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[1]));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::LoadFileFromContainerAsync(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::Security::EnterpriseData::ProtectedContainerImportResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapProtectedContainerImportResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void SaveFileAsContainerAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::ProtectedContainerExportResult^>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFile^>(info[0])
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Platform::String^>^>(info[1]) || info[1]->IsArray()))
      {
        try
        {
          ::Windows::Storage::IStorageFile^ arg0 = dynamic_cast<::Windows::Storage::IStorageFile^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Foundation::Collections::IIterable<::Platform::String^>^ arg1 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Platform::String^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Platform::String^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return (!NodeRT::Utils::IsWinRtWrapper(value));
                 },
                 [](Local<Value> value) -> ::Platform::String^ {
                   return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Platform::String^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[1]);
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::SaveFileAsContainerAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFile^>(info[0]))
      {
        try
        {
          ::Windows::Storage::IStorageFile^ arg0 = dynamic_cast<::Windows::Storage::IStorageFile^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::SaveFileAsContainerAsync(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::Security::EnterpriseData::ProtectedContainerExportResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapProtectedContainerExportResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void ProtectAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::FileProtectionInfo^>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0])
          && info[1]->IsString())
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::ProtectAsync(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::Security::EnterpriseData::FileProtectionInfo^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapFileProtectionInfo(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void CopyProtectionAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<bool>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[1]))
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Storage::IStorageItem^ arg1 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[1]));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::CopyProtectionAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<bool> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<Boolean>(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetProtectionInfoAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::FileProtectionInfo^>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0]))
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::GetProtectionInfoAsync(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::Security::EnterpriseData::FileProtectionInfo^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapFileProtectionInfo(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void CreateProtectedAndOpenAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::ProtectedFileCreateResult^>^ op;


      if (info.Length() == 5
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFolder^>(info[0])
          && info[1]->IsString()
          && info[2]->IsString()
          && info[3]->IsInt32())
      {
        try
        {
          ::Windows::Storage::IStorageFolder^ arg0 = dynamic_cast<::Windows::Storage::IStorageFolder^>(NodeRT::Utils::GetObjectInstance(info[0]));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[2])));
          ::Windows::Storage::CreationCollisionOption arg3 = static_cast<::Windows::Storage::CreationCollisionOption>(Nan::To<int32_t>(info[3]).FromMaybe(0));
            
          op = ::Windows::Security::EnterpriseData::FileProtectionManager::CreateProtectedAndOpenAsync(arg0,arg1,arg2,arg3);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Security::EnterpriseData::ProtectedFileCreateResult^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = WrapProtectedFileCreateResult(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }




    private:
      ::Windows::Security::EnterpriseData::FileProtectionManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapFileProtectionManager(::Windows::Security::EnterpriseData::FileProtectionManager^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::FileProtectionManager^ UnwrapFileProtectionManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> FileProtectionManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapFileProtectionManager(::Windows::Security::EnterpriseData::FileProtectionManager^ 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>(FileProtectionManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::FileProtectionManager^ UnwrapFileProtectionManager(Local<Value> value) {
     return FileProtectionManager::Unwrap<FileProtectionManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFileProtectionManager(Local<Object> exports) {
    FileProtectionManager::Init(exports);
  }

  class FileRevocationManager : 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>("FileRevocationManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;





        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "revoke", Revoke);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(ProtectAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("protectAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(CopyProtectionAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("copyProtectionAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetStatusAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getStatusAsync").ToLocalChecked(), func);


        Nan::Set(exports, Nan::New<String>("FileRevocationManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      FileRevocationManager(::Windows::Security::EnterpriseData::FileRevocationManager^ 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::Security::EnterpriseData::FileRevocationManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileRevocationManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::FileRevocationManager^) 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());

      FileRevocationManager *wrapperInstance = new FileRevocationManager(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::Security::EnterpriseData::FileRevocationManager^>(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::Security::EnterpriseData::FileRevocationManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::FileRevocationManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapFileRevocationManager(winRtInstance));
    }




    static void ProtectAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::FileProtectionStatus>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0])
          && info[1]->IsString())
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
            
          op = ::Windows::Security::EnterpriseData::FileRevocationManager::ProtectAsync(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::Security::EnterpriseData::FileProtectionStatus> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<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};


            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 CopyProtectionAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<bool>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0])
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[1]))
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
          ::Windows::Storage::IStorageItem^ arg1 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[1]));
            
          op = ::Windows::Security::EnterpriseData::FileRevocationManager::CopyProtectionAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<bool> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<Boolean>(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetStatusAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::FileProtectionStatus>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0]))
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::FileRevocationManager::GetStatusAsync(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::Security::EnterpriseData::FileProtectionStatus> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<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};


            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 Revoke(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Windows::Security::EnterpriseData::FileRevocationManager::Revoke(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::Security::EnterpriseData::FileRevocationManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapFileRevocationManager(::Windows::Security::EnterpriseData::FileRevocationManager^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::FileRevocationManager^ UnwrapFileRevocationManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> FileRevocationManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapFileRevocationManager(::Windows::Security::EnterpriseData::FileRevocationManager^ 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>(FileRevocationManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::FileRevocationManager^ UnwrapFileRevocationManager(Local<Value> value) {
     return FileRevocationManager::Unwrap<FileRevocationManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFileRevocationManager(Local<Object> exports) {
    FileRevocationManager::Init(exports);
  }

  class FileUnprotectOptions : 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>("FileUnprotectOptions").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("audit").ToLocalChecked(), AuditGetter, AuditSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("FileUnprotectOptions").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      FileUnprotectOptions(::Windows::Security::EnterpriseData::FileUnprotectOptions^ 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::Security::EnterpriseData::FileUnprotectOptions^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileUnprotectOptions^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::FileUnprotectOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 1
        && info[0]->IsBoolean())
      {
        try {
          bool arg0 = Nan::To<bool>(info[0]).FromMaybe(false);
          
          winRtInstance = ref new ::Windows::Security::EnterpriseData::FileUnprotectOptions(arg0);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found")));
        return;
      }

      NodeRT::Utils::SetHiddenValue(info.This(), Nan::New<String>("__winRtInstance__").ToLocalChecked(), True());

      FileUnprotectOptions *wrapperInstance = new FileUnprotectOptions(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::Security::EnterpriseData::FileUnprotectOptions^>(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::Security::EnterpriseData::FileUnprotectOptions^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::FileUnprotectOptions^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapFileUnprotectOptions(winRtInstance));
    }





    static void AuditGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::FileUnprotectOptions^>(info.This())) {
        return;
      }

      FileUnprotectOptions *wrapper = FileUnprotectOptions::Unwrap<FileUnprotectOptions>(info.This());

      try  {
        bool result = wrapper->_instance->Audit;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void AuditSetter(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::Security::EnterpriseData::FileUnprotectOptions^>(info.This())) {
        return;
      }

      FileUnprotectOptions *wrapper = FileUnprotectOptions::Unwrap<FileUnprotectOptions>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->Audit = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::FileUnprotectOptions^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapFileUnprotectOptions(::Windows::Security::EnterpriseData::FileUnprotectOptions^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::FileUnprotectOptions^ UnwrapFileUnprotectOptions(Local<Value> value);
  };

  Persistent<FunctionTemplate> FileUnprotectOptions::s_constructorTemplate;

  v8::Local<v8::Value> WrapFileUnprotectOptions(::Windows::Security::EnterpriseData::FileUnprotectOptions^ 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>(FileUnprotectOptions::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::FileUnprotectOptions^ UnwrapFileUnprotectOptions(Local<Value> value) {
     return FileUnprotectOptions::Unwrap<FileUnprotectOptions>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitFileUnprotectOptions(Local<Object> exports) {
    FileUnprotectOptions::Init(exports);
  }

  class ProtectedAccessResumedEventArgs : 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>("ProtectedAccessResumedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("identities").ToLocalChecked(), IdentitiesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ProtectedAccessResumedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectedAccessResumedEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ 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::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^) 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());

      ProtectedAccessResumedEventArgs *wrapperInstance = new ProtectedAccessResumedEventArgs(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::Security::EnterpriseData::ProtectedAccessResumedEventArgs^>(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::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectedAccessResumedEventArgs(winRtInstance));
    }





    static void IdentitiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^>(info.This())) {
        return;
      }

      ProtectedAccessResumedEventArgs *wrapper = ProtectedAccessResumedEventArgs::Unwrap<ProtectedAccessResumedEventArgs>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result = wrapper->_instance->Identities;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Platform::String^>::CreateVectorViewWrapper(result, 
            [](::Platform::String^ val) -> Local<Value> {
              return NodeRT::Utils::NewString(val->Data());
            },
            [](Local<Value> value) -> bool {
              return value->IsString();
            },
            [](Local<Value> value) -> ::Platform::String^ {
              return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectedAccessResumedEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ UnwrapProtectedAccessResumedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectedAccessResumedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectedAccessResumedEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ 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>(ProtectedAccessResumedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ UnwrapProtectedAccessResumedEventArgs(Local<Value> value) {
     return ProtectedAccessResumedEventArgs::Unwrap<ProtectedAccessResumedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectedAccessResumedEventArgs(Local<Object> exports) {
    ProtectedAccessResumedEventArgs::Init(exports);
  }

  class ProtectedAccessSuspendingEventArgs : 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>("ProtectedAccessSuspendingEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "getDeferral", GetDeferral);
          



          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("deadline").ToLocalChecked(), DeadlineGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("identities").ToLocalChecked(), IdentitiesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ProtectedAccessSuspendingEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectedAccessSuspendingEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ 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::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^) 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());

      ProtectedAccessSuspendingEventArgs *wrapperInstance = new ProtectedAccessSuspendingEventArgs(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::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^>(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::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectedAccessSuspendingEventArgs(winRtInstance));
    }


    static void GetDeferral(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^>(info.This())) {
        return;
      }

      ProtectedAccessSuspendingEventArgs *wrapper = ProtectedAccessSuspendingEventArgs::Unwrap<ProtectedAccessSuspendingEventArgs>(info.This());

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Foundation::Deferral^ result;
          result = wrapper->_instance->GetDeferral();
          info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Deferral", 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 DeadlineGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^>(info.This())) {
        return;
      }

      ProtectedAccessSuspendingEventArgs *wrapper = ProtectedAccessSuspendingEventArgs::Unwrap<ProtectedAccessSuspendingEventArgs>(info.This());

      try  {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Deadline;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IdentitiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^>(info.This())) {
        return;
      }

      ProtectedAccessSuspendingEventArgs *wrapper = ProtectedAccessSuspendingEventArgs::Unwrap<ProtectedAccessSuspendingEventArgs>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result = wrapper->_instance->Identities;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Platform::String^>::CreateVectorViewWrapper(result, 
            [](::Platform::String^ val) -> Local<Value> {
              return NodeRT::Utils::NewString(val->Data());
            },
            [](Local<Value> value) -> bool {
              return value->IsString();
            },
            [](Local<Value> value) -> ::Platform::String^ {
              return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectedAccessSuspendingEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ UnwrapProtectedAccessSuspendingEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectedAccessSuspendingEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectedAccessSuspendingEventArgs(::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ 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>(ProtectedAccessSuspendingEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ UnwrapProtectedAccessSuspendingEventArgs(Local<Value> value) {
     return ProtectedAccessSuspendingEventArgs::Unwrap<ProtectedAccessSuspendingEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectedAccessSuspendingEventArgs(Local<Object> exports) {
    ProtectedAccessSuspendingEventArgs::Init(exports);
  }

  class ProtectedContainerExportResult : 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>("ProtectedContainerExportResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("file").ToLocalChecked(), FileGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ProtectedContainerExportResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectedContainerExportResult(::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ 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::Security::EnterpriseData::ProtectedContainerExportResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContainerExportResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectedContainerExportResult^) 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());

      ProtectedContainerExportResult *wrapperInstance = new ProtectedContainerExportResult(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::Security::EnterpriseData::ProtectedContainerExportResult^>(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::Security::EnterpriseData::ProtectedContainerExportResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectedContainerExportResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectedContainerExportResult(winRtInstance));
    }





    static void FileGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContainerExportResult^>(info.This())) {
        return;
      }

      ProtectedContainerExportResult *wrapper = ProtectedContainerExportResult::Unwrap<ProtectedContainerExportResult>(info.This());

      try  {
        ::Windows::Storage::StorageFile^ result = wrapper->_instance->File;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage", "StorageFile", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContainerExportResult^>(info.This())) {
        return;
      }

      ProtectedContainerExportResult *wrapper = ProtectedContainerExportResult::Unwrap<ProtectedContainerExportResult>(info.This());

      try  {
        ::Windows::Security::EnterpriseData::ProtectedImportExportStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectedContainerExportResult(::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ UnwrapProtectedContainerExportResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectedContainerExportResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectedContainerExportResult(::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ 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>(ProtectedContainerExportResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectedContainerExportResult^ UnwrapProtectedContainerExportResult(Local<Value> value) {
     return ProtectedContainerExportResult::Unwrap<ProtectedContainerExportResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectedContainerExportResult(Local<Object> exports) {
    ProtectedContainerExportResult::Init(exports);
  }

  class ProtectedContainerImportResult : 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>("ProtectedContainerImportResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("file").ToLocalChecked(), FileGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("status").ToLocalChecked(), StatusGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ProtectedContainerImportResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectedContainerImportResult(::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ 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::Security::EnterpriseData::ProtectedContainerImportResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContainerImportResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectedContainerImportResult^) 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());

      ProtectedContainerImportResult *wrapperInstance = new ProtectedContainerImportResult(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::Security::EnterpriseData::ProtectedContainerImportResult^>(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::Security::EnterpriseData::ProtectedContainerImportResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectedContainerImportResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectedContainerImportResult(winRtInstance));
    }





    static void FileGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContainerImportResult^>(info.This())) {
        return;
      }

      ProtectedContainerImportResult *wrapper = ProtectedContainerImportResult::Unwrap<ProtectedContainerImportResult>(info.This());

      try  {
        ::Windows::Storage::StorageFile^ result = wrapper->_instance->File;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage", "StorageFile", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StatusGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContainerImportResult^>(info.This())) {
        return;
      }

      ProtectedContainerImportResult *wrapper = ProtectedContainerImportResult::Unwrap<ProtectedContainerImportResult>(info.This());

      try  {
        ::Windows::Security::EnterpriseData::ProtectedImportExportStatus result = wrapper->_instance->Status;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectedContainerImportResult(::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ UnwrapProtectedContainerImportResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectedContainerImportResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectedContainerImportResult(::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ 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>(ProtectedContainerImportResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectedContainerImportResult^ UnwrapProtectedContainerImportResult(Local<Value> value) {
     return ProtectedContainerImportResult::Unwrap<ProtectedContainerImportResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectedContainerImportResult(Local<Object> exports) {
    ProtectedContainerImportResult::Init(exports);
  }

  class ProtectedContentRevokedEventArgs : 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>("ProtectedContentRevokedEventArgs").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("identities").ToLocalChecked(), IdentitiesGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ProtectedContentRevokedEventArgs").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectedContentRevokedEventArgs(::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ 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::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^) 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());

      ProtectedContentRevokedEventArgs *wrapperInstance = new ProtectedContentRevokedEventArgs(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::Security::EnterpriseData::ProtectedContentRevokedEventArgs^>(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::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectedContentRevokedEventArgs(winRtInstance));
    }





    static void IdentitiesGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^>(info.This())) {
        return;
      }

      ProtectedContentRevokedEventArgs *wrapper = ProtectedContentRevokedEventArgs::Unwrap<ProtectedContentRevokedEventArgs>(info.This());

      try  {
        ::Windows::Foundation::Collections::IVectorView<::Platform::String^>^ result = wrapper->_instance->Identities;
        info.GetReturnValue().Set(NodeRT::Collections::VectorViewWrapper<::Platform::String^>::CreateVectorViewWrapper(result, 
            [](::Platform::String^ val) -> Local<Value> {
              return NodeRT::Utils::NewString(val->Data());
            },
            [](Local<Value> value) -> bool {
              return value->IsString();
            },
            [](Local<Value> value) -> ::Platform::String^ {
              return ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));
            }
          ));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectedContentRevokedEventArgs(::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ UnwrapProtectedContentRevokedEventArgs(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectedContentRevokedEventArgs::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectedContentRevokedEventArgs(::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ 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>(ProtectedContentRevokedEventArgs::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ UnwrapProtectedContentRevokedEventArgs(Local<Value> value) {
     return ProtectedContentRevokedEventArgs::Unwrap<ProtectedContentRevokedEventArgs>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectedContentRevokedEventArgs(Local<Object> exports) {
    ProtectedContentRevokedEventArgs::Init(exports);
  }

  class ProtectedFileCreateResult : 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>("ProtectedFileCreateResult").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("file").ToLocalChecked(), FileGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("protectionInfo").ToLocalChecked(), ProtectionInfoGetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("stream").ToLocalChecked(), StreamGetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ProtectedFileCreateResult").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectedFileCreateResult(::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ 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::Security::EnterpriseData::ProtectedFileCreateResult^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedFileCreateResult^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectedFileCreateResult^) 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());

      ProtectedFileCreateResult *wrapperInstance = new ProtectedFileCreateResult(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::Security::EnterpriseData::ProtectedFileCreateResult^>(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::Security::EnterpriseData::ProtectedFileCreateResult^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectedFileCreateResult^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectedFileCreateResult(winRtInstance));
    }





    static void FileGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedFileCreateResult^>(info.This())) {
        return;
      }

      ProtectedFileCreateResult *wrapper = ProtectedFileCreateResult::Unwrap<ProtectedFileCreateResult>(info.This());

      try  {
        ::Windows::Storage::StorageFile^ result = wrapper->_instance->File;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage", "StorageFile", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ProtectionInfoGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedFileCreateResult^>(info.This())) {
        return;
      }

      ProtectedFileCreateResult *wrapper = ProtectedFileCreateResult::Unwrap<ProtectedFileCreateResult>(info.This());

      try  {
        ::Windows::Security::EnterpriseData::FileProtectionInfo^ result = wrapper->_instance->ProtectionInfo;
        info.GetReturnValue().Set(WrapFileProtectionInfo(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void StreamGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectedFileCreateResult^>(info.This())) {
        return;
      }

      ProtectedFileCreateResult *wrapper = ProtectedFileCreateResult::Unwrap<ProtectedFileCreateResult>(info.This());

      try  {
        ::Windows::Storage::Streams::IRandomAccessStream^ result = wrapper->_instance->Stream;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Storage.Streams", "IRandomAccessStream", result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectedFileCreateResult(::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ UnwrapProtectedFileCreateResult(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectedFileCreateResult::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectedFileCreateResult(::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ 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>(ProtectedFileCreateResult::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectedFileCreateResult^ UnwrapProtectedFileCreateResult(Local<Value> value) {
     return ProtectedFileCreateResult::Unwrap<ProtectedFileCreateResult>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectedFileCreateResult(Local<Object> exports) {
    ProtectedFileCreateResult::Init(exports);
  }

  class ProtectionPolicyAuditInfo : 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>("ProtectionPolicyAuditInfo").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);





          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("targetDescription").ToLocalChecked(), TargetDescriptionGetter, TargetDescriptionSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sourceDescription").ToLocalChecked(), SourceDescriptionGetter, SourceDescriptionSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("dataDescription").ToLocalChecked(), DataDescriptionGetter, DataDescriptionSetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("action").ToLocalChecked(), ActionGetter, ActionSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ProtectionPolicyAuditInfo").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectionPolicyAuditInfo(::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ 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::Security::EnterpriseData::ProtectionPolicyAuditInfo^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 4
        && info[0]->IsInt32()
        && info[1]->IsString()
        && info[2]->IsString()
        && info[3]->IsString())
      {
        try {
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction arg0 = static_cast<::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[2])));
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[3])));
          
          winRtInstance = ref new ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo(arg0,arg1,arg2,arg3);
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 2
        && info[0]->IsInt32()
        && info[1]->IsString())
      {
        try {
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction arg0 = static_cast<::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction>(Nan::To<int32_t>(info[0]).FromMaybe(0));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          
          winRtInstance = ref new ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo(arg0,arg1);
        } 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());

      ProtectionPolicyAuditInfo *wrapperInstance = new ProtectionPolicyAuditInfo(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::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(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::Security::EnterpriseData::ProtectionPolicyAuditInfo^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectionPolicyAuditInfo(winRtInstance));
    }





    static void TargetDescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->TargetDescription;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void TargetDescriptionSetter(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::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->TargetDescription = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void SourceDescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->SourceDescription;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void SourceDescriptionSetter(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::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->SourceDescription = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void DataDescriptionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->DataDescription;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void DataDescriptionSetter(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::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->DataDescription = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ActionGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try  {
        ::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction result = wrapper->_instance->Action;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ActionSetter(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::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info.This())) {
        return;
      }

      ProtectionPolicyAuditInfo *wrapper = ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(info.This());

      try {

        ::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction winRtValue = static_cast<::Windows::Security::EnterpriseData::ProtectionPolicyAuditAction>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Action = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    private:
      ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectionPolicyAuditInfo(::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ UnwrapProtectionPolicyAuditInfo(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectionPolicyAuditInfo::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectionPolicyAuditInfo(::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ 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>(ProtectionPolicyAuditInfo::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ UnwrapProtectionPolicyAuditInfo(Local<Value> value) {
     return ProtectionPolicyAuditInfo::Unwrap<ProtectionPolicyAuditInfo>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectionPolicyAuditInfo(Local<Object> exports) {
    ProtectionPolicyAuditInfo::Init(exports);
  }

  class ProtectionPolicyManager : 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>("ProtectionPolicyManager").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);

        Local<Function> func;
        Local<FunctionTemplate> funcTemplate;




          
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("identity").ToLocalChecked(), IdentityGetter, IdentitySetter);
            Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("showEnterpriseIndicator").ToLocalChecked(), ShowEnterpriseIndicatorGetter, ShowEnterpriseIndicatorSetter);

        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);

        Nan::SetMethod(constructor, "isRoamableProtectionEnabled", IsRoamableProtectionEnabled);
        Nan::SetMethod(constructor, "getPrimaryManagedIdentityForIdentity", GetPrimaryManagedIdentityForIdentity);
        Nan::SetMethod(constructor, "logAuditEvent", LogAuditEvent);
        Nan::SetMethod(constructor, "hasContentBeenRevokedSince", HasContentBeenRevokedSince);
        Nan::SetMethod(constructor, "checkAccessForApp", CheckAccessForApp);
        Nan::SetMethod(constructor, "getEnforcementLevel", GetEnforcementLevel);
        Nan::SetMethod(constructor, "isUserDecryptionAllowed", IsUserDecryptionAllowed);
        Nan::SetMethod(constructor, "isProtectionUnderLockRequired", IsProtectionUnderLockRequired);
        Nan::SetMethod(constructor, "isIdentityManaged", IsIdentityManaged);
        Nan::SetMethod(constructor, "tryApplyProcessUIPolicy", TryApplyProcessUIPolicy);
        Nan::SetMethod(constructor, "clearProcessUIPolicy", ClearProcessUIPolicy);
        Nan::SetMethod(constructor, "createCurrentThreadNetworkContext", CreateCurrentThreadNetworkContext);
        Nan::SetMethod(constructor, "revokeContent", RevokeContent);
        Nan::SetMethod(constructor, "getForCurrentView", GetForCurrentView);
        Nan::SetMethod(constructor, "checkAccess", CheckAccess);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(RequestAccessAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("requestAccessAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(RequestAccessForAppAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("requestAccessForAppAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(RequestAccessToFilesForAppAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("requestAccessToFilesForAppAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(RequestAccessToFilesForProcessAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("requestAccessToFilesForProcessAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(IsFileProtectionRequiredAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("isFileProtectionRequiredAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(IsFileProtectionRequiredForNewFileAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("isFileProtectionRequiredForNewFileAsync").ToLocalChecked(), func);
        func = Nan::GetFunction(Nan::New<FunctionTemplate>(GetPrimaryManagedIdentityForNetworkEndpointAsync)).ToLocalChecked();
        Nan::Set(constructor, Nan::New<String>("getPrimaryManagedIdentityForNetworkEndpointAsync").ToLocalChecked(), func);
        Nan::SetAccessor(constructor, Nan::New<String>("isProtectionEnabled").ToLocalChecked(), IsProtectionEnabledGetter);
        Nan::SetAccessor(constructor, Nan::New<String>("primaryManagedIdentity").ToLocalChecked(), PrimaryManagedIdentityGetter);
        
              Local<Function> addListenerFunc = Nan::GetFunction(Nan::New<FunctionTemplate>(AddListener)).ToLocalChecked();
              Nan::Set(constructor, Nan::New<String>("addListener").ToLocalChecked(), addListenerFunc);
              Nan::Set(constructor, Nan::New<String>("on").ToLocalChecked(), addListenerFunc);
              Local<Function> removeListenerFunc = Nan::GetFunction(Nan::New<FunctionTemplate>(RemoveListener)).ToLocalChecked();
              Nan::Set(constructor, Nan::New<String>("removeListener").ToLocalChecked(), removeListenerFunc);
              Nan::Set(constructor, Nan::New<String>("off").ToLocalChecked(), removeListenerFunc);


        Nan::Set(exports, Nan::New<String>("ProtectionPolicyManager").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ProtectionPolicyManager(::Windows::Security::EnterpriseData::ProtectionPolicyManager^ 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::Security::EnterpriseData::ProtectionPolicyManager^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyManager^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ProtectionPolicyManager^) 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());

      ProtectionPolicyManager *wrapperInstance = new ProtectionPolicyManager(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::Security::EnterpriseData::ProtectionPolicyManager^>(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::Security::EnterpriseData::ProtectionPolicyManager^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ProtectionPolicyManager^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapProtectionPolicyManager(winRtInstance));
    }




    static void RequestAccessAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult>^ op;


      if (info.Length() == 6
          && info[0]->IsString()
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2])
          && info[3]->IsString()
          && info[4]->IsInt32())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[3])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior arg4 = static_cast<::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior>(Nan::To<int32_t>(info[4]).FromMaybe(0));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessAsync(arg0,arg1,arg2,arg3,arg4);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 4
          && info[0]->IsString()
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 5
          && info[0]->IsString()
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2])
          && info[3]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[3])));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessAsync(arg0,arg1,arg2,arg3);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 3
          && info[0]->IsString()
          && info[1]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessAsync(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::Security::EnterpriseData::ProtectionPolicyEvaluationResult> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<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};


            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 RequestAccessForAppAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult>^ op;


      if (info.Length() == 6
          && info[0]->IsString()
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2])
          && info[3]->IsString()
          && info[4]->IsInt32())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[3])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior arg4 = static_cast<::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior>(Nan::To<int32_t>(info[4]).FromMaybe(0));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessForAppAsync(arg0,arg1,arg2,arg3,arg4);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 4
          && info[0]->IsString()
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessForAppAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 5
          && info[0]->IsString()
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2])
          && info[3]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[3])));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessForAppAsync(arg0,arg1,arg2,arg3);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 3
          && info[0]->IsString()
          && info[1]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessForAppAsync(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::Security::EnterpriseData::ProtectionPolicyEvaluationResult> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<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};


            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 RequestAccessToFilesForAppAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult>^ op;


      if (info.Length() == 4
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(info[0]) || info[0]->IsArray())
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2]))
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Storage::IStorageItem^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Storage::IStorageItem^ {
                   return dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessToFilesForAppAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 6
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(info[0]) || info[0]->IsArray())
          && info[1]->IsString()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2])
          && info[3]->IsString()
          && info[4]->IsInt32())
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Storage::IStorageItem^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Storage::IStorageItem^ {
                   return dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[3])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior arg4 = static_cast<::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior>(Nan::To<int32_t>(info[4]).FromMaybe(0));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessToFilesForAppAsync(arg0,arg1,arg2,arg3,arg4);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<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};


            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 RequestAccessToFilesForProcessAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult>^ op;


      if (info.Length() == 4
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(info[0]) || info[0]->IsArray())
          && info[1]->IsUint32()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2]))
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Storage::IStorageItem^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Storage::IStorageItem^ {
                   return dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          unsigned int arg1 = static_cast<unsigned int>(Nan::To<uint32_t>(info[1]).FromMaybe(0));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessToFilesForProcessAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
      else if (info.Length() == 6
          && (NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(info[0]) || info[0]->IsArray())
          && info[1]->IsUint32()
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2])
          && info[3]->IsString()
          && info[4]->IsInt32())
      {
        try
        {
          ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^ arg0 = 
            [] (v8::Local<v8::Value> value) -> ::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^
            {
              if (value->IsArray())
              {
                return NodeRT::Collections::JsArrayToWinrtVector<::Windows::Storage::IStorageItem^>(value.As<Array>(), 
                 [](Local<Value> value) -> bool {
                   return NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(value);
                 },
                 [](Local<Value> value) -> ::Windows::Storage::IStorageItem^ {
                   return dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(value));
                 }
                );
              }
              else
              {
                return dynamic_cast<::Windows::Foundation::Collections::IIterable<::Windows::Storage::IStorageItem^>^>(NodeRT::Utils::GetObjectInstance(value));
              }
            } (info[0]);
          unsigned int arg1 = static_cast<unsigned int>(Nan::To<uint32_t>(info[1]).FromMaybe(0));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
          Platform::String^ arg3 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[3])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior arg4 = static_cast<::Windows::Security::EnterpriseData::ProtectionPolicyRequestAccessBehavior>(Nan::To<int32_t>(info[4]).FromMaybe(0));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RequestAccessToFilesForProcessAsync(arg0,arg1,arg2,arg3,arg4);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<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};


            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 IsFileProtectionRequiredAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<bool>^ op;


      if (info.Length() == 3
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageItem^>(info[0])
          && info[1]->IsString())
      {
        try
        {
          ::Windows::Storage::IStorageItem^ arg0 = dynamic_cast<::Windows::Storage::IStorageItem^>(NodeRT::Utils::GetObjectInstance(info[0]));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::IsFileProtectionRequiredAsync(arg0,arg1);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<bool> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<Boolean>(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void IsFileProtectionRequiredForNewFileAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<bool>^ op;


      if (info.Length() == 4
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Storage::IStorageFolder^>(info[0])
          && info[1]->IsString()
          && info[2]->IsString())
      {
        try
        {
          ::Windows::Storage::IStorageFolder^ arg0 = dynamic_cast<::Windows::Storage::IStorageFolder^>(NodeRT::Utils::GetObjectInstance(info[0]));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          Platform::String^ arg2 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[2])));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::IsFileProtectionRequiredForNewFileAsync(arg0,arg1,arg2);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<bool> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = Nan::New<Boolean>(result);
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {

            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);

            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }
      });
    }

    static void GetPrimaryManagedIdentityForNetworkEndpointAsync(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
        return;
      }

      ::Windows::Foundation::IAsyncOperation<::Platform::String^>^ op;


      if (info.Length() == 2
          && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Networking::HostName^>(info[0]))
      {
        try
        {
          ::Windows::Networking::HostName^ arg0 = dynamic_cast<::Windows::Networking::HostName^>(NodeRT::Utils::GetObjectInstance(info[0]));
            
          op = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::GetPrimaryManagedIdentityForNetworkEndpointAsync(arg0);
        } catch (Platform::Exception ^exception) {
            NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
            return;
        }
      }
 else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }

      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<::Platform::String^> t)
      {
        try {
          auto result = t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> error;
            Local<Value> arg1;
            {
              TryCatch tryCatch;
              arg1 = NodeRT::Utils::NewString(result->Data());
              if (tryCatch.HasCaught())
              {
                error = Nan::To<Object>(tryCatch.Exception()).ToLocalChecked();
              }
              else
              {
                error = Undefined();
              }
              if (arg1.IsEmpty()) arg1 = Undefined();
            }
            Local<Value> args[] = {error, arg1};


            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 IsRoamableProtectionEnabled(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          bool result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::IsRoamableProtectionEnabled(arg0);
          info.GetReturnValue().Set(Nan::New<Boolean>(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void GetPrimaryManagedIdentityForIdentity(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          Platform::String^ result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::GetPrimaryManagedIdentityForIdentity(arg0);
          info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void LogAuditEvent(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 3
        && info[0]->IsString()
        && info[1]->IsString()
        && NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^>(info[2]))
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          ::Windows::Security::EnterpriseData::ProtectionPolicyAuditInfo^ arg2 = UnwrapProtectionPolicyAuditInfo(info[2]);
          
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager::LogAuditEvent(arg0, arg1, arg2);
          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 HasContentBeenRevokedSince(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsDate())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          ::Windows::Foundation::DateTime arg1 = NodeRT::Utils::DateTimeFromJSDate(info[1]);
          
          bool result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::HasContentBeenRevokedSince(arg0, arg1);
          info.GetReturnValue().Set(Nan::New<Boolean>(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void CheckAccessForApp(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          
          ::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::CheckAccessForApp(arg0, arg1);
          info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void GetEnforcementLevel(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Windows::Security::EnterpriseData::EnforcementLevel result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::GetEnforcementLevel(arg0);
          info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void IsUserDecryptionAllowed(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          bool result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::IsUserDecryptionAllowed(arg0);
          info.GetReturnValue().Set(Nan::New<Boolean>(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void IsProtectionUnderLockRequired(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          bool result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::IsProtectionUnderLockRequired(arg0);
          info.GetReturnValue().Set(Nan::New<Boolean>(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void IsIdentityManaged(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          bool result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::IsIdentityManaged(arg0);
          info.GetReturnValue().Set(Nan::New<Boolean>(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void TryApplyProcessUIPolicy(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          bool result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::TryApplyProcessUIPolicy(arg0);
          info.GetReturnValue().Set(Nan::New<Boolean>(result));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void ClearProcessUIPolicy(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager::ClearProcessUIPolicy();
          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 CreateCurrentThreadNetworkContext(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Windows::Security::EnterpriseData::ThreadNetworkContext^ result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::CreateCurrentThreadNetworkContext(arg0);
          info.GetReturnValue().Set(WrapThreadNetworkContext(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 RevokeContent(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 1
        && info[0]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager::RevokeContent(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 GetForCurrentView(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 0)
      {
        try
        {
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager^ result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::GetForCurrentView();
          info.GetReturnValue().Set(WrapProtectionPolicyManager(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 CheckAccess(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() == 2
        && info[0]->IsString()
        && info[1]->IsString())
      {
        try
        {
          Platform::String^ arg0 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[0])));
          Platform::String^ arg1 = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), info[1])));
          
          ::Windows::Security::EnterpriseData::ProtectionPolicyEvaluationResult result;
          result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::CheckAccess(arg0, arg1);
          info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
          return;
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
 else  {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }

    static void IdentityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyManager^>(info.This())) {
        return;
      }

      ProtectionPolicyManager *wrapper = ProtectionPolicyManager::Unwrap<ProtectionPolicyManager>(info.This());

      try  {
        Platform::String^ result = wrapper->_instance->Identity;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void IdentitySetter(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::Security::EnterpriseData::ProtectionPolicyManager^>(info.This())) {
        return;
      }

      ProtectionPolicyManager *wrapper = ProtectionPolicyManager::Unwrap<ProtectionPolicyManager>(info.This());

      try {

        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(v8::Isolate::GetCurrent(), value)));

        wrapper->_instance->Identity = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      
    static void ShowEnterpriseIndicatorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ProtectionPolicyManager^>(info.This())) {
        return;
      }

      ProtectionPolicyManager *wrapper = ProtectionPolicyManager::Unwrap<ProtectionPolicyManager>(info.This());

      try  {
        bool result = wrapper->_instance->ShowEnterpriseIndicator;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      
    static void ShowEnterpriseIndicatorSetter(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::Security::EnterpriseData::ProtectionPolicyManager^>(info.This())) {
        return;
      }

      ProtectionPolicyManager *wrapper = ProtectionPolicyManager::Unwrap<ProtectionPolicyManager>(info.This());

      try {

        bool winRtValue = Nan::To<bool>(value).FromMaybe(false);

        wrapper->_instance->ShowEnterpriseIndicator = winRtValue;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
      


    static void IsProtectionEnabledGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      try
      {
        bool result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::IsProtectionEnabled;
        info.GetReturnValue().Set(Nan::New<Boolean>(result));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      

    static void PrimaryManagedIdentityGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info) {
      HandleScope scope;

      try
      {
        Platform::String^ result = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::PrimaryManagedIdentity;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
      

    static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)")));
        return;
      }

      String::Value eventName(v8::Isolate::GetCurrent(), info[0]);
      auto str = *eventName;

      Local<Function> callback = info[1].As<Function>();

      ::Windows::Foundation::EventRegistrationToken registrationToken;
      if (NodeRT::Utils::CaseInsenstiveEquals(L"policyChanged", str))
      {
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::PolicyChanged::add(
            ref new ::Windows::Foundation::EventHandler<::Platform::Object^>(
            [callbackObjPtr](::Platform::Object^ arg0, ::Platform::Object^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = CreateOpaqueWrapper(arg0);
                  wrappedArg1 = CreateOpaqueWrapper(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"protectedAccessResumed", str))
      {
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::ProtectedAccessResumed::add(
            ref new ::Windows::Foundation::EventHandler<::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^>(
            [callbackObjPtr](::Platform::Object^ arg0, ::Windows::Security::EnterpriseData::ProtectedAccessResumedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = CreateOpaqueWrapper(arg0);
                  wrappedArg1 = WrapProtectedAccessResumedEventArgs(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"protectedAccessSuspending", str))
      {
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::ProtectedAccessSuspending::add(
            ref new ::Windows::Foundation::EventHandler<::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^>(
            [callbackObjPtr](::Platform::Object^ arg0, ::Windows::Security::EnterpriseData::ProtectedAccessSuspendingEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = CreateOpaqueWrapper(arg0);
                  wrappedArg1 = WrapProtectedAccessSuspendingEventArgs(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
      else if (NodeRT::Utils::CaseInsenstiveEquals(L"protectedContentRevoked", str))
      {
      
        try {
          Persistent<Object>* perstPtr = new Persistent<Object>();
          perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback));
          std::shared_ptr<Persistent<Object>> callbackObjPtr(perstPtr,
            [] (Persistent<Object> *ptr ) {
              NodeUtils::Async::RunOnMain([ptr]() {
                ptr->Reset();
                delete ptr;
            });
          });

          registrationToken = ::Windows::Security::EnterpriseData::ProtectionPolicyManager::ProtectedContentRevoked::add(
            ref new ::Windows::Foundation::EventHandler<::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^>(
            [callbackObjPtr](::Platform::Object^ arg0, ::Windows::Security::EnterpriseData::ProtectedContentRevokedEventArgs^ arg1) {
              NodeUtils::Async::RunOnMain([callbackObjPtr , arg0, arg1]() {
                HandleScope scope;


                Local<Value> wrappedArg0;
                Local<Value> wrappedArg1;

                {
                  TryCatch tryCatch;


                  wrappedArg0 = CreateOpaqueWrapper(arg0);
                  wrappedArg1 = WrapProtectedContentRevokedEventArgs(arg1);


                  if (wrappedArg0.IsEmpty()) wrappedArg0 = Undefined();
                  if (wrappedArg1.IsEmpty()) wrappedArg1 = Undefined();
                }

                Local<Value> args[] = { wrappedArg0, wrappedArg1 };
                Local<Object> callbackObjLocalRef = Nan::New<Object>(*callbackObjPtr);
                NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args);
              });
            })
          );
        }
        catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }

      }
 else  {
        Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As<String>())));
        return;
      }

      Local<Value> tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New<String>(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked());
      Local<Object> tokenMap;

      if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) {
        tokenMap = Nan::New<Object>();
        NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New<String>(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap);
      } else {
        tokenMap = Nan::To<Object>(tokenMapVal).ToLocalChecked();
      }

      Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value)));
    }

    static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback")));
        return;
      }

      String::Value eventName(v8::Isolate::GetCurrent(), info[0]);
      auto str = *eventName;

      if ((!NodeRT::Utils::CaseInsenstiveEquals(L"policyChanged", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"protectedAccessResumed", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"protectedAccessSuspending", str)) &&(!NodeRT::Utils::CaseInsenstiveEquals(L"protectedContentRevoked", str))) {
        Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As<String>())));
        return;
      }

      Local<Function> callback = info[1].As<Function>();
      Local<Value> tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New<String>(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked());

      if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) {
        return;
      }

      Local<Value> opaqueWrapperObj =  Nan::Get(Nan::To<Object>(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked();

      if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) {
        return;
      }

      OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap<OpaqueWrapper>(opaqueWrapperObj.As<Object>());

      long long tokenValue = (long long) opaqueWrapper->GetObjectInstance();
      ::Windows::Foundation::EventRegistrationToken registrationToken;
      registrationToken.Value = tokenValue;

      try  {
        if (NodeRT::Utils::CaseInsenstiveEquals(L"policyChanged", str)) {
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager::PolicyChanged::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"protectedAccessResumed", str))
        {
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager::ProtectedAccessResumed::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"protectedAccessSuspending", str))
        {
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager::ProtectedAccessSuspending::remove(registrationToken);
        }
        else if (NodeRT::Utils::CaseInsenstiveEquals(L"protectedContentRevoked", str))
        {
          ::Windows::Security::EnterpriseData::ProtectionPolicyManager::ProtectedContentRevoked::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::Security::EnterpriseData::ProtectionPolicyManager^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapProtectionPolicyManager(::Windows::Security::EnterpriseData::ProtectionPolicyManager^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ProtectionPolicyManager^ UnwrapProtectionPolicyManager(Local<Value> value);
  };

  Persistent<FunctionTemplate> ProtectionPolicyManager::s_constructorTemplate;

  v8::Local<v8::Value> WrapProtectionPolicyManager(::Windows::Security::EnterpriseData::ProtectionPolicyManager^ 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>(ProtectionPolicyManager::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ProtectionPolicyManager^ UnwrapProtectionPolicyManager(Local<Value> value) {
     return ProtectionPolicyManager::Unwrap<ProtectionPolicyManager>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitProtectionPolicyManager(Local<Object> exports) {
    ProtectionPolicyManager::Init(exports);
  }

  class ThreadNetworkContext : 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>("ThreadNetworkContext").ToLocalChecked());
        localRef->InstanceTemplate()->SetInternalFieldCount(1);


          
            Nan::SetPrototypeMethod(localRef, "close", Close);
          




        Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
        Nan::SetMethod(constructor, "castFrom", CastFrom);



        Nan::Set(exports, Nan::New<String>("ThreadNetworkContext").ToLocalChecked(), constructor);
      }

      virtual ::Platform::Object^ GetObjectInstance() const override {
        return _instance;
      }

    private:

      ThreadNetworkContext(::Windows::Security::EnterpriseData::ThreadNetworkContext^ 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::Security::EnterpriseData::ThreadNetworkContext^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ThreadNetworkContext^>(info[0])) {
        try {
          winRtInstance = (::Windows::Security::EnterpriseData::ThreadNetworkContext^) 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());

      ThreadNetworkContext *wrapperInstance = new ThreadNetworkContext(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::Security::EnterpriseData::ThreadNetworkContext^>(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::Security::EnterpriseData::ThreadNetworkContext^ winRtInstance;
      try {
        winRtInstance = (::Windows::Security::EnterpriseData::ThreadNetworkContext^) NodeRT::Utils::GetObjectInstance(info[0]);
      } catch (Platform::Exception ^exception) {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }

      info.GetReturnValue().Set(WrapThreadNetworkContext(winRtInstance));
    }



    static void Close(Nan::NAN_METHOD_ARGS_TYPE info) {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Security::EnterpriseData::ThreadNetworkContext^>(info.This())) {
        return;
      }

      ThreadNetworkContext *wrapper = ThreadNetworkContext::Unwrap<ThreadNetworkContext>(info.This());

      if (info.Length() == 0) {
        try {
          delete wrapper->_instance;
          wrapper->_instance = nullptr;
          return;
        } catch (Platform::Exception ^exception) {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      } else {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    }





    private:
      ::Windows::Security::EnterpriseData::ThreadNetworkContext^ _instance;
      static Persistent<FunctionTemplate> s_constructorTemplate;

      friend v8::Local<v8::Value> WrapThreadNetworkContext(::Windows::Security::EnterpriseData::ThreadNetworkContext^ wintRtInstance);
      friend ::Windows::Security::EnterpriseData::ThreadNetworkContext^ UnwrapThreadNetworkContext(Local<Value> value);
  };

  Persistent<FunctionTemplate> ThreadNetworkContext::s_constructorTemplate;

  v8::Local<v8::Value> WrapThreadNetworkContext(::Windows::Security::EnterpriseData::ThreadNetworkContext^ 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>(ThreadNetworkContext::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::Security::EnterpriseData::ThreadNetworkContext^ UnwrapThreadNetworkContext(Local<Value> value) {
     return ThreadNetworkContext::Unwrap<ThreadNetworkContext>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitThreadNetworkContext(Local<Object> exports) {
    ThreadNetworkContext::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::Security::EnterpriseData::InitDataProtectionStatusEnum(target);
      NodeRT::Windows::Security::EnterpriseData::InitEnforcementLevelEnum(target);
      NodeRT::Windows::Security::EnterpriseData::InitFileProtectionStatusEnum(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectedImportExportStatusEnum(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectionPolicyAuditActionEnum(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectionPolicyEvaluationResultEnum(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectionPolicyRequestAccessBehaviorEnum(target);
      NodeRT::Windows::Security::EnterpriseData::InitBufferProtectUnprotectResult(target);
      NodeRT::Windows::Security::EnterpriseData::InitDataProtectionInfo(target);
      NodeRT::Windows::Security::EnterpriseData::InitDataProtectionManager(target);
      NodeRT::Windows::Security::EnterpriseData::InitFileProtectionInfo(target);
      NodeRT::Windows::Security::EnterpriseData::InitFileProtectionManager(target);
      NodeRT::Windows::Security::EnterpriseData::InitFileRevocationManager(target);
      NodeRT::Windows::Security::EnterpriseData::InitFileUnprotectOptions(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectedAccessResumedEventArgs(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectedAccessSuspendingEventArgs(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectedContainerExportResult(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectedContainerImportResult(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectedContentRevokedEventArgs(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectedFileCreateResult(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectionPolicyAuditInfo(target);
      NodeRT::Windows::Security::EnterpriseData::InitProtectionPolicyManager(target);
      NodeRT::Windows::Security::EnterpriseData::InitThreadNetworkContext(target);


  NodeRT::Utils::RegisterNameSpace("Windows.Security.EnterpriseData", target);
}



NODE_MODULE(binding, init)
