// Copyright (c) Microsoft Corporation
// All rights reserved. 
//
// Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
//
// THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. 
//
// See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.

// TODO: Verify that this is is still needed..
#define NTDDI_VERSION 0x06010000

#include <v8.h>
#include "nan.h"
#include <string>
#include <ppltasks.h>
#include "CollectionsConverter.h"
#include "CollectionsWrap.h"
#include "node-async.h"
#include "NodeRtUtils.h"
#include "OpaqueWrapper.h"
#include "WrapperBase.h"

#using <Windows.WinMD>

// this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search
// Some of the node header files brings windows definitions with the same names as some of the WinRT methods
#undef DocumentProperties
#undef GetObject
#undef CreateEvent
#undef FindText
#undef SendMessage

const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__";

using v8::Array;
using v8::String;
using v8::Handle;
using v8::Value;
using v8::Boolean;
using v8::Integer;
using v8::FunctionTemplate;
using v8::Object;
using v8::Local;
using v8::Function;
using v8::Date;
using v8::Number;
using v8::PropertyAttribute;
using v8::Primitive;
using Nan::HandleScope;
using Nan::Persistent;
using Nan::Undefined;
using Nan::True;
using Nan::False;
using Nan::Null;
using Nan::MaybeLocal;
using Nan::EscapableHandleScope;
using Nan::HandleScope;
using Nan::TryCatch;
using namespace concurrency;

namespace NodeRT { namespace Windows { namespace ApplicationModel { namespace SocialInfo { 

  v8::Local<v8::Value> WrapSocialUserInfo(::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ wintRtInstance);
  ::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ UnwrapSocialUserInfo(Local<Value> value);
  
  v8::Local<v8::Value> WrapSocialFeedContent(::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ wintRtInstance);
  ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ UnwrapSocialFeedContent(Local<Value> value);
  
  v8::Local<v8::Value> WrapSocialItemThumbnail(::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ wintRtInstance);
  ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ UnwrapSocialItemThumbnail(Local<Value> value);
  
  v8::Local<v8::Value> WrapSocialFeedSharedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ wintRtInstance);
  ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ UnwrapSocialFeedSharedItem(Local<Value> value);
  
  v8::Local<v8::Value> WrapSocialFeedChildItem(::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ wintRtInstance);
  ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ UnwrapSocialFeedChildItem(Local<Value> value);
  
  v8::Local<v8::Value> WrapSocialFeedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ wintRtInstance);
  ::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ UnwrapSocialFeedItem(Local<Value> value);
  


  static void InitSocialItemBadgeStyleEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("SocialItemBadgeStyle").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("hidden").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialItemBadgeStyle::Hidden)));
	Nan::Set(enumObject, Nan::New<String>("visible").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialItemBadgeStyle::Visible)));
	Nan::Set(enumObject, Nan::New<String>("visibleWithCount").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialItemBadgeStyle::VisibleWithCount)));
  }


  static void InitSocialFeedKindEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("SocialFeedKind").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("homeFeed").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialFeedKind::HomeFeed)));
	Nan::Set(enumObject, Nan::New<String>("contactFeed").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialFeedKind::ContactFeed)));
	Nan::Set(enumObject, Nan::New<String>("dashboard").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialFeedKind::Dashboard)));
  }


  static void InitSocialFeedItemStyleEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("SocialFeedItemStyle").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("default").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialFeedItemStyle::Default)));
	Nan::Set(enumObject, Nan::New<String>("photo").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialFeedItemStyle::Photo)));
  }


  static void InitSocialFeedUpdateModeEnum(const Local<Object> exports)
  {
    HandleScope scope;
    
	Local<Object> enumObject = Nan::New<Object>();
    Nan::Set(exports, Nan::New<String>("SocialFeedUpdateMode").ToLocalChecked(), enumObject);
	Nan::Set(enumObject, Nan::New<String>("append").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialFeedUpdateMode::Append)));
	Nan::Set(enumObject, Nan::New<String>("replace").ToLocalChecked(), Nan::New<Integer>(static_cast<int>(::Windows::ApplicationModel::SocialInfo::SocialFeedUpdateMode::Replace)));
  }



  
  static bool IsSocialInfoContractJsObject(Local<Value> value)
  {
    if (!value->IsObject())
    {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    return true;
  }

  ::Windows::ApplicationModel::SocialInfo::SocialInfoContract SocialInfoContractFromJsObject(Local<Value> value)
  {
    HandleScope scope;
    ::Windows::ApplicationModel::SocialInfo::SocialInfoContract 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> SocialInfoContractToJsObject(::Windows::ApplicationModel::SocialInfo::SocialInfoContract value)
  {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();

    
    return scope.Escape(obj);
  }

  
  static bool IsBitmapSizeJsObject(Local<Value> value)
  {
    if (!value->IsObject())
    {
      return false;
    }

    Local<String> symbol;
    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();

    symbol = Nan::New<String>("width").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false))
    {
      if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32())
      {
          return false;
      }
    }
    
    symbol = Nan::New<String>("height").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false))
    {
      if (!Nan::Get(obj,symbol).ToLocalChecked()->IsUint32())
      {
          return false;
      }
    }
    
    return true;
  }

  ::Windows::Graphics::Imaging::BitmapSize BitmapSizeFromJsObject(Local<Value> value)
  {
    HandleScope scope;
    ::Windows::Graphics::Imaging::BitmapSize returnValue;
    
    if (!value->IsObject())
    {
      Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object")));
      return returnValue;
    }

    Local<Object> obj = Nan::To<Object>(value).ToLocalChecked();
    Local<String> symbol;

    symbol = Nan::New<String>("width").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false))
    {
      returnValue.Width = static_cast<unsigned int>(Nan::To<uint32_t>(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0));
    }
    
    symbol = Nan::New<String>("height").ToLocalChecked();
    if (Nan::Has(obj, symbol).FromMaybe(false))
    {
      returnValue.Height = static_cast<unsigned int>(Nan::To<uint32_t>(Nan::Get(obj,symbol).ToLocalChecked()).FromMaybe(0));
    }
    
    return returnValue;
  }

  Local<Value> BitmapSizeToJsObject(::Windows::Graphics::Imaging::BitmapSize value)
  {
    EscapableHandleScope scope;

    Local<Object> obj = Nan::New<Object>();

    Nan::Set(obj, Nan::New<String>("width").ToLocalChecked(), Nan::New<Integer>(value.Width));
    Nan::Set(obj, Nan::New<String>("height").ToLocalChecked(), Nan::New<Integer>(value.Height));
    
    return scope.Escape(obj);
  }

  
  class SocialUserInfo : 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>("SocialUserInfo").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("userName").ToLocalChecked(), UserNameGetter, UserNameSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("targetUri").ToLocalChecked(), TargetUriGetter, TargetUriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("remoteId").ToLocalChecked(), RemoteIdGetter, RemoteIdSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("displayName").ToLocalChecked(), DisplayNameGetter, DisplayNameSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("SocialUserInfo").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    SocialUserInfo(::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ instance)
    {
      _instance = instance;
    }
    
    
    static void New(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

	    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This()))
      {
        if (info.Length() > 0)
        {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++)
          {
            argsPtr[i] = info[i];
          }

		  MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
		  if (res.IsEmpty())
		  {
			  return;
		  }
		  info.GetReturnValue().Set(res.ToLocalChecked());
		  return;
		}
		else
		{
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);
          if (res.IsEmpty())
          {
            return;
          }
          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }
      
      ::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialUserInfo^) 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());

      SocialUserInfo *wrapperInstance = new SocialUserInfo(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


	
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info)
    {
		HandleScope scope;
		if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info[0]))
		{
			Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
			return;
		}

		::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialUserInfo^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapSocialUserInfo(winRtInstance));
    }


  



    static void UserNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->UserName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void UserNameSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsString())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->UserName = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void TargetUriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->TargetUri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TargetUriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->TargetUri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void RemoteIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->RemoteId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RemoteIdSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsString())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->RemoteId = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void DisplayNameGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->DisplayName;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void DisplayNameSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsString())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialUserInfo^>(info.This()))
      {
        return;
      }

      SocialUserInfo *wrapper = SocialUserInfo::Unwrap<SocialUserInfo>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->DisplayName = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapSocialUserInfo(::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ wintRtInstance);
    friend ::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ UnwrapSocialUserInfo(Local<Value> value);
  };
  Persistent<FunctionTemplate> SocialUserInfo::s_constructorTemplate;

  v8::Local<v8::Value> WrapSocialUserInfo(::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ 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>(SocialUserInfo::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ UnwrapSocialUserInfo(Local<Value> value)
  {
     return SocialUserInfo::Unwrap<SocialUserInfo>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSocialUserInfo(Local<Object> exports)
  {
    SocialUserInfo::Init(exports);
  }

  class SocialFeedContent : 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>("SocialFeedContent").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("title").ToLocalChecked(), TitleGetter, TitleSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("targetUri").ToLocalChecked(), TargetUriGetter, TargetUriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("message").ToLocalChecked(), MessageGetter, MessageSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("SocialFeedContent").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    SocialFeedContent(::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ instance)
    {
      _instance = instance;
    }
    
    
    static void New(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

	    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This()))
      {
        if (info.Length() > 0)
        {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++)
          {
            argsPtr[i] = info[i];
          }

		  MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
		  if (res.IsEmpty())
		  {
			  return;
		  }
		  info.GetReturnValue().Set(res.ToLocalChecked());
		  return;
		}
		else
		{
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);
          if (res.IsEmpty())
          {
            return;
          }
          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }
      
      ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedContent^) 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());

      SocialFeedContent *wrapperInstance = new SocialFeedContent(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


	
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info)
    {
		HandleScope scope;
		if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info[0]))
		{
			Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
			return;
		}

		::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedContent^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapSocialFeedContent(winRtInstance));
    }


  



    static void TitleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info.This()))
      {
        return;
      }

      SocialFeedContent *wrapper = SocialFeedContent::Unwrap<SocialFeedContent>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Title;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TitleSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsString())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info.This()))
      {
        return;
      }

      SocialFeedContent *wrapper = SocialFeedContent::Unwrap<SocialFeedContent>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Title = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void TargetUriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info.This()))
      {
        return;
      }

      SocialFeedContent *wrapper = SocialFeedContent::Unwrap<SocialFeedContent>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->TargetUri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TargetUriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info.This()))
      {
        return;
      }

      SocialFeedContent *wrapper = SocialFeedContent::Unwrap<SocialFeedContent>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->TargetUri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void MessageGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info.This()))
      {
        return;
      }

      SocialFeedContent *wrapper = SocialFeedContent::Unwrap<SocialFeedContent>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->Message;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void MessageSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsString())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedContent^>(info.This()))
      {
        return;
      }

      SocialFeedContent *wrapper = SocialFeedContent::Unwrap<SocialFeedContent>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->Message = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapSocialFeedContent(::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ wintRtInstance);
    friend ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ UnwrapSocialFeedContent(Local<Value> value);
  };
  Persistent<FunctionTemplate> SocialFeedContent::s_constructorTemplate;

  v8::Local<v8::Value> WrapSocialFeedContent(::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ 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>(SocialFeedContent::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ UnwrapSocialFeedContent(Local<Value> value)
  {
     return SocialFeedContent::Unwrap<SocialFeedContent>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSocialFeedContent(Local<Object> exports)
  {
    SocialFeedContent::Init(exports);
  }

  class SocialItemThumbnail : 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>("SocialItemThumbnail").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
      Local<Function> func;
      Local<FunctionTemplate> funcTemplate;
                  
      Nan::SetPrototypeMethod(localRef, "setImageAsync", SetImageAsync);
      
                  
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("targetUri").ToLocalChecked(), TargetUriGetter, TargetUriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("imageUri").ToLocalChecked(), ImageUriGetter, ImageUriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("bitmapSize").ToLocalChecked(), BitmapSizeGetter, BitmapSizeSetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("SocialItemThumbnail").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    SocialItemThumbnail(::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ instance)
    {
      _instance = instance;
    }
    
    
    static void New(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

	    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This()))
      {
        if (info.Length() > 0)
        {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++)
          {
            argsPtr[i] = info[i];
          }

		  MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
		  if (res.IsEmpty())
		  {
			  return;
		  }
		  info.GetReturnValue().Set(res.ToLocalChecked());
		  return;
		}
		else
		{
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);
          if (res.IsEmpty())
          {
            return;
          }
          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }
      
      ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail();
        }
        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());

      SocialItemThumbnail *wrapperInstance = new SocialItemThumbnail(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


	
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info)
    {
		HandleScope scope;
		if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info[0]))
		{
			Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
			return;
		}

		::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapSocialItemThumbnail(winRtInstance));
    }


    static void SetImageAsync(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info.This()))
      {
        return;
      }

      if (info.Length() == 0 || !info[info.Length() -1]->IsFunction())
      {
          Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given")));
          return;
      }

      SocialItemThumbnail *wrapper = SocialItemThumbnail::Unwrap<SocialItemThumbnail>(info.This());

      ::Windows::Foundation::IAsyncAction^ 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 = wrapper->_instance->SetImageAsync(arg0);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else 
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found")));
        return;
      }
    
      auto opTask = create_task(op);
      uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As<Function>());

      opTask.then( [asyncToken] (task<void> t) 
      {	
        try
        {
          t.get();
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) {


            Local<Value> args[] = {Undefined()};

		    
            invokeCallback(_countof(args), args);
          });
        }
        catch (Platform::Exception^ exception)
        {
          NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) {
             
            Local<Value> error = NodeRT::Utils::WinRtExceptionToJsError(exception);
        
            Local<Value> args[] = {error};
            invokeCallback(_countof(args), args);
          });
        }  		
      });
    }
  



    static void TargetUriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info.This()))
      {
        return;
      }

      SocialItemThumbnail *wrapper = SocialItemThumbnail::Unwrap<SocialItemThumbnail>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->TargetUri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TargetUriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info.This()))
      {
        return;
      }

      SocialItemThumbnail *wrapper = SocialItemThumbnail::Unwrap<SocialItemThumbnail>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->TargetUri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ImageUriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info.This()))
      {
        return;
      }

      SocialItemThumbnail *wrapper = SocialItemThumbnail::Unwrap<SocialItemThumbnail>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->ImageUri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ImageUriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info.This()))
      {
        return;
      }

      SocialItemThumbnail *wrapper = SocialItemThumbnail::Unwrap<SocialItemThumbnail>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->ImageUri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void BitmapSizeGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info.This()))
      {
        return;
      }

      SocialItemThumbnail *wrapper = SocialItemThumbnail::Unwrap<SocialItemThumbnail>(info.This());

      try 
      {
        ::Windows::Graphics::Imaging::BitmapSize result = wrapper->_instance->BitmapSize;
        info.GetReturnValue().Set(BitmapSizeToJsObject(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void BitmapSizeSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!IsBitmapSizeJsObject(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(info.This()))
      {
        return;
      }

      SocialItemThumbnail *wrapper = SocialItemThumbnail::Unwrap<SocialItemThumbnail>(info.This());

      try 
      {
        
        ::Windows::Graphics::Imaging::BitmapSize winRtValue = BitmapSizeFromJsObject(value);

        wrapper->_instance->BitmapSize = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    


  private:
    ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapSocialItemThumbnail(::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ wintRtInstance);
    friend ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ UnwrapSocialItemThumbnail(Local<Value> value);
  };
  Persistent<FunctionTemplate> SocialItemThumbnail::s_constructorTemplate;

  v8::Local<v8::Value> WrapSocialItemThumbnail(::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ 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>(SocialItemThumbnail::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ UnwrapSocialItemThumbnail(Local<Value> value)
  {
     return SocialItemThumbnail::Unwrap<SocialItemThumbnail>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSocialItemThumbnail(Local<Object> exports)
  {
    SocialItemThumbnail::Init(exports);
  }

  class SocialFeedSharedItem : 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>("SocialFeedSharedItem").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnail").ToLocalChecked(), ThumbnailGetter, ThumbnailSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("targetUri").ToLocalChecked(), TargetUriGetter, TargetUriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("originalSource").ToLocalChecked(), OriginalSourceGetter, OriginalSourceSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("content").ToLocalChecked(), ContentGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("SocialFeedSharedItem").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    SocialFeedSharedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ instance)
    {
      _instance = instance;
    }
    
    
    static void New(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

	    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This()))
      {
        if (info.Length() > 0)
        {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++)
          {
            argsPtr[i] = info[i];
          }

		  MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
		  if (res.IsEmpty())
		  {
			  return;
		  }
		  info.GetReturnValue().Set(res.ToLocalChecked());
		  return;
		}
		else
		{
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);
          if (res.IsEmpty())
          {
            return;
          }
          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }
      
      ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem();
        }
        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());

      SocialFeedSharedItem *wrapperInstance = new SocialFeedSharedItem(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


	
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info)
    {
		HandleScope scope;
		if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info[0]))
		{
			Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
			return;
		}

		::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapSocialFeedSharedItem(winRtInstance));
    }


  



    static void TimestampGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Timestamp;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TimestampSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsDate())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        
        ::Windows::Foundation::DateTime winRtValue = NodeRT::Utils::DateTimeFromJSDate(value);

        wrapper->_instance->Timestamp = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ThumbnailGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ result = wrapper->_instance->Thumbnail;
        info.GetReturnValue().Set(WrapSocialItemThumbnail(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ThumbnailSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ winRtValue = dynamic_cast<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->Thumbnail = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void TargetUriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->TargetUri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TargetUriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->TargetUri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void OriginalSourceGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->OriginalSource;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void OriginalSourceSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->OriginalSource = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ContentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(info.This()))
      {
        return;
      }

      SocialFeedSharedItem *wrapper = SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ result = wrapper->_instance->Content;
        info.GetReturnValue().Set(WrapSocialFeedContent(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapSocialFeedSharedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ wintRtInstance);
    friend ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ UnwrapSocialFeedSharedItem(Local<Value> value);
  };
  Persistent<FunctionTemplate> SocialFeedSharedItem::s_constructorTemplate;

  v8::Local<v8::Value> WrapSocialFeedSharedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ 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>(SocialFeedSharedItem::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ UnwrapSocialFeedSharedItem(Local<Value> value)
  {
     return SocialFeedSharedItem::Unwrap<SocialFeedSharedItem>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSocialFeedSharedItem(Local<Object> exports)
  {
    SocialFeedSharedItem::Init(exports);
  }

  class SocialFeedChildItem : 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>("SocialFeedChildItem").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("targetUri").ToLocalChecked(), TargetUriGetter, TargetUriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sharedItem").ToLocalChecked(), SharedItemGetter, SharedItemSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("author").ToLocalChecked(), AuthorGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("primaryContent").ToLocalChecked(), PrimaryContentGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("secondaryContent").ToLocalChecked(), SecondaryContentGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnails").ToLocalChecked(), ThumbnailsGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("SocialFeedChildItem").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    SocialFeedChildItem(::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ instance)
    {
      _instance = instance;
    }
    
    
    static void New(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

	    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This()))
      {
        if (info.Length() > 0)
        {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++)
          {
            argsPtr[i] = info[i];
          }

		  MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
		  if (res.IsEmpty())
		  {
			  return;
		  }
		  info.GetReturnValue().Set(res.ToLocalChecked());
		  return;
		}
		else
		{
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);
          if (res.IsEmpty())
          {
            return;
          }
          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }
      
      ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem();
        }
        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());

      SocialFeedChildItem *wrapperInstance = new SocialFeedChildItem(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


	
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info)
    {
		HandleScope scope;
		if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info[0]))
		{
			Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
			return;
		}

		::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapSocialFeedChildItem(winRtInstance));
    }


  



    static void TimestampGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Timestamp;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TimestampSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsDate())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        
        ::Windows::Foundation::DateTime winRtValue = NodeRT::Utils::DateTimeFromJSDate(value);

        wrapper->_instance->Timestamp = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void TargetUriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->TargetUri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TargetUriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->TargetUri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void SharedItemGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ result = wrapper->_instance->SharedItem;
        info.GetReturnValue().Set(WrapSocialFeedSharedItem(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SharedItemSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ winRtValue = dynamic_cast<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->SharedItem = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void AuthorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ result = wrapper->_instance->Author;
        info.GetReturnValue().Set(WrapSocialUserInfo(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void PrimaryContentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ result = wrapper->_instance->PrimaryContent;
        info.GetReturnValue().Set(WrapSocialFeedContent(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SecondaryContentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ result = wrapper->_instance->SecondaryContent;
        info.GetReturnValue().Set(WrapSocialFeedContent(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ThumbnailsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(info.This()))
      {
        return;
      }

      SocialFeedChildItem *wrapper = SocialFeedChildItem::Unwrap<SocialFeedChildItem>(info.This());

      try 
      {
        ::Windows::Foundation::Collections::IVector<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>^ result = wrapper->_instance->Thumbnails;
        info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>::CreateVectorWrapper(result, 
            [](::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ val) -> Local<Value> {
              return WrapSocialItemThumbnail(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ {
              return UnwrapSocialItemThumbnail(value);
            }
          ));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapSocialFeedChildItem(::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ wintRtInstance);
    friend ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ UnwrapSocialFeedChildItem(Local<Value> value);
  };
  Persistent<FunctionTemplate> SocialFeedChildItem::s_constructorTemplate;

  v8::Local<v8::Value> WrapSocialFeedChildItem(::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ 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>(SocialFeedChildItem::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ UnwrapSocialFeedChildItem(Local<Value> value)
  {
     return SocialFeedChildItem::Unwrap<SocialFeedChildItem>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSocialFeedChildItem(Local<Object> exports)
  {
    SocialFeedChildItem::Init(exports);
  }

  class SocialFeedItem : 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>("SocialFeedItem").ToLocalChecked());
      localRef->InstanceTemplate()->SetInternalFieldCount(1);
      
                              
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("timestamp").ToLocalChecked(), TimestampGetter, TimestampSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("targetUri").ToLocalChecked(), TargetUriGetter, TargetUriSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("style").ToLocalChecked(), StyleGetter, StyleSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("sharedItem").ToLocalChecked(), SharedItemGetter, SharedItemSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("remoteId").ToLocalChecked(), RemoteIdGetter, RemoteIdSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("childItem").ToLocalChecked(), ChildItemGetter, ChildItemSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("badgeStyle").ToLocalChecked(), BadgeStyleGetter, BadgeStyleSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("badgeCountValue").ToLocalChecked(), BadgeCountValueGetter, BadgeCountValueSetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("author").ToLocalChecked(), AuthorGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("primaryContent").ToLocalChecked(), PrimaryContentGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("secondaryContent").ToLocalChecked(), SecondaryContentGetter);
      Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("thumbnails").ToLocalChecked(), ThumbnailsGetter);
      
      Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
	  Nan::SetMethod(constructor, "castFrom", CastFrom);


      Nan::Set(exports, Nan::New<String>("SocialFeedItem").ToLocalChecked(), constructor);
    }


    virtual ::Platform::Object^ GetObjectInstance() const override
    {
      return _instance;
    }

  private:
    
    SocialFeedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ instance)
    {
      _instance = instance;
    }
    
    
    static void New(Nan::NAN_METHOD_ARGS_TYPE info)
    {
      HandleScope scope;

	    Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(s_constructorTemplate);

      // in case the constructor was called without the new operator
      if (!localRef->HasInstance(info.This()))
      {
        if (info.Length() > 0)
        {
          std::unique_ptr<Local<Value> []> constructorArgs(new Local<Value>[info.Length()]);

          Local<Value> *argsPtr = constructorArgs.get();
          for (int i = 0; i < info.Length(); i++)
          {
            argsPtr[i] = info[i];
          }

		  MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get());
		  if (res.IsEmpty())
		  {
			  return;
		  }
		  info.GetReturnValue().Set(res.ToLocalChecked());
		  return;
		}
		else
		{
          MaybeLocal<Object> res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr);
          if (res.IsEmpty())
          {
            return;
          }
          info.GetReturnValue().Set(res.ToLocalChecked());
          return;
        }
      }
      
      ::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ winRtInstance;


      if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) &&
        NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info[0]))
      {
        try 
        {
          winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedItem^) NodeRT::Utils::GetObjectInstance(info[0]);
        }
        catch (Platform::Exception ^exception)
        {
          NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
          return;
        }
      }
      else if (info.Length() == 0)
      {
        try
        {
          winRtInstance = ref new ::Windows::ApplicationModel::SocialInfo::SocialFeedItem();
        }
        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());

      SocialFeedItem *wrapperInstance = new SocialFeedItem(winRtInstance);
      wrapperInstance->Wrap(info.This());

      info.GetReturnValue().Set(info.This());
    }


	
    static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info)
    {
		HandleScope scope;
		if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info[0]))
		{
			Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
			return;
		}

		::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ winRtInstance;
		try
		{
			winRtInstance = (::Windows::ApplicationModel::SocialInfo::SocialFeedItem^) NodeRT::Utils::GetObjectInstance(info[0]);
		}
		catch (Platform::Exception ^exception)
		{
			NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
			return;
		}

		info.GetReturnValue().Set(WrapSocialFeedItem(winRtInstance));
    }


  



    static void TimestampGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::Foundation::DateTime result = wrapper->_instance->Timestamp;
        info.GetReturnValue().Set(NodeRT::Utils::DateTimeToJS(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TimestampSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsDate())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        ::Windows::Foundation::DateTime winRtValue = NodeRT::Utils::DateTimeFromJSDate(value);

        wrapper->_instance->Timestamp = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void TargetUriGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::Foundation::Uri^ result = wrapper->_instance->TargetUri;
        info.GetReturnValue().Set(NodeRT::Utils::CreateExternalWinRTObject("Windows.Foundation", "Uri", result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void TargetUriSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::Foundation::Uri^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        ::Windows::Foundation::Uri^ winRtValue = dynamic_cast<::Windows::Foundation::Uri^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->TargetUri = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void StyleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedItemStyle result = wrapper->_instance->Style;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void StyleSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsInt32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::SocialInfo::SocialFeedItemStyle winRtValue = static_cast<::Windows::ApplicationModel::SocialInfo::SocialFeedItemStyle>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->Style = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void SharedItemGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ result = wrapper->_instance->SharedItem;
        info.GetReturnValue().Set(WrapSocialFeedSharedItem(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SharedItemSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^ winRtValue = dynamic_cast<::Windows::ApplicationModel::SocialInfo::SocialFeedSharedItem^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->SharedItem = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void RemoteIdGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        Platform::String^ result = wrapper->_instance->RemoteId;
        info.GetReturnValue().Set(NodeRT::Utils::NewString(result->Data()));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void RemoteIdSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsString())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        Platform::String^ winRtValue = ref new Platform::String(NodeRT::Utils::StringToWchar(v8::String::Value(value)));

        wrapper->_instance->RemoteId = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void ChildItemGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ result = wrapper->_instance->ChildItem;
        info.GetReturnValue().Set(WrapSocialFeedChildItem(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ChildItemSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(value))
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^ winRtValue = dynamic_cast<::Windows::ApplicationModel::SocialInfo::SocialFeedChildItem^>(NodeRT::Utils::GetObjectInstance(value));

        wrapper->_instance->ChildItem = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void BadgeStyleGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialItemBadgeStyle result = wrapper->_instance->BadgeStyle;
        info.GetReturnValue().Set(Nan::New<Integer>(static_cast<int>(result)));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void BadgeStyleSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsInt32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        ::Windows::ApplicationModel::SocialInfo::SocialItemBadgeStyle winRtValue = static_cast<::Windows::ApplicationModel::SocialInfo::SocialItemBadgeStyle>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->BadgeStyle = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void BadgeCountValueGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        int result = wrapper->_instance->BadgeCountValue;
        info.GetReturnValue().Set(Nan::New<Integer>(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void BadgeCountValueSetter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info)
    {
      HandleScope scope;
      
      if (!value->IsInt32())
      {
        Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
        return;
      }

      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        
        int winRtValue = static_cast<int>(Nan::To<int32_t>(value).FromMaybe(0));

        wrapper->_instance->BadgeCountValue = winRtValue;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
      }
    }
    
    static void AuthorGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialUserInfo^ result = wrapper->_instance->Author;
        info.GetReturnValue().Set(WrapSocialUserInfo(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void PrimaryContentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ result = wrapper->_instance->PrimaryContent;
        info.GetReturnValue().Set(WrapSocialFeedContent(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void SecondaryContentGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::ApplicationModel::SocialInfo::SocialFeedContent^ result = wrapper->_instance->SecondaryContent;
        info.GetReturnValue().Set(WrapSocialFeedContent(result));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    
    static void ThumbnailsGetter(Local<String> property, const Nan::PropertyCallbackInfo<v8::Value> &info)
    {
      HandleScope scope;
      
      if (!NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialFeedItem^>(info.This()))
      {
        return;
      }

      SocialFeedItem *wrapper = SocialFeedItem::Unwrap<SocialFeedItem>(info.This());

      try 
      {
        ::Windows::Foundation::Collections::IVector<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>^ result = wrapper->_instance->Thumbnails;
        info.GetReturnValue().Set(NodeRT::Collections::VectorWrapper<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>::CreateVectorWrapper(result, 
            [](::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ val) -> Local<Value> {
              return WrapSocialItemThumbnail(val);
            },
            [](Local<Value> value) -> bool {
              return NodeRT::Utils::IsWinRtWrapperOf<::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^>(value);
            },
            [](Local<Value> value) -> ::Windows::ApplicationModel::SocialInfo::SocialItemThumbnail^ {
              return UnwrapSocialItemThumbnail(value);
            }
          ));
        return;
      }
      catch (Platform::Exception ^exception)
      {
        NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
        return;
      }
    }
    


  private:
    ::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ _instance;
    static Persistent<FunctionTemplate> s_constructorTemplate;

    friend v8::Local<v8::Value> WrapSocialFeedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ wintRtInstance);
    friend ::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ UnwrapSocialFeedItem(Local<Value> value);
  };
  Persistent<FunctionTemplate> SocialFeedItem::s_constructorTemplate;

  v8::Local<v8::Value> WrapSocialFeedItem(::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ 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>(SocialFeedItem::s_constructorTemplate);
    return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked());
  }

  ::Windows::ApplicationModel::SocialInfo::SocialFeedItem^ UnwrapSocialFeedItem(Local<Value> value)
  {
     return SocialFeedItem::Unwrap<SocialFeedItem>(Nan::To<Object>(value).ToLocalChecked())->_instance;
  }

  void InitSocialFeedItem(Local<Object> exports)
  {
    SocialFeedItem::Init(exports);
  }

} } } } 

NAN_MODULE_INIT(init)
{
  // we ignore failures for now since it probably means that the initialization already happened for STA, and that's cool
  CoInitializeEx(nullptr, COINIT_MULTITHREADED);
  //if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED)))
  /*{
    Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"error in CoInitializeEx()")));
    return;
  }*/
  
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialItemBadgeStyleEnum(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialFeedKindEnum(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialFeedItemStyleEnum(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialFeedUpdateModeEnum(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialUserInfo(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialFeedContent(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialItemThumbnail(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialFeedSharedItem(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialFeedChildItem(target);
  NodeRT::Windows::ApplicationModel::SocialInfo::InitSocialFeedItem(target);

  NodeRT::Utils::RegisterNameSpace("Windows.ApplicationModel.SocialInfo", target);
}


NODE_MODULE(binding, init)